-
Notifications
You must be signed in to change notification settings - Fork 2
[SHA3 / ML-KEM/ ML-DSA] C extraction #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jschneider-bensch
wants to merge
47
commits into
main
Choose a base branch
from
jonas/mldsa-c-extraction-ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
ef243e1
Initial extraction script
jschneider-bensch ded8c0f
Don't clone (Eurydice issue)
jschneider-bensch 8953d1b
Merge branch 'jonas/ml-kem-fstar' into jonas/mlkem-c-extraction-hax
jschneider-bensch 577f31c
Remove duplicate `Operations` trait
jschneider-bensch 4494d88
Eurydice fixes
jschneider-bensch e843d6c
[ML-KEM] C Extraction
jschneider-bensch 67c3de8
Update CI workflows for C extraction
jschneider-bensch d3a116b
Fix path
jschneider-bensch 4c0c924
Remove `libcrux` submodule
jschneider-bensch b313f7f
WIP
jschneider-bensch 21e62b7
Add CI workflow for ML-DSA C extraction
jschneider-bensch 3cec894
Merge branch 'main' into jonas/mldsa-c-extraction-ci
jschneider-bensch 686e579
Add missing `core_num__u32__rotate_left` to glue
jschneider-bensch 0ad861e
Fix names in test
jschneider-bensch a22f22a
Fix names better
jschneider-bensch f3705ad
Fix one more name
jschneider-bensch 9ef0b3f
Temporarily disable other workflows
jschneider-bensch 25b5e6d
Missed places
jschneider-bensch 1e1638c
Add missing source files
jschneider-bensch 509de22
Update C extraction
jschneider-bensch 3d40211
Don't overwrite glue
jschneider-bensch 4274283
Replace buggy cloop
jschneider-bensch dfb034b
Update C extraction
jschneider-bensch 652fe7a
Remove function that causes MSVC error
jschneider-bensch f8138aa
Revert "Temporarily disable other workflows"
jschneider-bensch e174f1f
Remove unused import
jschneider-bensch ef9b31a
Merge branch 'main' into jonas/mldsa-c-extraction-ci
jschneider-bensch 16d98a4
WIP Update for ML-KEM extraction
jschneider-bensch 042dc4c
No unrolling
jschneider-bensch 51fc151
[ML-KEM/C code] Fix test code
jschneider-bensch f5a2e82
`cfg` out debug assertions for Eurydice
jschneider-bensch 3f81227
Fix buggy glue
jschneider-bensch acc0481
[C code/ML-KEM] Update C extraction
jschneider-bensch aa80212
Delete temp file
jschneider-bensch e1d9853
[C code/SHA3] Update config
jschneider-bensch e8b2e95
[C code/ SHA3] Update tests and glue
jschneider-bensch 0c7d13e
[C code/SHA3] Update C extraction
jschneider-bensch 56733d9
[C code/ML-DSA] Update extraction config
jschneider-bensch 5ab1940
[C Code/ML-DSA] Update glue & tests
jschneider-bensch 6adc442
[C code/ML-DSA] Update C extraction
jschneider-bensch b50ad18
Document `unrolling=0`
jschneider-bensch a5bd699
Remove commented code
jschneider-bensch 44dc8b4
Fix `cloop` for `step_by`
jschneider-bensch 27979e9
Add NIST KATs to ML-DSA C extraction tests
jschneider-bensch 816d9d0
Prune Eurydice glue
jschneider-bensch a016a47
More pruning
jschneider-bensch 56726ac
Fix ARM GNU toolchain action version
jschneider-bensch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| name: ML-DSA C - Extract, Build & Test | ||
|
|
||
| on: | ||
| merge_group: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main", "*"] | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| extract-c: | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: ghcr.io/cryspen/libcrux-c:latest | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Extract C | ||
| run: | | ||
| export HOME=/home/user | ||
| cd libcrux-iot | ||
| ../c/extract-mldsa.sh | ||
|
|
||
| - name: Upload C extraction | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: c-extraction-mldsa-iot | ||
| path: c/ml-dsa/extracted | ||
| include-hidden-files: true | ||
| if-no-files-found: error | ||
|
|
||
| build-c: | ||
| needs: [extract-c] | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - macos-latest | ||
| - ubuntu-latest | ||
| - windows-latest | ||
| runs-on: ${{ matrix.os }} | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| steps: | ||
| - uses: actions/download-artifact@v5 | ||
| with: | ||
| name: c-extraction-mldsa-iot | ||
|
|
||
| - name: Set CC and CXX to Clang on Ubuntu | ||
| if: matrix.os == 'ubuntu-latest' | ||
| run: | | ||
| echo "CC=clang" >> $GITHUB_ENV | ||
| echo "CXX=clang++" >> $GITHUB_ENV | ||
|
|
||
| - name: 🔨 Build | ||
| run: | | ||
| cmake -B build | ||
| cmake --build build | ||
|
|
||
| - name: 🏃🏻♀️ Test ML-DSA 65 | ||
| run: ./build/ml_dsa_test65 | ||
| if: ${{ matrix.os != 'windows-latest' }} | ||
|
|
||
|
|
||
| mldsa-build-test-status: | ||
| if: ${{ always() }} | ||
| needs: [build-c] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Successful | ||
| if: ${{ !(contains(needs.*.result, 'failure')) }} | ||
| run: exit 0 | ||
| - name: Failing | ||
| if: ${{ (contains(needs.*.result, 'failure')) }} | ||
| run: exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/sh | ||
|
|
||
| repo_root=$(git rev-parse --show-toplevel) | ||
|
|
||
| $repo_root/c/c.sh --extract ml-dsa --config $repo_root/c/mldsa.yml --no-glue --dep sha3 --libcrux-dep secrets --clean cfiles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # cmake -B build -G "Ninja Multi-Config" | ||
| # cmake --build build | ||
| # # For release (benchmarks) | ||
| # cmake --build build --config Release | ||
|
|
||
| cmake_minimum_required(VERSION 3.10..4.0) | ||
|
|
||
| project(libcrux-ml-dsa | ||
| VERSION 0.1.0 | ||
| LANGUAGES C CXX | ||
| ) | ||
|
|
||
| set(CMAKE_C_STANDARD 11) | ||
| set(CMAKE_CXX_STANDARD 20) | ||
|
|
||
| if(NOT MSVC) | ||
| # TODO: Clean up | ||
| add_compile_options( | ||
| -Wall | ||
|
|
||
| # -Wextra | ||
| # -pedantic | ||
| # -Wconversion | ||
| # -Wsign-conversion | ||
| $<$<CONFIG:DEBUG>:-g> | ||
| $<$<CONFIG:DEBUG>:-Og> | ||
| $<$<CONFIG:RELEASE>:-g> | ||
| $<$<CONFIG:RELEASE>:-O3> | ||
| ) | ||
| endif(NOT MSVC) | ||
|
|
||
| set(CMAKE_COLOR_DIAGNOSTICS "ON") | ||
|
|
||
| # For LSP-based editors | ||
| set(CMAKE_EXPORT_COMPILE_COMMANDS 1) | ||
| include_directories( | ||
| ${PROJECT_SOURCE_DIR} | ||
| ${PROJECT_SOURCE_DIR}/internal | ||
| ${PROJECT_SOURCE_DIR}/karamel/include | ||
| ) | ||
| file(GLOB SOURCES | ||
| ${PROJECT_SOURCE_DIR}/libcrux_iot_mldsa_core.c | ||
| ${PROJECT_SOURCE_DIR}/libcrux_iot_sha3.c | ||
| ${PROJECT_SOURCE_DIR}/libcrux_iot_mldsa65_portable.c | ||
| ) | ||
|
|
||
| if(${CMAKE_SYSTEM_NAME} MATCHES Linux) | ||
| add_compile_options( | ||
| -fPIC | ||
| ) | ||
| endif(${CMAKE_SYSTEM_NAME} MATCHES Linux) | ||
|
|
||
| # if(${CMAKE_SYSTEM_NAME} MATCHES Linux AND CMAKE_BUILD_TYPE MATCHES "Release") | ||
| # add_compile_options( | ||
| # -flto | ||
| # ) | ||
| # add_link_options(-flto) | ||
| # endif(${CMAKE_SYSTEM_NAME} MATCHES Linux AND CMAKE_BUILD_TYPE MATCHES "Release") | ||
|
|
||
| add_library(ml_dsa SHARED ${SOURCES}) | ||
| add_library(ml_dsa_static STATIC ${SOURCES}) | ||
|
|
||
| # --- Tests | ||
| if(DEFINED ENV{LIBCRUX_UNPACKED}) | ||
| add_compile_definitions(LIBCRUX_UNPACKED) | ||
| endif(DEFINED ENV{LIBCRUX_UNPACKED}) | ||
|
|
||
| # Get gtests | ||
| include(FetchContent) | ||
| FetchContent_Declare(googletest | ||
| GIT_REPOSITORY https://github.com/google/googletest.git | ||
| GIT_TAG v1.16.0 | ||
| ) | ||
|
|
||
| # For Windows: Prevent overriding the parent project's compiler/linker settings | ||
| set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
| FetchContent_MakeAvailable(googletest) | ||
|
|
||
| # Get nlohmann json | ||
| FetchContent_Declare(json | ||
| GIT_REPOSITORY https://github.com/nlohmann/json.git | ||
| GIT_TAG v3.11.3 | ||
| ) | ||
| FetchContent_MakeAvailable(json) | ||
|
|
||
| add_executable(ml_dsa_test65 | ||
| ${PROJECT_SOURCE_DIR}/tests/mldsa65.cc | ||
| ) | ||
| target_link_libraries(ml_dsa_test65 PRIVATE | ||
| ml_dsa_static | ||
| gtest_main | ||
| nlohmann_json::nlohmann_json | ||
| ) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| This code was generated with the following revisions: | ||
| Charon: 146b7dce58cb11ca8010b1c947c3437a959dcd88 | ||
| Eurydice: cdf02f9d8ed0d73f88c0a495c5b79359a51398fc | ||
| Karamel: 8e7262955105599e91f3a99c9ab3d3387f7046f2 | ||
| F*: unset | ||
| Libcrux: 0c7d13eb4d0117dce1ec2ef42fdb87d10cf78e2b |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.