Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Crypto-TII/claasp into d…
Browse files Browse the repository at this point in the history
…evelop
Mario Pinto committed Jan 16, 2025
2 parents d25250d + cb2c6ab commit 44e80cd
Showing 150 changed files with 12,095 additions and 3,812 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/build-claasp-base-image.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
name: Build and push image for testing
name: Build and push Intel and M1 images for testing
on:
push:
branches:
- main

jobs:
build-image:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -25,11 +28,11 @@ jobs:
restore-keys: |
${{ runner.os }}-buildx-
- name: Login dockerhub
- name: Login Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}

- name: Build & Push
uses: docker/build-push-action@v4
@@ -38,7 +41,7 @@ jobs:
context: .
file: ./docker/Dockerfile
push: true
tags: tiicrc/claasp-base:latest
tags: ${{ matrix.os == 'ubuntu-latest' && 'tiicrc/claasp-base:latest' || 'tiicrc/claasp-m1-base:latest' }}
target: claasp-base
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
5 changes: 4 additions & 1 deletion .github/workflows/build-staging-webapp-image.yaml
Original file line number Diff line number Diff line change
@@ -25,13 +25,16 @@ jobs:
restore-keys: |
${{ runner.os }}-buildx-
- name: Login dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}

- name: Clean docker
run: |
docker system prune -a --volumes -f
- name: Build & Push
uses: docker/build-push-action@v4
id: built-image
5 changes: 3 additions & 2 deletions .github/workflows/generate-and-submit-documentation.yaml
Original file line number Diff line number Diff line change
@@ -21,13 +21,14 @@ jobs:
uses: actions-js/push@master
with:
branch: 'main'
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.AUTHORIZATION_TOKEN }}
message: "Update documentation"
force: true

- name: Update develop branch
uses: morbalint/git-merge-action@v1
with:
target: 'develop'
source: 'main'
strategy_options: 'ours'
token: ${{ secrets.WORKFLOW_TOKEN }}
token: ${{ secrets.AUTHORIZATION_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/publish-claasp-on-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish CLAASP package on PyPi

on:
push:
branches:
- main
tags:
- 'v*.*.*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install build tools
run: |
python3 -m pip install --upgrade pip
python3 -m pip install setuptools wheel
- name: Install twine
run: sudo apt install twine

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python3 setup.py sdist bdist_wheel
twine upload dist/*
4 changes: 3 additions & 1 deletion .github/workflows/run-doctest.yaml
Original file line number Diff line number Diff line change
@@ -34,4 +34,6 @@ jobs:
- name: Run test
run: |
cd /home/runner/_work/claasp
make test
make test
env:
GUROBI_COMPUTE_SERVER: ${{ secrets.GUROBI_COMPUTE_SERVER }}
8 changes: 5 additions & 3 deletions .github/workflows/run-pytest-and-sonarcloud-scan.yaml
Original file line number Diff line number Diff line change
@@ -39,9 +39,11 @@ jobs:
run: |
cd /home/runner/_work/claasp
make remote-pytest
env:
GUROBI_COMPUTE_SERVER: ${{ secrets.GUROBI_COMPUTE_SERVER }}

- name: Upload Coverage.xml to artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: /home/runner/_work/claasp/coverage.xml
@@ -56,7 +58,7 @@ jobs:
fetch-depth: 0

- name: Download Latest Coverage.xml from Artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: coverage-report

@@ -72,4 +74,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
needs: run-pytest
needs: run-pytest
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -3,13 +3,14 @@
# Package folder
PACKAGE=claasp

# change to your sage command if needed
# Change to your sage command if needed
SAGE_BIN=`if [ -s SAGE_BIN_PATH ]; then cat SAGE_BIN_PATH; else echo sage; fi`
MODULE?=$(PACKAGE)

DOCKER_IMG_NAME=claasp
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`


all: install
if [ $(CURRENT_BRANCH) == "main" ]; then\
$(SAGE_BIN) setup.py testall;\
@@ -24,13 +25,23 @@ rundocker: builddocker
docker run -i -p 8887:8887 --mount type=bind,source=`pwd`,target=/home/sage/tii-claasp -t $(DOCKER_IMG_NAME) \
sh -c "cd /home/sage/tii-claasp && make install && cd /home/sage/tii-claasp && exec /bin/bash"

rundockerhub:
docker pull tiicrc/claasp-base \
docker run -i -p 8887:8887 --mount type=bind,source=`pwd`,target=/home/sage/tii-claasp -t $(DOCKER_IMG_NAME) \
sh -c "cd /home/sage/tii-claasp && make install && cd /home/sage/tii-claasp && exec /bin/bash"

builddocker-m1:
docker build -f docker/Dockerfile --platform linux/x86_64 --target claasp-base -t $(DOCKER_IMG_NAME) .

rundocker-m1: builddocker-m1
docker run -i -p 8888:8888 --mount type=bind,source=`pwd`,target=/home/sage/tii-claasp -t $(DOCKER_IMG_NAME) \
sh -c "cd /home/sage/tii-claasp && make install && cd /home/sage/tii-claasp && exec /bin/bash"

rundockerhub-m1:
docker pull tiicrc/claasp-m1-base \
docker run -i -p 8888:8888 --mount type=bind,source=`pwd`,target=/home/sage/tii-claasp -t $(DOCKER_IMG_NAME) \
sh -c "cd /home/sage/tii-claasp && make install && cd /home/sage/tii-claasp && exec /bin/bash"

install:
$(SAGE_BIN) -pip install --upgrade --no-index -v .

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

<div align="center">
<img src="https://github.com/Crypto-TII/claasp/assets/63452003/e226b467-adaa-486c-9558-45526c62d6e8" alt="claasp-logo"></img>
</div>

# CLAASP: A Cryptographic Library for the Automated Analysis of Symmetric Primitives

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Crypto-TII_claasp&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Crypto-TII_claasp)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.5.0
v2.6.0
5 changes: 5 additions & 0 deletions claasp/cipher.py
Original file line number Diff line number Diff line change
@@ -1050,6 +1050,9 @@ def get_model(self, technique, problem):
- ``technique`` -- **string** ; sat, smt, milp or cp
- ``problem`` -- **string** ; xor_differential, xor_linear, cipher_model (more to be added as more model types are added to the library)
"""
if technique == 'cp':
technique = 'mzn'
formalism = 'cp'
if problem == 'xor_differential':
constructor_name = f'{technique[0].capitalize()}{technique[1:]}XorDifferentialModel'
elif problem == "xor_linear":
@@ -1058,6 +1061,8 @@ def get_model(self, technique, problem):
constructor_name = f'{technique[0].capitalize()}{technique[1:]}CipherModel'

module_name = f'claasp.cipher_modules.models.{technique}.{technique}_models.{technique}_{problem}_model'
if technique == 'mzn':
module_name = f'claasp.cipher_modules.models.{formalism}.{technique}_models.{technique}_{problem}_model'

module = importlib.import_module(module_name)
constructor = getattr(module, constructor_name)
9 changes: 4 additions & 5 deletions claasp/cipher_modules/continuous_diffusion_analysis.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# ****************************************************************************
# Copyright 2023 Technology Innovation Institute
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ****************************************************************************
@@ -243,9 +243,8 @@ def mag(xx):

@staticmethod
def _get_graph_representation_components_by_type(graph_representation, type_name):
cipher_rounds = graph_representation["cipher_rounds"][0]
cipher_rounds = sum(graph_representation["cipher_rounds"], [])
components_by_type = list(filter(lambda d: d['type'] in [type_name], cipher_rounds))

return components_by_type

@staticmethod
Loading

0 comments on commit 44e80cd

Please sign in to comment.