├── .clang-format ├── .github └── workflows │ ├── arm.yml │ ├── osx-x86.yml │ └── test.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── README.md ├── bench └── CMakeLists.txt ├── decoding ├── __init__.py ├── matrix.py └── optimize.py ├── hallo.txt ├── shell.nix ├── src ├── bjmm.h ├── fq │ ├── prange.h │ ├── sieving.h │ ├── stern.h │ └── stern_v2.h ├── isd.h ├── mitm.h ├── prange.h ├── stern.h ├── stern_im.h └── stern_mo.h └── tests ├── CMakeLists.txt ├── decoding ├── CMakeLists.txt ├── challenges │ ├── 10.h │ ├── 100.h │ ├── 200.h │ ├── 300.h │ ├── 500.h │ ├── 510.h │ └── 520.h └── stern │ ├── 100.cpp │ ├── 200.cpp │ ├── 300.cpp │ └── CMakeLists.txt ├── fq ├── CMakeLists.txt ├── challenges │ ├── 50_20_4.h │ └── ternary │ │ ├── t10.h │ │ ├── t100transformed.h │ │ ├── t10transformed.h │ │ ├── t110transformed.h │ │ ├── t120transformed.h │ │ ├── t130transformed.h │ │ ├── t140transformed.h │ │ ├── t150transformed.h │ │ ├── t160transformed.h │ │ ├── t170transformed.h │ │ ├── t180transformed.h │ │ ├── t190transformed.h │ │ ├── t200transformed.h │ │ ├── t20transformed.h │ │ ├── t210transformed.h │ │ ├── t220transformed.h │ │ ├── t230transformed.h │ │ ├── t240transformed.h │ │ ├── t250transformed.h │ │ ├── t40transformed.h │ │ ├── t50transformed.h │ │ ├── t60transformed.h │ │ ├── t70transformed.h │ │ ├── t80transformed.h │ │ ├── t90transformed.h │ │ ├── wave100transformed.h │ │ ├── wave110transformed.h │ │ ├── wave120transformed.h │ │ ├── wave130transformed.h │ │ ├── wave140transformed.h │ │ ├── wave150transformed.h │ │ ├── wave160transformed.h │ │ ├── wave170transformed.h │ │ ├── wave180transformed.h │ │ ├── wave190transformed.h │ │ ├── wave200transformed.h │ │ ├── wave210transformed.h │ │ ├── wave220transformed.h │ │ ├── wave230transformed.h │ │ ├── wave240transformed.h │ │ ├── wave250transformed.h │ │ ├── wave40transformed.h │ │ ├── wave50transformed.h │ │ ├── wave60transformed.h │ │ ├── wave70transformed.h │ │ ├── wave80transformed.h │ │ └── wave90transformed.h ├── prange │ ├── 50.cpp │ └── CMakeLists.txt ├── sieving │ ├── 50.cpp │ └── CMakeLists.txt └── stern │ ├── 50.cpp │ └── CMakeLists.txt ├── isd.cpp ├── mceliece ├── CMakeLists.txt ├── bjmm │ ├── 1284.cpp │ ├── 240.cpp │ ├── 431.cpp │ ├── 640.cpp │ └── CMakeLists.txt ├── challenges │ ├── mce1041.h │ ├── mce1101.h │ ├── mce1161.h │ ├── mce1223.h │ ├── mce1284.h │ ├── mce1284b.h │ ├── mce1347.h │ ├── mce1347b.h │ ├── mce1347b_14.h │ ├── mce1347b_perm.h │ ├── mce1409.h │ ├── mce1473.h │ ├── mce1536.h │ ├── mce156.h │ ├── mce1600.h │ ├── mce1665.h │ ├── mce1730.h │ ├── mce1796.h │ ├── mce1995.h │ ├── mce240.h │ ├── mce286.h │ ├── mce3036.h │ ├── mce333.h │ ├── mce381.h │ ├── mce431.h │ ├── mce431_v2.h │ ├── mce482.h │ ├── mce534.h │ ├── mce640.h │ ├── mce695.h │ ├── mce751.h │ ├── mce808.h │ ├── mce865.h │ ├── mce923.h │ ├── mce982.h │ └── mce982_v2.h ├── prange │ ├── 240.cpp │ ├── 431.cpp │ └── CMakeLists.txt └── stern │ ├── 1284.cpp │ ├── 240.cpp │ ├── 431.cpp │ ├── 640.cpp │ └── CMakeLists.txt └── mitm.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | # Generated from CLion C/C++ Code Style settings 2 | BasedOnStyle: LLVM 3 | AccessModifierOffset: -4 4 | AlignAfterOpenBracket: Align 5 | AlignConsecutiveAssignments: None 6 | AlignOperands: Align 7 | AllowAllArgumentsOnNextLine: false 8 | AllowAllConstructorInitializersOnNextLine: false 9 | AllowAllParametersOfDeclarationOnNextLine: false 10 | AllowShortBlocksOnASingleLine: Always 11 | AllowShortCaseLabelsOnASingleLine: false 12 | AllowShortFunctionsOnASingleLine: All 13 | AllowShortIfStatementsOnASingleLine: Always 14 | AllowShortLambdasOnASingleLine: All 15 | AllowShortLoopsOnASingleLine: true 16 | AlwaysBreakAfterReturnType: None 17 | AlwaysBreakTemplateDeclarations: Yes 18 | BreakBeforeBraces: Custom 19 | BraceWrapping: 20 | AfterCaseLabel: false 21 | AfterClass: false 22 | AfterControlStatement: Never 23 | AfterEnum: false 24 | AfterFunction: false 25 | AfterNamespace: false 26 | AfterUnion: false 27 | BeforeCatch: false 28 | BeforeElse: false 29 | IndentBraces: false 30 | SplitEmptyFunction: false 31 | SplitEmptyRecord: true 32 | BreakBeforeBinaryOperators: None 33 | BreakBeforeTernaryOperators: true 34 | BreakConstructorInitializers: BeforeColon 35 | BreakInheritanceList: BeforeColon 36 | ColumnLimit: 0 37 | CompactNamespaces: false 38 | ContinuationIndentWidth: 8 39 | IndentCaseLabels: true 40 | IndentPPDirectives: None 41 | IndentWidth: 4 42 | KeepEmptyLinesAtTheStartOfBlocks: true 43 | MaxEmptyLinesToKeep: 2 44 | NamespaceIndentation: All 45 | ObjCSpaceAfterProperty: false 46 | ObjCSpaceBeforeProtocolList: true 47 | PointerAlignment: Right 48 | ReflowComments: false 49 | SpaceAfterCStyleCast: true 50 | SpaceAfterLogicalNot: false 51 | SpaceAfterTemplateKeyword: false 52 | SpaceBeforeAssignmentOperators: true 53 | SpaceBeforeCpp11BracedList: false 54 | SpaceBeforeCtorInitializerColon: true 55 | SpaceBeforeInheritanceColon: true 56 | SpaceBeforeParens: ControlStatements 57 | SpaceBeforeRangeBasedForLoopColon: false 58 | SpaceInEmptyParentheses: false 59 | SpacesBeforeTrailingComments: 0 60 | SpacesInAngles: false 61 | SpacesInCStyleCastParentheses: false 62 | SpacesInContainerLiterals: false 63 | SpacesInParentheses: false 64 | SpacesInSquareBrackets: false 65 | TabWidth: 4 66 | UseTab: ForIndentation 67 | -------------------------------------------------------------------------------- /.github/workflows/arm.yml: -------------------------------------------------------------------------------- 1 | name: arm 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | with: 11 | submodules: recursive 12 | 13 | - uses: pguyot/arm-runner-action@HEAD 14 | with: 15 | bind_mount_repository: true 16 | base_image: raspios_lite_arm64:latest 17 | cpu: cortex-a53 18 | image_additional_mb: 512 19 | commands: | 20 | sudo apt-get install -y cmake make git autoconf libtool libgmp-dev libgmp10 21 | git clone --depth=1 --single-branch --branch v1.7.1 https://github.com/google/benchmark.git benchmark && mkdir -p benchmark/build && cd ./benchmark/build && cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_GTEST_TESTS=OFF ../ && make -j 22 | sudo apt-get install -y libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/libgtest.a /usr/lib && sudo cp lib/libgtest_main.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a 23 | cd /decoding 24 | mkdir -p cmake-build-release 25 | mkdir -p cmake-build-debug 26 | cd cmake-build-debug 27 | cmake .. -DCMAKE_BUILD_TYPE=Debug 28 | make -j 29 | ctest -C Debug -V 30 | cd ../cmake-build-release 31 | cmake .. -DCMAKE_BUILD_TYPE=Release 32 | make -j 33 | ctest -C Debug -V 34 | -------------------------------------------------------------------------------- /.github/workflows/osx-x86.yml: -------------------------------------------------------------------------------- 1 | name: osx 2 | env: 3 | BUILD_TYPE: Release 4 | 5 | on: [push] 6 | 7 | jobs: 8 | build: 9 | strategy: 10 | matrix: 11 | include: 12 | - os: macos-latest 13 | TARGET: x86_64-apple-darwin 14 | COMPILER: clang 15 | LINKER: clang 16 | 17 | name: Build & test on ${{ matrix.os }} with ${{ matrix.compiler }}. 18 | runs-on: ${{ matrix.os }} 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | with: 23 | submodules: recursive 24 | 25 | - name: Install Software (HomeBrew) 26 | run: | 27 | sudo rm -f /usr/local/bin/2to3 28 | sudo rm -f /usr/local/bin/2to3-3.12 29 | sudo rm -f /usr/local/bin/idle3 30 | sudo rm -f /usr/local/bin/idle3.12 31 | sudo rm -f /usr/local/bin/python 32 | sudo rm -f /usr/local/bin/python3 33 | sudo rm -f /usr/local/bin/python3.12 34 | sudo rm -f /usr/local/bin/pydoc3 35 | sudo rm -f /usr/local/bin/pydoc3.12 36 | sudo rm -f /usr/local/bin/python3-config 37 | sudo rm -f /usr/local/bin/python3.12-config 38 | 39 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 40 | brew install libomp llvm googletest google-benchmark 41 | 42 | - name: Configure CMake 43 | run: cmake -B ${{github.workspace}}/build -D CMAKE_CXX_COMPILER=$(brew --prefix llvm)/bin/clang++ 44 | 45 | - name: Build 46 | run: cmake --build ${{github.workspace}}/build --config Debug 47 | 48 | - name: Test 49 | working-directory: ${{github.workspace}}/build 50 | run: ctest -C Debug -V 51 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | strategy: 8 | matrix: 9 | # ubuntu 20 doesnt support c++20 10 | #os: [ubuntu-22.04, ubuntu-20.04] 11 | os: [ubuntu-22.04] 12 | # TODO currently not working. The CI does not find omp? Probably need 13 | # to install the correct omp version for the correct compiler 14 | # compiler: [ g++-10, clang++-11, clang++-12, clang++-13, clang++-14, clang++-15] 15 | build_type: [Release, Debug] 16 | 17 | name: Build & test on ${{ matrix.os }} with ${{ matrix.compiler }} in ${{ matrix.build_type }} mode. 18 | runs-on: ${{ matrix.os }} 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | with: 23 | submodules: recursive 24 | 25 | - name: Install Software 26 | run: | 27 | sudo apt-get install -y libtbb-dev llvm-11 clang-11 llvm-12 clang-12 llvm-13 clang-13 llvm-14 clang-14 llvm-15 clang-15 gcc-10 28 | # libomp-11-dev libomp-12-dev libomp-13-dev libomp-14-dev libomp-15-dev libomp5-11 libomp5-12 libomp5-13 libomp5-14 libomp5-15 29 | 30 | - name: Install Google Benchmark 31 | run: git clone --depth=1 --single-branch --branch v1.7.1 https://github.com/google/benchmark.git benchmark && mkdir -p benchmark/build && cd ./benchmark/build && cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_GTEST_TESTS=OFF ../ && make -j 32 | 33 | - name: Install gtest 34 | run: 35 | sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/libgtest.a /usr/lib && sudo cp lib/libgtest_main.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a 36 | 37 | 38 | - name: Configure CMake 39 | # env: 40 | # CXX: ${{ matrix.compiler }} 41 | run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} 42 | 43 | - name: Build 44 | run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} 45 | 46 | - name: Test 47 | working-directory: ${{github.workspace}}/build 48 | run: ctest -C Debug -V 49 | 50 | 51 | # Benchmark: 52 | # runs-on: ubuntu-latest 53 | # 54 | # steps: 55 | # - uses: actions/checkout@v3 56 | # with: 57 | # submodules: recursive 58 | # 59 | # - name: Install Software 60 | # run: | 61 | # sudo apt-get install -y libmpfr-dev libpng-dev libtbb-dev 62 | # 63 | # - name: Configure CMake 64 | # run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} 65 | # 66 | # - name: Install Google Benchmark 67 | # run: git clone --depth=1 --single-branch --branch v1.7.1 https://github.com/google/benchmark.git benchmark && mkdir -p benchmark/build && cd ./benchmark/build && cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_GTEST_TESTS=OFF ../ && make -j 68 | # 69 | # - name: Install gtest 70 | # run: 71 | # sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/libgtest.a /usr/lib && sudo cp lib/libgtest_main.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a 72 | # 73 | # - name: Build 74 | # run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} 75 | # 76 | # - name: Bench 77 | # run: cd build && 78 | # ./bench/container/bench_b63_container_get_bits -j | tee benchmark_bench_b63_container_get_bits.json && 79 | # ./bench/container/bench_b63_container_kAryPackedContainer -j | tee benchmark_bench_b63_container_kAryPackedContainer.json && 80 | # 81 | # ./bench/label/bench_b63_label_add -j | tee benchmark_bench_b63_label_add.json && 82 | # ./bench/label/bench_b63_label_add_level -j | tee benchmark_bench_b63_label_add_level.json && 83 | # ./bench/label/bench_b63_label_equal_level -j | tee benchmark_bench_b63_label_equal_level.json && 84 | # ./bench/label/bench_b63_label_sub -j | tee benchmark_bench_b63_label_sub.json && 85 | # ./bench/label/bench_b63_label_sub_level -j | tee benchmark_bench_b63_label_sub_level.json && 86 | # 87 | # ./bench/labeltype/bench_b63_labeltype_add -j | tee benchmark_bench_b63_labeltype_add.json && 88 | # ./bench/labeltype/bench_b63_labeltype_sub -j | tee benchmark_bench_b63_labeltype_sub.json && 89 | # 90 | # ./bench/list/bench_b63_list_binarysearch -j | tee benchmark_bench_b63_list_binarysearchjson && 91 | # ./bench/list/bench_b63_list_search -j | tee benchmark_bench_b63_list_search.json && 92 | # ./bench/list/bench_b63_list_sort -j | tee benchmark_bench_b63_list_sort && 93 | # 94 | # ./bench/matrix/bench_b63_matrix/gaus -j | tee benchmark_bench_b63_matrix_gaus && 95 | # 96 | # ./bench/mem/bench_b63_mem_malloc_free -j | tee benchmark_bench_b63_mem_malloc_free.json && 97 | # 98 | # ./bench/nn/bench_b63_nn_avx2 -j | tee benchmark_bench_b63_nn_avx2.json && 99 | # ./bench/nn/bench_b63_nn_bruteforce -j | tee benchmark_bench_b63_nn_bruteforce.json && 100 | # ./bench/nn/bench_b63_nn_n128_avx2 -j | tee benchmark_bench_b63_nn_n128_avx2.json && 101 | # ./bench/nn/bench_b63_nn_opt -j | tee benchmark_bench_b63_nn_opt.json && 102 | # ./bench/nn/bench_b63_nn_popcount -j | tee benchmark_bench_b63_nn_popcount.json && 103 | # ./bench/nn/bench_b63_nn_sort_nn_on32 -j | tee benchmark_bench_b63_nn_sort_nn_on32.json && 104 | # ./bench/nn/bench_b63_nn_sort_nn_on64 -j | tee benchmark_bench_b63_nn_sort_nn_on64.json && 105 | # 106 | # ./bench/search/bench_b63_search_binarysearch -j | tee benchmark_bench_b63_search_binarysearch.json && 107 | # ./bench/search/bench_b63_search_internal_parallel_bucket_search -j | tee benchmark_bench_b63_search_internal_parallel_bucket_search.json && 108 | # 109 | # ./bench/sort/bench_b63_sort_binarycontainer_single_limb -j | tee benchmark_bench_b63_sort_binarycontainer_single_limb.json && 110 | # ./bench/sort/bench_b63_sort_internal_parallel_bucket_sort -j | tee benchmark_bench_b63_sort_internal_parallel_bucket_sort.json && 111 | # ./bench/sort/bench_b63_sort_sort -j | tee benchmark_bench_b63_sort_sort.json && 112 | # ./bench/sort/bench_stl_stl -j | tee benchmark_bench_stl_stl.json && 113 | # ./bench/value/bench_b63_value_absolute -j | tee benchmark_bench_b63_value_absolute.json && 114 | # ./bench/value/bench_b63_value_add -j | tee benchmark_bench_b63_value_add.json && 115 | # ./bench/value/bench_b63_value_move_operator -j | tee benchmark_bench_b63_value_move_operator.json 116 | 117 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .local-history/ 2 | __pycache__ 3 | *.log 4 | cache.txt 5 | deps/NTRU/ 6 | deps/NTRUEncrypt/ 7 | deps/coordinates.sage.py 8 | deps/decoding/ 9 | deps/elena_smallSecretLWE/ 10 | .clangd/ 11 | build/ 12 | compile_commands.json 13 | .vimspector.json 14 | main.h 15 | config.h 16 | 17 | # Created by .ignore support plugin (hsz.mobi) 18 | ### C++ template 19 | # Prerequisites 20 | *.d 21 | 22 | # Compiled Object files 23 | *.slo 24 | *.lo 25 | *.o 26 | *.obj 27 | 28 | # Precompiled Headers 29 | *.gch 30 | *.pch 31 | 32 | # Compiled Dynamic libraries 33 | *.so 34 | *.dylib 35 | *.dll 36 | 37 | # Fortran module files 38 | *.mod 39 | *.smod 40 | 41 | # Compiled Static libraries 42 | *.lai 43 | *.la 44 | *.a 45 | *.lib 46 | 47 | # Executables 48 | *.exe 49 | *.out 50 | *.app 51 | 52 | ### C template 53 | # Prerequisites 54 | *.d 55 | 56 | # Object files 57 | *.o 58 | *.ko 59 | *.obj 60 | *.elf 61 | 62 | # Linker output 63 | *.ilk 64 | *.map 65 | *.exp 66 | 67 | # Precompiled Headers 68 | *.gch 69 | *.pch 70 | 71 | # Libraries 72 | *.lib 73 | *.a 74 | *.la 75 | *.lo 76 | 77 | # Shared objects (inc. Windows DLLs) 78 | *.dll 79 | *.so 80 | *.so.* 81 | *.dylib 82 | 83 | # Executables 84 | *.exe 85 | *.out 86 | *.app 87 | *.i*86 88 | *.x86_64 89 | *.hex 90 | 91 | # Debug files 92 | *.dSYM/ 93 | *.su 94 | *.idb 95 | *.pdb 96 | 97 | # Kernel Module Compile Results 98 | *.mod* 99 | *.cmd 100 | .tmp_versions/ 101 | modules.order 102 | Module.symvers 103 | Mkfile.old 104 | dkms.conf 105 | 106 | ### Example user template template 107 | ### Example user template 108 | 109 | # cython files 110 | python/*.cpp 111 | python/*.so 112 | 113 | # IntelliJ project files 114 | .idea 115 | *.iml 116 | out 117 | gen 118 | cmake-build-debug/ 119 | cmake-build-release/ 120 | cmake-build-Release/ 121 | cmake-build-Debug/ 122 | cmake-build-debug-coverage/ 123 | cmake-build-release-coverage/ 124 | cmake-build-relwithdebinfo/ 125 | cmake-build-minsizerel/ 126 | build/ 127 | .cache/ 128 | 129 | ### CMake template 130 | CMakeLists.txt.user 131 | CMakeCache.txt 132 | CMakeFiles 133 | CMakeScripts 134 | Testing 135 | Makefile 136 | cmake_install.cmake 137 | install_manifest.txt 138 | compile_commands.json 139 | CTestTestfile.cmake 140 | _deps 141 | 142 | out.log 143 | *.log 144 | 145 | rust/target/ 146 | rust/Cargo.lock 147 | 148 | .ccls-cache/ 149 | .cache/ 150 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/cryptanalysislib"] 2 | path = deps/cryptanalysislib 3 | url = https://github.com/FloydZ/cryptanalysislib 4 | [submodule "src/rust/deps/m4ri-rust"] 5 | path = src/rust/deps/m4ri-rust 6 | url = https://github.com/thomwiggers/m4ri-rust 7 | -------------------------------------------------------------------------------- /bench/CMakeLists.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FloydZ/decoding/8fdacd9da8805f202d2b958da9b9ed592ce55d31/bench/CMakeLists.txt -------------------------------------------------------------------------------- /decoding/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = "Floyd Zweydinger" 2 | __copyright__ = "Copyright 2024" 3 | __credits__ = ["Floyd Zweydinger"] 4 | __license__ = "GPL2" 5 | __version_info__ = ('0', '0', '1') 6 | __version__ = '.'.join(__version_info__) 7 | __maintainer__ = "Floyd Zweydinger" 8 | __email__ = "zweydfg8+github@rub.de" 9 | __status__ = "Development" 10 | 11 | from .optimize import Decoding 12 | -------------------------------------------------------------------------------- /decoding/matrix.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ super simple matrix implementation. The only goal is to have zero dependencies """ 3 | 4 | from typing import Union 5 | import random 6 | 7 | 8 | 9 | class Matrix: 10 | """ simple matrix class """ 11 | def __init__(self, nrows: int, ncols: int, q: int = 2) -> None: 12 | """ zero initialized """ 13 | self.nrows = nrows 14 | self.ncols = ncols 15 | self.q = q 16 | self.data = [[0 for _ in range(ncols)] for _ in range(nrows)] 17 | 18 | def __getitem__(self, tup): 19 | """ nice access function """ 20 | x, y = tup 21 | assert x < self.nrows and y < self.ncols 22 | return self.data[x][y] 23 | 24 | def print(self, tranpose: bool = False): 25 | """ printing """ 26 | for i in range(self.nrows): 27 | for j in range(self.ncols): 28 | print(self.data[i][j], end='') 29 | 30 | print("") 31 | 32 | def zero(self) -> 'Matrix': 33 | """ zeros all elements""" 34 | for i in range(self.nrows): 35 | for j in range(self.ncols): 36 | self.data[i][j] = 0 37 | return self 38 | 39 | def random(self) -> 'Matrix': 40 | """ generates a random matrix """ 41 | for i in range(self.nrows): 42 | for j in range(self.ncols): 43 | self.data[i][j] = random.randint(0, self.q - 1) 44 | return self 45 | 46 | def random_row_with_weight(self, row: int, w: int) -> 'Matrix': 47 | """ generates a random weight w row """ 48 | assert w > 0 and w < self.ncols 49 | self.zero() 50 | for i in range(w): 51 | self.data[row][i] = 1 52 | 53 | # and now just simple apply a random permutation 54 | for i in range(self.ncols): 55 | pos = random.randint(0, self.ncols - i - 1) 56 | tmp = self.data[row][i] 57 | self.data[row][i] = self.data[row][i + pos] 58 | self.data[row][i + pos] = tmp 59 | return self 60 | 61 | def gauß(self, max_rank: Union[int, None] = None) -> int: 62 | """ simple Gaussian elimination. Is an inplace operation 63 | :return the rank of the matrix 64 | """ 65 | if max_rank is None: 66 | max_rank = self.nrows 67 | 68 | assert isinstance(max_rank, int) 69 | row = 0 70 | for col in range(self.ncols): 71 | if row >= min(max_rank, self.nrows): break 72 | 73 | # find pivot 74 | sel = -1 75 | for i in range(row, self.nrows): 76 | if self.data[i][col] == 1: 77 | sel = i 78 | break 79 | 80 | if sel == -1: 81 | return row 82 | 83 | self.__swap_rows(sel, row) 84 | 85 | # solve remaining coordinates 86 | for i in range(self.nrows): 87 | if i == row: continue 88 | if self.data[i][col] == 0: continue 89 | 90 | for j in range(self.ncols): 91 | self.data[i][j] += self.data[row][j] 92 | self.data[i][j] %= self.q 93 | 94 | row += 1 95 | 96 | return row 97 | 98 | def mul(self, B: 'Matrix') -> 'Matrix': 99 | """ simple multiplication """ 100 | B_r, B_c = B.nrows, B.ncols 101 | assert self.q == B.q and self.ncols == B_r 102 | C = Matrix(self.nrows, B_c, self.q) 103 | for i in range(B_c): # each column in B 104 | for j in range(self.nrows): # each row in A 105 | sum = 0 106 | for k in range(self.ncols): # each element in a row in A 107 | sum += self[j, k] * B[k, i] 108 | 109 | C.data[j][i] = sum % self.q 110 | return C 111 | 112 | def add(self, B: 'Matrix') -> 'Matrix': 113 | """ simple inplace additions """ 114 | B_r, B_c = B.nrows, B.ncols 115 | assert self.q == B.q and self.ncols == B_c and self.nrows == B_r 116 | for i in range(self.nrows): 117 | for j in range(self.ncols): 118 | self.data[i][j] += B[i, j] 119 | self.data[i][j] %= self.q 120 | return self 121 | 122 | def transpose(self) -> 'Matrix': 123 | """ simple transpose """ 124 | T = Matrix(self.ncols, self.nrows, q=self.q) 125 | 126 | for i in range(self.nrows): 127 | for j in range(self.ncols): 128 | T.data[j][i] = self.data[i][j] 129 | return T 130 | 131 | def popcnt_row(self, row: int) -> int: 132 | """ computes the hamming weight of a row""" 133 | assert row < self.nrows 134 | return sum(self.data[row]) 135 | 136 | def popcnt_col(self, col: int) -> int: 137 | """ computes the hamming weight of a column""" 138 | assert col < self.ncols 139 | t = 0 140 | for j in range(self.nrows): 141 | t += self.data[j][col] 142 | return t 143 | 144 | def __swap_rows(self, i: int, j: int) -> None: 145 | """ swap the rows i and j """ 146 | assert i < self.nrows and j < self.nrows 147 | if i == j: return 148 | for k in range(self.ncols): 149 | tmp = self.data[i][k] 150 | self.data[i][k] = self.data[j][k] 151 | self.data[j][k] = tmp 152 | 153 | def __swap_cols(self, i: int, j: int) -> None: 154 | """ swap the cols i and j """ 155 | assert i < self.ncols and j < self.ncols 156 | if i == j: return 157 | for k in range(self.nrows): 158 | tmp = self.data[k][i] 159 | self.data[k][i] = self.data[k][j] 160 | self.data[k][j] = tmp 161 | 162 | 163 | if __name__ == "__main__": 164 | nc, nr, q, w = 10, 5, 2, 2 165 | A = Matrix(nr, nc, q) 166 | A.print() 167 | print() 168 | 169 | A.random() 170 | A.print() 171 | print() 172 | 173 | rank = A.gauß() 174 | A.print() 175 | print("rank", rank) 176 | 177 | e = Matrix(1, nc, q) 178 | e.random_row_with_weight(0, w) 179 | e.print() 180 | print() 181 | 182 | eT = e.transpose() 183 | eT.print() 184 | print() 185 | 186 | C = A.mul(eT) 187 | C.print() 188 | 189 | -------------------------------------------------------------------------------- /hallo.txt: -------------------------------------------------------------------------------- 1 | hihi 2 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | with import {}; 2 | let 3 | mach-nix = import (builtins.fetchGit { 4 | url = "https://github.com/DavHau/mach-nix"; 5 | ref = "refs/tags/3.5.0"; 6 | }) {}; 7 | pyEnv = mach-nix.mkPython rec { 8 | providers._default = "wheel,conda,nixpkgs,sdist"; 9 | requirements = builtins.readFile ./requirements.txt; 10 | }; 11 | in 12 | { pkgs ? import {} }: 13 | 14 | stdenv.mkDerivation { 15 | name = "decoding"; 16 | src = ./.; 17 | 18 | buildInputs = [ 19 | pyenv 20 | gtest 21 | gbenchmark 22 | git 23 | cmake 24 | clang_17 25 | clang-tools_17 26 | llvmPackages_17.openmp 27 | llvm_17 28 | gcc 29 | ]++ (lib.optionals pkgs.stdenv.isLinux ([ 30 | flamegraph 31 | gdb 32 | linuxKernel.packages.linux_6_6.perf 33 | pprof 34 | valgrind 35 | massif-visualizer 36 | #TODO cudatoolkit 37 | ])); 38 | } 39 | -------------------------------------------------------------------------------- /src/fq/prange.h: -------------------------------------------------------------------------------- 1 | #ifndef DECODING_FQ_PRANGE_H 2 | #define DECODING_FQ_PRANGE_H 3 | 4 | #include "combination/chase.h" 5 | #include "helper.h" 6 | #include "container/fq_vector.h" 7 | #include "matrix/matrix.h" 8 | #include "list/list.h" 9 | #include "list/enumeration/fq.h" 10 | #include "thread/thread.h" 11 | #include "isd.h" 12 | 13 | 14 | /// 15 | /// \tparam config 16 | template 17 | class FqPrange : public ISDInstance { 18 | constexpr static uint32_t n = config.n; 19 | constexpr static uint32_t k = config.k; 20 | constexpr static uint32_t w = config.w; 21 | constexpr static uint32_t q = config.q; 22 | constexpr static uint32_t p = config.p; 23 | 24 | static_assert(config.l == 0); 25 | 26 | public: 27 | using ISD = ISDInstance; 28 | using Error = ISD::Error; 29 | using Label = ISD::Label; 30 | using Value = ISD::Value; 31 | using Element = ISD::Element; 32 | using limb_type = ISD::limb_type; 33 | using ISD::A,ISD::H,ISD::wA,ISD::wAT,ISD::HT,ISD::s,ISD::ws,ISD::e,ISD::syndrome,ISD::P,ISD::not_found,ISD::loops,ISD::ghz; 34 | using ISD::cycles, ISD::gaus_cycles, ISD::periodic_print; 35 | 36 | /// needed list stuff 37 | using List = List_T; 38 | using Generator = ListEnumerateMultiFullLength; 39 | Generator G; 40 | 41 | FqPrange() noexcept : G(HT, 0) {} 42 | 43 | /// rebuild the final solution 44 | void rebuild_solution() { 45 | Error tmpe; 46 | tmpe.zero(); 47 | e.zero(); 48 | 49 | /// NOTE: the `element1` the code below is referencing is part of the 50 | /// `Enumeration class'. Its the field which is actually enumerated by the class. 51 | /// And we need access to it, to know the label, value tuple. 52 | if constexpr (p == 0) { 53 | for (uint32_t i = 0; i < n-k; ++i) { 54 | const auto data = ws.get(i); 55 | tmpe.set(data, 0, n-k-1-i); 56 | } 57 | } else { 58 | // ASSERT(G.element1.label.popcnt() == (w-p)); 59 | ASSERT(G.element1.value.popcnt() == p); 60 | 61 | G.element1.label.print(); 62 | G.element1.value.print(); 63 | 64 | Label tmp; 65 | Label::sub(tmp, ws, G.element1.label); 66 | ws.print(); 67 | tmp.print(); 68 | ASSERT(tmp.popcnt() == (w-p)); 69 | /// set e1 (get the label) 70 | for (uint32_t i = 0; i < n-k; ++i) { 71 | const auto data = tmp.get(i); 72 | tmpe.set(data, 0, n-k-1-i); 73 | } 74 | 75 | /// set e2 (get the value) 76 | for (uint32_t i = 0; i < k; ++i) { 77 | const auto data = G.element1.value.get(i); 78 | tmpe.set(data, 0, i+n-k); 79 | } 80 | } 81 | 82 | // apply back permutation 83 | for (uint32_t i = 0; i < n; ++i) { 84 | const auto data = tmpe.get(0, i); 85 | e.set(data, 0, P.values[i]); 86 | } 87 | } 88 | 89 | /// \return needed loops 90 | uint64_t __attribute__ ((noinline)) 91 | run() noexcept { 92 | ISD::reset(); 93 | 94 | while (not_found && (loops < config.loops)) { 95 | 96 | /// check if prange or Lee-Brickell 97 | if constexpr (p == 0) { 98 | ISD::template step(); 99 | const uint32_t weight = ws.popcnt(); 100 | ASSERT(weight <= n-k); 101 | ASSERT(weight > 0); 102 | if (unlikely(weight <= w)) { 103 | not_found = false; 104 | break; 105 | } 106 | } else { 107 | // TODO can be optimizes. Currently we need to swap because the syndrome is swapped to. 108 | ISD::template step(); 109 | auto predicate = [&, this](const Label &in){ 110 | Label tmp; 111 | Label::sub(tmp, ws, in); 112 | return tmp.popcnt() <= (w - p); 113 | }; 114 | 115 | const uint32_t tid = Thread::get_tid(); 116 | 117 | /// start the iterations 118 | bool found = G.template run 119 | 120 | (nullptr, nullptr, 0, 0, tid, nullptr, nullptr, &predicate); 121 | 122 | if (unlikely(found)) { 123 | not_found = false; 124 | break; 125 | } 126 | 127 | } 128 | } 129 | 130 | rebuild_solution(); 131 | return loops; 132 | } 133 | }; 134 | 135 | #endif//DECODING_FQ_PRANGE_H 136 | -------------------------------------------------------------------------------- /src/fq/stern.h: -------------------------------------------------------------------------------- 1 | #ifndef DECODING_FQ_STERN_H 2 | #define DECODING_FQ_STERN_H 3 | 4 | #include "helper.h" 5 | #include "container/fq_vector.h" 6 | #include "matrix/matrix.h" 7 | #include "list/list.h" 8 | #include "sort.h" 9 | #include "popcount/popcount.h" 10 | #include "mitm.h" 11 | #include "isd.h" 12 | #include "../stern.h" 13 | 14 | using namespace cryptanalysislib; 15 | 16 | 17 | template 18 | class FqStern : public ISDInstance { 19 | private: 20 | constexpr static uint32_t n = isd.n; 21 | constexpr static uint32_t k = isd.k; 22 | constexpr static uint32_t w = isd.w; 23 | constexpr static uint32_t q = isd.q; 24 | constexpr static uint32_t qbits = bits_log2(q); 25 | 26 | constexpr static uint32_t l = isd.l; 27 | constexpr static uint32_t p = isd.p; 28 | 29 | constexpr static uint32_t threads = config.threads; 30 | public: 31 | using ISD = ISDInstance; 32 | using Error = ISD::Error; 33 | using Label = ISD::Label; 34 | using Value = ISD::Value; 35 | using Element = ISD::Element; 36 | using limb_type = ISD::limb_type; 37 | using ISD::A,ISD::H,ISD::wA,ISD::wAT,ISD::HT,ISD::s,ISD::ws,ISD::e,ISD::syndrome,ISD::P,ISD::not_found,ISD::loops,ISD::ghz; 38 | using ISD::cycles, ISD::gaus_cycles, ISD::periodic_print, ISD::HashMasp_BucketSize; 39 | 40 | constexpr static uint32_t HM_nrb = ISD::HashMasp_BucketSize(l); 41 | constexpr static uint32_t HM_bs = config.HM_bucketsize; 42 | 43 | constexpr static bool packed = ISD::packed; 44 | 45 | /// minimal datatype to keep all l fq elements 46 | using l_type = MinLogTypeTemplate; 47 | using IndexType = TypeTemplate; 48 | 49 | /// needed list stuff 50 | constexpr static uint32_t enum_length = (k + l) >> 1u; 51 | constexpr static uint32_t enum_offset = k + l - enum_length; 52 | constexpr static size_t list_size = compute_combinations_fq_chase_list_size(); 53 | // using List = Parallel_List_FullElement_T; 54 | using List = List_T; 55 | using Generator = ListEnumerateMultiFullLength; 56 | Generator G; 57 | List *L1, *L2; 58 | 59 | /// compress in the case of non packed data containers 60 | /// e.g. removes all the zeros from the containers 61 | constexpr inline static __uint128_t Compress(const Label &label) noexcept { 62 | /// some security measurements: 63 | if constexpr (qbits*l > 128) { 64 | ASSERT(false && "not implemented"); 65 | } 66 | 67 | /// easy case 68 | if constexpr (packed) { 69 | constexpr __uint128_t mask = qbits*l == 128 ? __uint128_t(-1ull) : (__uint128_t(1ull) << (qbits*l)) - __uint128_t(1ull); 70 | using TT = LogTypeTemplate; 71 | 72 | /// NOTE: that we fetch the first 128bits (and not the last, where we would assume 73 | /// normally the l bit window), as we assume we swapped all rows within the parity 74 | /// check matrix. Therefor the last `l` bit of every syndrome are now the first. 75 | const TT a = *((TT *)label.ptr()); 76 | const __uint128_t aa = a; 77 | return aa&mask; 78 | } 79 | 80 | // important to init with zero here. 81 | __uint128_t ret = 0; 82 | 83 | #pragma unroll 84 | for (uint32_t i = 0u; i < l; ++i) { 85 | ret ^= (label.get(i) << (qbits*i)); 86 | } 87 | 88 | return ret; 89 | } 90 | 91 | /// this extractor is needed, to be able to search on the second 92 | /// list for elements, which are equal zero summed together 93 | /// \return the negative of label[lower, q*l*nr_window) shifted to zero 94 | constexpr inline static __uint128_t NegateCompress(const Label &label) noexcept { 95 | Label tmp = label; 96 | tmp.neg(); 97 | return Compress(tmp); 98 | } 99 | 100 | 101 | using valueType = TypeTemplate[1]; 102 | // using value_type = CollisionType; 103 | constexpr static SimpleHashMapConfig simpleHashMapConfig{ 104 | HM_bs, HM_nrb, config.threads 105 | }; 106 | using HM = SimpleHashMap>; 107 | HM *hm; 108 | using HM_LoadType = HM::load_type; 109 | 110 | Value value_solution_to_recover; 111 | Label label_solution_to_recover; 112 | 113 | /// base constructor 114 | FqStern() noexcept : G(HT, 0, nullptr) { 115 | /// init lists 116 | L1 = new List(list_size, threads); 117 | L2 = new List(list_size, threads); 118 | ASSERT((L1 != nullptr) && (L2 != nullptr)); 119 | 120 | ///// init hashmap 121 | hm = new HM; 122 | ASSERT(hm != nullptr); 123 | } 124 | 125 | /// free all the memory 126 | ~FqStern() { 127 | delete L1; 128 | delete L2; 129 | delete hm; 130 | } 131 | 132 | /// 133 | inline void init_list(const uint32_t tid) noexcept { 134 | hm->clear(); 135 | 136 | /// this call simply inits the the list 137 | G.template run 138 | (L1, L2, enum_offset, 0, tid, hm, &Compress); 139 | } 140 | 141 | void find_collisions(const uint32_t tid) { 142 | const size_t start = L2->start_pos(tid); 143 | const size_t end = L2->end_pos(tid); 144 | 145 | Label tmp; 146 | for (size_t i = start; i < end; ++i) { 147 | l_type data = NegateCompress(L2->at(i).label); 148 | data = Label::template add_T(data, syndrome); 149 | 150 | /// search in HM 151 | HM_LoadType load; 152 | IndexType pos = hm->find(data, load); 153 | for (uint64_t j = pos; j < pos + load; j++) { 154 | const IndexType index = hm->ptr(j)[0]; 155 | 156 | /// TODO not really nice 157 | Label::add(tmp, L1->at(index).label, L2->at(i).label); 158 | Label::sub(tmp, ws, tmp); 159 | 160 | // std::cout << std::endl; 161 | // L2->at(i).label.print(); 162 | // L1->at(index).label.print(); 163 | // tmp.print(); 164 | // ws.print(); 165 | // std::cout << i << " " << index << std::endl; 166 | 167 | /// some debug checks 168 | for (uint32_t s = 0; s < l; ++s) { 169 | ASSERT(tmp.get(s) == 0); 170 | } 171 | 172 | /// if this checks passes we found a solution 173 | if (unlikely(tmp.popcnt() <= (w - 2*p))) { 174 | not_found = false; 175 | label_solution_to_recover = tmp; 176 | Value::add(value_solution_to_recover, L2->at(i).value, L1->at(index).value); 177 | goto finished; 178 | } 179 | } 180 | } 181 | 182 | /// forward jumps = best jumps 183 | finished: 184 | return; 185 | } 186 | 187 | /// 188 | void rebuild_solution() { 189 | Error tmpe; 190 | tmpe.zero(); 191 | e.zero(); 192 | 193 | for (uint32_t i = 0; i < l; ++i) { 194 | ASSERT(label_solution_to_recover.get(i) == 0); 195 | } 196 | ASSERT(label_solution_to_recover.popcnt() <= (w-2*p)); 197 | ASSERT(value_solution_to_recover.popcnt() == 2*p); 198 | 199 | for (uint32_t i = 0; i < n-k-l; ++i) { 200 | tmpe.set(label_solution_to_recover.get(l + i), 0, (n-k-l) - i - 1); 201 | } 202 | 203 | for (uint32_t i = 0; i < k+l; ++i) { 204 | tmpe.set(value_solution_to_recover.get(i), 0, (n-k-l)+i); 205 | } 206 | 207 | ASSERT(tmpe.get(0).popcnt() <= w); 208 | 209 | // apply back permutation 210 | for (uint32_t i = 0; i < n; ++i) { 211 | const auto data = tmpe.get(0, i); 212 | e.set(data, 0, P.values[i]); 213 | } 214 | } 215 | 216 | 217 | /// \return 218 | uint64_t __attribute__ ((noinline)) 219 | run() noexcept { 220 | ISD::reset(); 221 | 222 | while (not_found && (loops < config.loops)) { 223 | ISD::step(); 224 | 225 | // #pragma omp parallel default(none) shared(std::cout,L1,not_found,loops) num_threads(threads) 226 | { 227 | const uint32_t tid = 0; //Thread::get_tid(); 228 | init_list(tid); 229 | Thread::sync(); 230 | find_collisions(tid); 231 | } 232 | } 233 | 234 | rebuild_solution(); 235 | return loops; 236 | } 237 | }; 238 | #endif//DECODING_FQ_STERN_H 239 | -------------------------------------------------------------------------------- /src/fq/stern_v2.h: -------------------------------------------------------------------------------- 1 | #ifndef DECODING_FQ_STERNV2_H 2 | #define DECODING_FQ_STERNV2_H 3 | 4 | #include "helper.h" 5 | #include "container/fq_vector.h" 6 | #include "matrix/matrix.h" 7 | #include "list/list.h" 8 | #include "popcount/popcount.h" 9 | #include "mitm.h" 10 | #include "isd.h" 11 | #include "../stern.h" 12 | 13 | using namespace cryptanalysislib; 14 | 15 | 16 | template 17 | class FqSternV2 : public ISDInstance { 18 | private: 19 | constexpr static uint32_t n = isd.n; 20 | constexpr static uint32_t k = isd.k; 21 | constexpr static uint32_t w = isd.w; 22 | constexpr static uint32_t q = isd.q; 23 | constexpr static uint32_t qbits = bits_log2(q); 24 | 25 | constexpr static uint32_t l = isd.l; 26 | constexpr static uint32_t p = isd.p; 27 | 28 | constexpr static uint32_t threads = config.threads; 29 | constexpr static size_t final_list_size = 1024; 30 | 31 | public: 32 | using ISD = ISDInstance; 33 | using Error = ISD::Error; 34 | using Label = ISD::Label; 35 | using Value = ISD::Value; 36 | using Element = ISD::Element; 37 | using limb_type = ISD::limb_type; 38 | using PCSubMatrix_T = ISD::PCSubMatrix_T; 39 | using ISD::A,ISD::H,ISD::wA,ISD::wAT,ISD::HT,ISD::s,ISD::ws,ISD::e,ISD::syndrome,ISD::P,ISD::not_found,ISD::loops,ISD::ghz; 40 | using ISD::cycles, ISD::gaus_cycles, ISD::periodic_print, ISD::HashMasp_BucketSize; 41 | 42 | constexpr static uint32_t HM_nrb = ISD::HashMasp_BucketSize(l); 43 | constexpr static uint32_t HM_bs = config.HM_bucketsize; 44 | 45 | constexpr static bool packed = ISD::packed; 46 | 47 | /// minimal datatype to keep all l fq elements 48 | using l_type = MinLogTypeTemplate; 49 | using IndexType = TypeTemplate; 50 | 51 | l_type *lHT; 52 | 53 | constexpr static uint32_t NR_HT_LIMBS = (n-k+sizeof(limb_type)*8 - 1u)/((sizeof(limb_type)*8)); 54 | constexpr static uint32_t NR_HT_T_LIMBS = (n-k+(sizeof(l_type)*8) - 1u)/(sizeof(l_type)*8); 55 | 56 | /// needed list stuff 57 | constexpr static uint32_t enum_length = (k + l + isd.epsilon) >> 1u; 58 | constexpr static uint32_t enum_offset = k + l - enum_length; 59 | constexpr static size_t enum_size = compute_combinations_fq_chase_list_size(); 60 | 61 | using V1 = CollisionType; 62 | constexpr static SimpleHashMapConfig simpleHashMapConfig{ 63 | HM_bs, HM_nrb, config.threads 64 | }; 65 | using HM = SimpleHashMap>; 66 | HM *hm; 67 | using HM_LoadType = HM::load_type; 68 | using HM_DataType_IndexType = V1::index_type; 69 | using HM_DataType = V1; 70 | 71 | 72 | /// changelist stuff 73 | chase<(config.k+config.l)/2 + config.epsilon, config.p, config.q> c{}; 74 | using cle = std::pair; 75 | std::vector cL; 76 | 77 | /// 78 | size_t cfls = 0; 79 | alignas(256) std::array final_list_left; 80 | alignas(256) std::array final_list_right; 81 | 82 | /// list entries of the current permutation if a solution was found. 83 | size_t solutions[2*p] = {0}; 84 | 85 | Value value_solution_to_recover; 86 | Label label_solution_to_recover; 87 | 88 | /// base constructor 89 | FqSternV2() noexcept { 90 | constexpr size_t size_lHT = roundToAligned<1024>(sizeof(l_type) * (k+l)); 91 | lHT =(l_type *)cryptanalysislib::aligned_alloc(1024, size_lHT); 92 | ASSERT(lHT); 93 | 94 | hm = new HM{}; 95 | ASSERT(hm); 96 | hm->print(); 97 | 98 | 99 | cL.resize(enum_size); 100 | size_t ctr = 0; 101 | c.enumerate([&, this](const uint16_t p1, const uint16_t p2){ 102 | cL[ctr] = cle{p1, p2}; 103 | ctr += 1; 104 | }); 105 | ASSERT(ctr == (enum_size - 1)); 106 | } 107 | 108 | /// free all the memory 109 | ~FqSternV2() { 110 | delete hm; 111 | } 112 | 113 | bool compute_finale_list() noexcept { 114 | alignas(32) uint16_t left[p], right[p]; 115 | for (size_t m = 0; m < cfls; ++m) { 116 | biject(final_list_left[m], left); 117 | biject(final_list_right[m], right); 118 | 119 | /// TODO the following things are wrong: 120 | /// - biject is not correct, we need to match the +q-1 offset 121 | /// - missing lpart = 0 checks 122 | auto climb = ws.ptr(0); 123 | for (uint16_t j = 0; j < p; j++) { 124 | const auto tmp = Label::add_T(HT.limb(left[j], 0), HT.limb(right[j], 0)); 125 | climb = Label::add_T(climb, tmp); 126 | } 127 | 128 | uint32_t wt = Label::popcnt_T(climb); 129 | if (likely(wt > (w - (2*p)))) { 130 | continue; 131 | } 132 | 133 | 134 | for (uint32_t i = 1; i < NR_HT_LIMBS; i++) { 135 | climb = ws.ptr(i); 136 | for (uint16_t j = 0; j < p; j++) { 137 | const auto tmp = Label::add_T(HT.limb(left[j], i), HT.limb(right[j], i)); 138 | climb = Label::add_T(climb, tmp); 139 | } 140 | 141 | wt += cryptanalysislib::popcount::popcount(climb); 142 | } 143 | 144 | if ((wt <= w - (2*p)) && not_found) { 145 | not_found = false; 146 | cycles = cpucycles() - cycles; 147 | for (uint16_t j = 0; j < p; ++j) { 148 | solutions[j*p + 0] = left[j]; 149 | solutions[j*p + 1] = right[j]; 150 | } 151 | 152 | cfls = 0; 153 | return true; 154 | } 155 | } 156 | 157 | cfls = 0; 158 | return false; 159 | } 160 | 161 | /// 162 | inline void init_list(const uint32_t tid) { 163 | hm->clear(); 164 | 165 | l_type tmp = 0; 166 | for (uint32_t i = 0; i < p; ++i) { 167 | tmp = Label::template add_T(tmp, lHT[i]); 168 | } 169 | 170 | for (size_t i = 0; i < enum_size; ++i) { 171 | const uint16_t ci = cL[i].second; 172 | for (uint32_t j = 0; j < (q - 1); ++j) { 173 | hm->insert(tmp, HM_DataType::create(tmp, (HM_DataType_IndexType *)&i)); 174 | tmp = Label::template add_T(tmp, lHT[ci]); 175 | } 176 | 177 | tmp = Label::template add_T(tmp, lHT[cL[i].first]); 178 | tmp = Label::template add_T(tmp, lHT[cL[i].second]); 179 | } 180 | } 181 | 182 | void find_collisions(const uint32_t tid) { 183 | l_type tmp = syndrome; 184 | for (uint32_t i = 0; i < p; ++i) { 185 | tmp = Label::template add_T(tmp, lHT[i]); 186 | } 187 | 188 | for (size_t i = 0; i < enum_size; ++i) { 189 | const uint16_t ci = cL[i].second; 190 | for (uint32_t m = 0; m < (q - 1); ++m) { 191 | HM_LoadType load; 192 | IndexType pos = hm->find(tmp, load); 193 | for (uint64_t j = pos; j < pos + load; j++) { 194 | const IndexType index = hm->ptr(j).index[0]; 195 | 196 | final_list_left[cfls] = index; 197 | final_list_right[cfls] = i; 198 | cfls += 1; 199 | 200 | if (cfls >= final_list_size) { 201 | compute_finale_list(); 202 | } 203 | } 204 | 205 | // next element 206 | tmp = Label::template add_T(tmp, lHT[ci]); 207 | } 208 | 209 | // next element in the chase sequence 210 | tmp = Label::template add_T(tmp, lHT[cL[i].first]); 211 | tmp = Label::template add_T(tmp, lHT[cL[i].second]); 212 | } 213 | } 214 | 215 | /// 216 | void rebuild_solution() { 217 | Error tmpe; 218 | tmpe.zero(); 219 | e.zero(); 220 | 221 | for (uint32_t i = 0; i < l; ++i) { 222 | ASSERT(label_solution_to_recover.get(i) == 0); 223 | } 224 | ASSERT(label_solution_to_recover.popcnt() <= (w-2*p)); 225 | ASSERT(value_solution_to_recover.popcnt() == 2*p); 226 | 227 | for (uint32_t i = 0; i < n-k-l; ++i) { 228 | tmpe.set(label_solution_to_recover.get(l + i), 0, (n-k-l) - i - 1); 229 | } 230 | 231 | tmpe.print(); 232 | for (uint32_t i = 0; i < k+l; ++i) { 233 | tmpe.set(value_solution_to_recover.get(i), 0, (n-k-l)+i); 234 | } 235 | 236 | ASSERT(tmpe.get(0).popcnt() <= w); 237 | 238 | // apply back permutation 239 | for (uint32_t i = 0; i < n; ++i) { 240 | const auto data = tmpe.get(0, i); 241 | e.set(data, 0, P.values[i]); 242 | } 243 | } 244 | 245 | 246 | /// \return 247 | uint64_t __attribute__ ((noinline)) 248 | run() noexcept { 249 | ISD::reset(); 250 | 251 | while (not_found && (loops < config.loops)) { 252 | ISD::step(); 253 | ISD::template extract_lHT(lHT); 254 | 255 | // #pragma omp parallel default(none) shared(std::cout,L1,not_found,loops) num_threads(threads) 256 | { 257 | const uint32_t tid = 0; //Thread::get_tid(); 258 | init_list(tid); 259 | 260 | Thread::sync(); 261 | find_collisions(tid); 262 | compute_finale_list(); 263 | } 264 | } 265 | 266 | rebuild_solution(); 267 | return loops; 268 | } 269 | }; 270 | #endif//DECODING_FQ_STERN_H 271 | -------------------------------------------------------------------------------- /src/prange.h: -------------------------------------------------------------------------------- 1 | #ifndef DECODING_STERN_H 2 | #define DECODING_STERN_H 3 | 4 | #include 5 | 6 | #include "matrix/matrix.h" 7 | #include "container/hashmap.h" 8 | #include "popcount/popcount.h" 9 | #include "math/bc.h" 10 | #include "alloc/alloc.h" 11 | #include "hash/simple.h" 12 | #include "mitm.h" 13 | 14 | #include "isd.h" 15 | 16 | using namespace cryptanalysislib; 17 | 18 | template 19 | class Prange : public ISDInstance { 20 | public: 21 | constexpr static uint32_t n = isd.n; 22 | constexpr static uint32_t k = isd.k; 23 | constexpr static uint32_t w = isd.w; 24 | constexpr static uint32_t p = isd.p; // NOTE: from now on p is the baselist p not the full p. 25 | constexpr static uint32_t l = isd.l; 26 | constexpr static uint32_t q = isd.q; 27 | 28 | static_assert(l == 0); 29 | static_assert(p == 0); 30 | 31 | using ISD = ISDInstance; 32 | using Label = ISD::Label; 33 | using limb_type = ISD::limb_type; 34 | using ISD::A,ISD::H,ISD::wA,ISD::wAT,ISD::HT,ISD::s,ISD::ws,ISD::e,ISD::syndrome,ISD::P,ISD::not_found,ISD::loops,ISD::ghz; 35 | using ISD::cycles, ISD::gaus_cycles, ISD::periodic_print; 36 | 37 | constexpr static bool packed = true; 38 | 39 | // base datatype of the hashmap 40 | using l_type = MinLogTypeTemplate; 41 | 42 | constexpr static uint32_t NR_HT_T_LIMBS = (n-k+(sizeof(l_type)*8) - 1u)/(sizeof(l_type)*8); 43 | 44 | /// internal arrays pointing to 45 | l_type *pHT; 46 | 47 | 48 | Prange() noexcept { 49 | constexpr size_t size_pHT = roundToAligned<1024>(sizeof(l_type) * (k+l) * NR_HT_T_LIMBS); 50 | pHT =(l_type *)cryptanalysislib::aligned_alloc(1024, size_pHT); 51 | ASSERT(pHT); 52 | } 53 | 54 | ~Prange() noexcept { 55 | free(pHT); 56 | } 57 | 58 | /// reconstruct the final solution 59 | void __attribute__ ((noinline)) 60 | reconstruct() noexcept { 61 | e.zero(); 62 | // apply back permutation. 63 | for (uint32_t i = 0; i < n-k; ++i) { 64 | e.set(wA.get(i, n), 0, P.values[i]); 65 | } 66 | } 67 | 68 | // runs: optimized stern 69 | uint64_t __attribute__ ((noinline)) 70 | run() noexcept { 71 | ISD::reset(); 72 | 73 | while (not_found && loops < isd.loops) { 74 | ISD::template step(); 75 | 76 | if (ws.popcnt() <= w) { 77 | ISD::extract_pHT(pHT); 78 | 79 | not_found = false; 80 | break; 81 | } 82 | } 83 | 84 | // compute the final solution 85 | reconstruct(); 86 | return loops; 87 | } 88 | 89 | /// important. Dont rename it 90 | void info() const noexcept {} 91 | }; 92 | #endif//DECODING_STERN_H 93 | -------------------------------------------------------------------------------- /src/stern_im.h: -------------------------------------------------------------------------------- 1 | #ifndef DECODING_STERN_IM_H 2 | #define DECODING_STERN_IM_H 3 | #include 4 | 5 | #include "mitm.h" 6 | #include "isd.h" 7 | #include "stern.h" 8 | 9 | using namespace cryptanalysislib; 10 | 11 | 12 | struct ConfigSternIM : public ConfigISD { 13 | public: 14 | const uint32_t nr_views = 1; 15 | 16 | [[nodiscard]] consteval uint64_t compute_loops() const noexcept { 17 | #ifdef EXPECTED_PERMUTATIONS 18 | return EXPECTED_PERMUTATIONS; 19 | #else 20 | return 1; // TODO 21 | #endif 22 | } 23 | 24 | void print() const noexcept { 25 | ConfigISD::print(); 26 | std::cout << "{ \"nr_views\": " << nr_views 27 | << " }" << std::endl; 28 | } 29 | }; 30 | 31 | 32 | template 33 | class SternIM : public Stern { 34 | public: 35 | using ISD = ISDInstance; 36 | using STERN = Stern; 37 | using limb_type = ISD::limb_type; 38 | using ISD::syndrome,ISD::P,ISD::not_found,ISD::loops,ISD::expected_loops,ISD::ghz,ISD::cycles,ISD::gaus_cycles,ISD::periodic_print; 39 | 40 | using l_type = STERN::l_type; 41 | using STERN::reconstruct,STERN::compute_finale_list,STERN::compute_finale_list_simd; 42 | using STERN::simd,STERN::lHT,STERN::pHT,STERN::bEnum,STERN::cEnum,STERN::final_list_current_size,STERN::final_list_left,STERN::final_list_right, STERN::final_list_max_size; 43 | constexpr static uint32_t nr_views = config.nr_views; 44 | 45 | static_assert(nr_views > 0); 46 | static_assert(nr_views*isd.l < (isd.n - isd.k)); 47 | 48 | SternIM() noexcept : Stern() { 49 | expected_loops = config.compute_loops(); 50 | } 51 | 52 | // runs: optimized stern 53 | uint64_t __attribute__ ((noinline)) 54 | run() noexcept { 55 | ISD::reset(); 56 | 57 | // collision function 58 | auto f = [&, this](const l_type a1, const l_type a2, 59 | uint16_t *index1, uint16_t *index2, 60 | const uint32_t nr_cols) __attribute__((always_inline)) -> bool { 61 | (void)nr_cols; 62 | (void)a1; 63 | (void)a2; 64 | // const l_type a = a1 ^ a2; 65 | ASSERT(bEnum->check_hashmap2(syndrome, index1, 2u*config.p, isd.l)); 66 | 67 | for (uint32_t i = 0; i < config.p; i++) { 68 | final_list_left[final_list_current_size][i] = index1[i]; 69 | final_list_right[final_list_current_size][i] = index2[i]; 70 | } 71 | final_list_current_size += 1; 72 | 73 | if (final_list_current_size >= final_list_max_size) { 74 | compute_finale_list(); 75 | } 76 | return false; 77 | }; 78 | 79 | while (not_found && loops < isd.loops) { 80 | const uint32_t tid = 0; 81 | const bool simd = false; 82 | ISD::step(); 83 | ISD::extract_pHT(pHT); 84 | 85 | constexpr_for<0, nr_views, 1>([&, this, f](const auto i){ 86 | constexpr auto offset = i*isd.l; 87 | ISD::template extract_lHT(lHT); 88 | ISD::template extract_syndrome_limb(); 89 | 90 | bEnum->step(0, tid, simd); 91 | cEnum->step(syndrome, f, tid, simd); 92 | compute_finale_list(); 93 | }); 94 | } 95 | 96 | reconstruct(); 97 | return loops; 98 | } 99 | }; 100 | #endif//DECODING_STERN_IM_H 101 | -------------------------------------------------------------------------------- /src/stern_mo.h: -------------------------------------------------------------------------------- 1 | #ifndef DECODING_STERNMO 2 | #define DECODING_STERNMO 3 | 4 | #include 5 | #include 6 | 7 | #include "isd.h" 8 | #include "stern.h" 9 | 10 | struct ConfigSternMO : public ConfigISD { 11 | public: 12 | /// Well, ... currently this forces the windowsize `k` = 64. 13 | const uint32_t r = 3;//(n-k + 63) / 64; 14 | const uint32_t N = 50; // 15 | const uint32_t dk = 12;// (w-2*p) + 6; 16 | const uint32_t nnk = 32; 17 | 18 | // debug mode. in case needed, we can enforce bruteforce 19 | const bool enforce_bf = false; 20 | [[nodiscard]] consteval uint64_t compute_loops() const noexcept { 21 | #ifdef EXPECTED_PERMUTATIONS 22 | return EXPECTED_PERMUTATIONS; 23 | #else 24 | return 1; // TODO 25 | #endif 26 | } 27 | 28 | void print() const noexcept { 29 | ConfigISD::print(); 30 | std::cout << "{ " 31 | << ", \"r\": " << r 32 | << ", \"N\": " << N 33 | << ", \"dk\": " << dk 34 | << ", \"nnk\": " << nnk 35 | << " }" << std::endl; 36 | } 37 | }; 38 | 39 | template 40 | class SternMO : public ISDInstance{ 41 | public: 42 | constexpr static uint32_t n = isd.n; 43 | constexpr static uint32_t k = isd.k; 44 | constexpr static uint32_t w = isd.w; 45 | constexpr static uint32_t p = isd.p; 46 | constexpr static uint32_t l = isd.l; 47 | 48 | constexpr static uint32_t r = config.r; 49 | 50 | using ISD = ISDInstance; 51 | using PCSubMatrix_T = ISD::PCSubMatrix_T; 52 | using Error = ISD::Error; 53 | using Label = ISD::Label; 54 | using limb_type = ISD::limb_type; 55 | using ISD::A,ISD::H,ISD::wA,ISD::wAT,ISD::HT,ISD::s,ISD::ws,ISD::e,ISD::syndrome,ISD::P,ISD::not_found,ISD::loops,ISD::ghz,ISD::expected_loops; 56 | using ISD::cycles, ISD::gaus_cycles, ISD::periodic_print, ISD::packed, ISD::simd; 57 | 58 | // if set to 59 | constexpr static uint32_t kl_half = k/2; 60 | constexpr static uint32_t NR_HT_LIMBS = PCSubMatrix_T::limbs(); 61 | 62 | // list shit, todo rename to baselist 63 | constexpr static size_t list_enumeration_length = kl_half; 64 | constexpr static size_t list_enumeration_weigth = p; 65 | constexpr static size_t list_enumeration_size = 66 | bc(list_enumeration_length, list_enumeration_weigth); 67 | constexpr static size_t size_MO_L = roundToAligned<1024>(list_enumeration_size*sizeof(Label)); 68 | Label *stern_MO_L1 = nullptr, *stern_MO_L2 = nullptr; 69 | 70 | 71 | constexpr static NN_Config nn_config{ 72 | n-k, config.r, config.N, config.nnk, 73 | list_enumeration_size, config.dk, w-(2*p), 0, 1024}; 74 | NN algo {}; 75 | using NNElement = typename NN::Element; 76 | 77 | size_t solutions[2*p] = {0}; 78 | 79 | constexpr SternMO() noexcept { 80 | nn_config.print(); 81 | expected_loops = config.compute_loops(); 82 | 83 | stern_MO_L1 = (Label *)cryptanalysislib::aligned_alloc(1024, size_MO_L); 84 | stern_MO_L2 = (Label *)cryptanalysislib::aligned_alloc(1024, size_MO_L); 85 | 86 | algo.L1 = (NNElement *)stern_MO_L1; 87 | algo.L2 = (NNElement *)stern_MO_L2; 88 | } 89 | 90 | /// reconstruct the solution 91 | void __attribute__ ((noinline)) 92 | reconstruct() { 93 | // we need to translate the indices from the NN to stern list indices. 94 | const size_t soll = solutions[0]; 95 | const size_t solr = solutions[1]; 96 | uint16_t rows[p]; 97 | Label tmpl, tmpr; 98 | bool foundl = false, foundr = false; 99 | 100 | for (size_t i = 0; i < list_enumeration_size; i++) { 101 | biject(i, rows); 102 | bool correctl = true; 103 | bool correctr = true; 104 | 105 | tmpl.zero(); tmpr = ws; 106 | 107 | for (uint16_t j = 0; j < p; j++) { 108 | ASSERT(rows[j] < kl_half); 109 | Label::add(tmpl.ptr(), tmpl.ptr(), HT[rows[j]]); 110 | Label::add(tmpr.ptr(), tmpr.ptr(), HT[rows[j] + list_enumeration_length]); 111 | } 112 | 113 | if (!tmpl.is_equal(((Label*)algo.L1)[soll])) { 114 | correctl = false; 115 | } 116 | if (!tmpr.is_equal(((Label*)algo.L2)[solr])) { 117 | correctr = false; 118 | } 119 | 120 | if (correctl) { 121 | ASSERT(!foundl); 122 | foundl = true; 123 | for (uint32_t j = 0; j < p; j++) { 124 | solutions[j] = rows[j]; 125 | } 126 | } 127 | 128 | if (correctr) { 129 | ASSERT(!foundr); 130 | foundr = true; 131 | for (uint32_t j = 0; j < p; j++) { 132 | solutions[p + j] = rows[j] + list_enumeration_length; 133 | } 134 | } 135 | } 136 | 137 | ASSERT(foundl); 138 | ASSERT(foundr); 139 | 140 | Error tmpe, tmpe2; 141 | Label tmp; tmp.zero(); 142 | // copy in the syndrome 143 | tmp = ws; 144 | for (uint32_t i = 0; i < 2*p; ++i) { 145 | ASSERT(solutions[i] < k+l); 146 | Label::add(tmp.ptr(), tmp.ptr(), HT.row(solutions[i])); 147 | } 148 | 149 | tmp.print(); 150 | 151 | // reversing and shit 152 | for (uint32_t i = 0; i < n-k; ++i) { 153 | const auto bit = tmp.get(i); 154 | tmpe.set(bit, 0, n-k-1-i); 155 | } 156 | 157 | tmpe.print(); 158 | for (uint32_t i = 0; i < 2*p; ++i) { 159 | ASSERT(n-k-l + solutions[i] < n); 160 | tmpe.set(1, 0, n-k-l + solutions[i]); 161 | } 162 | 163 | // apply back permutation. 164 | for (uint32_t i = 0; i < n; ++i) { 165 | e.set(tmpe.get(0, i), 0, P.values[i]); 166 | } 167 | } 168 | 169 | 170 | /// 171 | constexpr void construct_nearest_neighbour_lists() noexcept { 172 | alignas(32) Label tmpl, tmpr; 173 | alignas(32) uint16_t rows[p]; 174 | 175 | for (size_t i = 0; i < list_enumeration_size; i++) { 176 | biject(i, rows); 177 | tmpl.zero(); tmpr = ws; 178 | 179 | #pragma unroll 180 | for (uint16_t j = 0; j < p; j++) { 181 | ASSERT(rows[j] < kl_half); 182 | Label::add(tmpl.ptr(), tmpl.ptr(), HT[rows[j]]); 183 | Label::add(tmpr.ptr(), tmpr.ptr(), HT[rows[j] + list_enumeration_length]); 184 | } 185 | 186 | stern_MO_L1[i] = tmpl; 187 | stern_MO_L2[i] = tmpr; 188 | } 189 | } 190 | 191 | /// generates the two lists L1 and L2 from HT 192 | constexpr void apply_nearest_neighbour() noexcept { 193 | if constexpr (config.enforce_bf) { 194 | algo.bruteforce(list_enumeration_size, list_enumeration_size); 195 | } else { 196 | algo.nn(list_enumeration_size, list_enumeration_size); 197 | } 198 | if (algo.solutions_nr > 0) { 199 | solutions[0] = algo.solutions[0].first; 200 | solutions[1] = algo.solutions[0].second; 201 | 202 | not_found = false; 203 | } 204 | } 205 | 206 | /// runs the May-Ozerov Stern versions 207 | uint64_t __attribute__ ((noinline)) 208 | run() noexcept { 209 | ISD::reset(); 210 | 211 | while (not_found && loops < isd.loops) { 212 | ISD::step(); 213 | construct_nearest_neighbour_lists(); 214 | apply_nearest_neighbour(); 215 | } 216 | 217 | reconstruct(); 218 | return loops; 219 | } 220 | 221 | /// important. Dont rename it 222 | constexpr void info() const noexcept { 223 | std::cout << "{" 224 | << " \"size_MO_L\": " << size_MO_L 225 | << " }" << std::endl; 226 | } 227 | }; 228 | #endif 229 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 2 | foreach(testfile ${TEST_SOURCES}) 3 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 4 | string(REPLACE ".cpp" "" file ${filename}) 5 | add_executable(${file} ${testfile}) 6 | target_link_libraries(${file} ${LINK_TEST_FLAGS}) 7 | add_test(AllTests ${file}) 8 | endforeach(testfile ${TEST_SOURCES}) 9 | 10 | if(USE_CUDA) 11 | add_executable(cuda_list list.cu) 12 | target_compile_options(cuda_list PUBLIC ${COMPILE_TEST_FLAGS}) 13 | target_link_libraries(cuda_list ${LINK_TEST_FLAGS}) 14 | add_test(AllTests cuda_list) 15 | endif() 16 | 17 | 18 | # TODO add_subdirectory(decoding) 19 | add_subdirectory(mceliece) 20 | # TODO not implemented add_subdirectory(quasicyclic) 21 | # TODO add_subdirectory(lowweight) 22 | # TODO currently not implemented add_subdirectory(ternary) 23 | add_subdirectory(fq) 24 | -------------------------------------------------------------------------------- /tests/decoding/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(stern) -------------------------------------------------------------------------------- /tests/decoding/challenges/10.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 10; 5 | constexpr uint64_t k = 5; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 4; 8 | constexpr const char *s = "01110"; 9 | constexpr const char *h = "11011111100100101001101111000001000001000001000001"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/decoding/challenges/100.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 100; 5 | constexpr uint64_t k = 50; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 14; 8 | constexpr const char *s = "11111010000001101101101011011010101101110001011011"; 9 | constexpr const char *h = "11011111100100101001101110111000101101000001001101101011011010000110000001100111110101100010010110000000000101000000100010100011100100101110000011010011111100101010011110111000100011101100101011001111010000111000000001100110011010100100001110111100110001111010010011101010010011111001111010110110010000001001111010101010100010011100000011100101111110001110010111000000010110011100010111100001110111111000011001101001101110010000101011001101011000111011000110000110011001001001110111010010110001000000011000010111000111111000101000100011100010001110111001101101110111000100110110011011010101100101011010110010011110111000011100001110001111110000111011110111101101000111000101000110010011110111010100011111100100100001000101111011111011000010100010101010011111000100100111111100100111011110000001010110001001111010111110000010010100110101000110111000110010000010000110100111100011101010111000101101101010010100000010011001101101110111001100000100000001010011100101101010111110111010110111001011011100101001000111111110000101011001100000111110111110100011101001001100010101010001011111110101010111101101101100011000010101101100110000100101000101111101000010010101010010001111110010000100101100101011111100110101000100101111001100011010010011000000101100011001001110100010000100000010111001010011011011010110111010101100010111011001110101101100101110110111010001001110010000000011110110110110111111100000001010000111011110000001011100101010110101011111001010100111011001010000000110111000011100111001101100101111001110111111101101010011001111011101001110100101010001000010000010010000111010101011110010010001010100101101101110101011101011010111001111000100010101101100101010101010011000000100111100111111100000110100100110001110010011100001011011011101000110111100100001001110111001001011010101000100100001011011001101001110001001011011001101011000101110001011101111011000110001000101100111111001000010010001000001010010110110000000111111100000001010100111110010111110111111110010100111111001100001000011000010111101000011010100101000100011100101111110100111101000011011101000000111010010001001011101000001111010000100001010100101111100111111000110000010011111111001110001011000010101111100110010111001011110110111001011010100100110010010111011100000101111110001011111100000100000101001100000011101000100011010100000100101001110100111110110010001011000111101110001110101001010000001100001000001111011000100000110111110011000100110100110100111100101001100110000110011010010000111100001000000000101111000101000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000001"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/decoding/stern/100.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../challenges/100.h" 5 | #include "stern.h" 6 | #include "stern_im.h" 7 | #include "stern_mo.h" 8 | 9 | using ::testing::EmptyTestEventListener; 10 | using ::testing::InitGoogleTest; 11 | using ::testing::Test; 12 | using ::testing::TestEventListeners; 13 | using ::testing::TestInfo; 14 | using ::testing::TestPartResult; 15 | using ::testing::UnitTest; 16 | 17 | 18 | TEST(Stern, t100) { 19 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=8,.c=0,.threads=1}; 20 | static constexpr ConfigStern config{isdConfig, .HM_bucketsize=16, }; 21 | 22 | Stern stern{}; 23 | stern.from_string(h, s); 24 | stern.run(); 25 | EXPECT_EQ(stern.correct(), true); 26 | } 27 | 28 | TEST(SternIM, t100) { 29 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=8,.c=0,.threads=1}; 30 | static constexpr ConfigStern configStern{isdConfig, .HM_bucketsize=16}; 31 | static constexpr ConfigSternIM config{isdConfig, .nr_views=2}; 32 | 33 | SternIM stern{}; 34 | stern.from_string(h, s); 35 | stern.run(); 36 | EXPECT_EQ(stern.correct(), true); 37 | } 38 | 39 | TEST(SternMO, t100) { 40 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=1,.l=10,.c=0,.threads=1}; 41 | static constexpr ConfigSternMO config{isdConfig, .nr_views=2}; 42 | 43 | SternMO stern{}; 44 | stern.from_string(h, s); 45 | stern.run(); 46 | EXPECT_EQ(stern.correct(), true); 47 | } 48 | 49 | int main(int argc, char **argv) { 50 | InitGoogleTest(&argc, argv); 51 | srand(time(NULL)); 52 | random_seed(rand()); 53 | return RUN_ALL_TESTS(); 54 | } -------------------------------------------------------------------------------- /tests/decoding/stern/200.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../challenges/200.h" 5 | #include "stern.h" 6 | #include "stern_im.h" 7 | #include "stern_mo.h" 8 | 9 | 10 | using ::testing::EmptyTestEventListener; 11 | using ::testing::InitGoogleTest; 12 | using ::testing::Test; 13 | using ::testing::TestEventListeners; 14 | using ::testing::TestInfo; 15 | using ::testing::TestPartResult; 16 | using ::testing::UnitTest; 17 | 18 | 19 | TEST(Stern, t200t1p2) { 20 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=13,.c=0,.threads=1}; 21 | static constexpr ConfigStern config{isdConfig, .HM_bucketsize=16}; 22 | 23 | Stern stern{}; 24 | stern.from_string(h, s); 25 | stern.run(); 26 | EXPECT_EQ(stern.correct(), true); 27 | } 28 | 29 | TEST(SternIM, t200t1p2) { 30 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=13,.c=0,.threads=1}; 31 | static constexpr ConfigStern configStern{isdConfig, .HM_bucketsize=16}; 32 | static constexpr ConfigSternIM config{isdConfig, .nr_views=2}; 33 | 34 | SternIM stern{}; 35 | stern.from_string(h, s); 36 | stern.run(); 37 | EXPECT_EQ(stern.correct(), true); 38 | } 39 | 40 | TEST(SternMO, t200t1p2) { 41 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=10,.c=0,.threads=1}; 42 | static constexpr ConfigSternMO config{isdConfig, .nr_views=2}; 43 | 44 | SternMO stern{}; 45 | stern.from_string(h, s); 46 | stern.run(); 47 | EXPECT_EQ(stern.correct(), true); 48 | } 49 | 50 | 51 | int main(int argc, char **argv) { 52 | InitGoogleTest(&argc, argv); 53 | ident(); 54 | srand(time(NULL)); 55 | random_seed(rand()); 56 | return RUN_ALL_TESTS(); 57 | } -------------------------------------------------------------------------------- /tests/decoding/stern/300.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../challenges/300.h" 6 | #include "stern.h" 7 | #include "stern_im.h" 8 | #include "stern_mo.h" 9 | 10 | 11 | using ::testing::EmptyTestEventListener; 12 | using ::testing::InitGoogleTest; 13 | using ::testing::Test; 14 | using ::testing::TestEventListeners; 15 | using ::testing::TestInfo; 16 | using ::testing::TestPartResult; 17 | using ::testing::UnitTest; 18 | 19 | 20 | TEST(Stern, t300t1p2) { 21 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=17,.c=0,.threads=1}; 22 | static constexpr ConfigStern config{isdConfig, .HM_bucketsize=16}; 23 | 24 | Stern stern{}; 25 | stern.from_string(h, s); 26 | stern.run(); 27 | EXPECT_EQ(stern.correct(), true); 28 | } 29 | 30 | TEST(SternIM, t300t1p2) { 31 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=17,.c=0,.threads=1}; 32 | static constexpr ConfigStern configStern{isdConfig, .HM_bucketsize=16}; 33 | static constexpr ConfigSternIM config{isdConfig, .nr_views=2}; 34 | 35 | SternIM stern{}; 36 | stern.from_string(h, s); 37 | stern.run(); 38 | EXPECT_EQ(stern.correct(), true); 39 | } 40 | 41 | TEST(SternMO, t300t1p2) { 42 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=17,.c=0,.threads=1}; 43 | static constexpr ConfigSternMO config{isdConfig, .nr_views=2}; 44 | 45 | SternMO stern{}; 46 | stern.from_string(h, s); 47 | stern.run(); 48 | EXPECT_EQ(stern.correct(), true); 49 | } 50 | 51 | 52 | int main(int argc, char **argv) { 53 | InitGoogleTest(&argc, argv); 54 | ident(); 55 | srand(time(NULL)); 56 | random_seed(rand()); 57 | return RUN_ALL_TESTS(); 58 | } -------------------------------------------------------------------------------- /tests/decoding/stern/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 2 | 3 | foreach(testfile ${TEST_SOURCES}) 4 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 5 | string(REPLACE ".cpp" "" file ${filename}) 6 | add_executable(sd_test_stern_${file} ${testfile}) 7 | target_compile_options(sd_test_stern_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 8 | target_link_libraries(sd_test_stern_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 9 | endforeach(testfile ${TEST_SOURCES}) 10 | 11 | if(USE_SCLANG) 12 | use_sclang_compiler() 13 | foreach(testfile ${TEST_SOURCES}) 14 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 15 | string(REPLACE ".cpp" "" file ${filename}) 16 | add_executable(sclang_sd_stern_${file} ${testfile}) 17 | target_compile_options(sclang_sd_stern_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 18 | target_link_libraries(sclang_sd_stern_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 19 | endforeach(testfile ${TEST_SOURCES}) 20 | use_host_compiler() 21 | endif() 22 | 23 | -------------------------------------------------------------------------------- /tests/fq/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(prange) 2 | add_subdirectory(sieving) 3 | add_subdirectory(stern) 4 | -------------------------------------------------------------------------------- /tests/fq/challenges/50_20_4.h: -------------------------------------------------------------------------------- 1 | #ifndef DECODING_FILE_H 2 | #define DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 50; 5 | constexpr uint64_t k = 20; 6 | constexpr uint64_t w = 10; 7 | constexpr uint64_t q = 4; 8 | constexpr const char *s = "322232133222133300010111001300"; 9 | constexpr const char *kekw_solution = "13000000000300300003000000000002010000110000030000"; 10 | constexpr const char *h = "100000000000000000000000000000122321232313131123320100000000000000000000000000001213213331233121113300100000000000000000000000000012112122121232211113000100000000000000000000000000122213123222333332130000100000000000000000000000001213133211323321222300000100000000000000000000000011222323231331311221000000100000000000000000000000221123221123221133110000000100000000000000000000001322333121112131322100000000100000000000000000000013111233112233111312000000000100000000000000000000332321221323132333320000000000100000000000000000001121132131123111123100000000000100000000000000000023222113122322122131000000000000100000000000000000211113132231221332310000000000000100000000000000003113213221331222313100000000000000100000000000000032113111332321232323000000000000000100000000000000331332233321311232130000000000000000100000000000003321113132121332112100000000000000000100000000000012331122233221322233000000000000000000100000000000322313331221133111120000000000000000000100000000001332211122131332231300000000000000000000100000000023132221213211321221000000000000000000000100000000223131333123232211120000000000000000000000100000001222112132333232113200000000000000000000000100000022323223121313113222000000000000000000000000100000122333332122113113110000000000000000000000000100003112221323232232232100000000000000000000000000100032133312121312333222000000000000000000000000000100213211213313113132210000000000000000000000000000101221223122131233212100000000000000000000000000000121321313323222323132"; 11 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 12 | #endif //SECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t10.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 10; 5 | constexpr uint64_t k = 3; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 9; 8 | constexpr const char *s = "2010202"; 9 | constexpr const char *h = "1000000010000000100000001000000010000000100000001110121111120201002122"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t100transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 100; 5 | constexpr uint64_t k = 36; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 99; 8 | constexpr const char *s = "1000011011121001200212120121112021201101211201210020022201112120"; 9 | constexpr const char *h = "1000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001110121111120201002122201020211201112202112102002122202110212002000210012101212021202221102112010000221100200002221221200221211122210120122100021020101100020022222000202201010020002010202021201000211100210202101121202200200121021200121221211210220120120210011212122202112120020210002112221012212200101201212200111101022020012110002022200022011200112001101022221001000021211202222122121120012100011112012001002111201012001022011111002111101021101122002212000020010012211122201010120101002021200111020020001112002102122121211122022001221102012012122100200000101100211212202022202101221112200202012211011111100200121001101220220110211100100022021022210110022122120222101122020011101120001102222000222212100121001001020112101121010012011000102000022202011202000101121000111112210200221010001200011120020102001121202112100121220110121101110001022202110110011201122010102121001021220121021021120012001122211021112020001121020001112022202012212111122000201121022112121011221120110210200111020202221010020122120021001121101122101202100011111120010220100200102220021202211110222222212111210110000101200012021201012020112111020010021001222112111120012001121011110000001012012100010011110212202112212211000220021001220222100121022102222210200212101211200022112200100200012200200112202102022111100220212121201021201110001220112222011201012202201012000000210012100110110212211011222221020110020222220010000022202012022120220112210201011201021021111101212102221201120111001201222212022111002102222210012020201112111121000201010212212200211020022020222211111012112221102100202221110212200120202122102202010102102212200010121111121010101011122212021120221101120002110002022101011021120201120000122220220222221012002010112211210120022022010021201202120120202100012121112120010020012001202110220101011221212110011010100010012220112221100211022001101002210011022000022021012210002110010011120120020212000012000022002101122120012021001221011011010211201121202210102112020021012110212100111021201102112200102211120121021112010002100121102222012220000000201122121201101221220122210111121110200022222022202222012220100001211021122121002202002021220122110201012010221102101201212211100210120100112120110010100202022000122212201211020001110011210012102110010212111200112102212111112101101010201100211121220212110122001110102010102"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t10transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 10; 5 | constexpr uint64_t k = 3; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 9; 8 | constexpr const char *s = "1020101"; 9 | constexpr const char *h = "1000000010000000100000001000000010000000100000001110121111120201002122"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t110transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 110; 5 | constexpr uint64_t k = 40; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 108; 8 | constexpr const char *s = "0011012022021000002101212120100111220011010020120021222100211210001011"; 9 | constexpr const char *h = "10000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000011101211111202010021222010202112011122021121020021222021102120020002100121012120212022211021120100002211002000022212212002212111222101201221000210201011000200222220002022010100200020102020212010002111002102021011212022002001210212001212212112102201201202100112121222021121200202100021122210122122001012012122001111010220200121100020222000220112001120011010222210010000212112022221221211200121000111120120010021112010120010220111110021111010211011220022120000200100122111222010101201010020212001110200200011120021021221212111220220012211020120121221002000001011002112122020222021012211122002020122110111111002001210011012202201102111001000220210222101100221221202221011220200111011200011022220002222121001210010010201121011210100120110001020000222020112020001011210001111122102002210100012000111200201020011212021121001212201101211011100010222021101100112011220101021210010212201210210211200120011222110211120200011210200011120222020122121111220002011210221121210112211201102102001110202022210100201221200210011211011221012021000111111200102201002001022200212022111102222222121112101100001012000120212010120201121110200100210012221121111200120011210111100000010120121000100111102122021122122110002200210012202221001210221022222102002121012112000221122001002000122002001122021020221111002202121212010212011100012201122220112010122022010120000002100121001101102122110112222210201100202222200100000222020120221202201122102010112010210211111012121022212011201110012012222120221110021022222100120202011121111210002010102122122002110200220202222111110121122211021002022211102122001202021221022020101021022122000101211111210101010111222120211202211011200021100020221010110211202011200001222202202222210120020101122112101200220220100212012021201202021000121211121200100200120012021102201010112212121100110101000100122201122211002110220011010022100110220000220210122100021100100111201200202120000120000220021011221200120210012210110110102112011212022101021120200210121102121001110212011021122001022111201210211120100021001211022220122200000002011221212011012212201222101111211102000222220222022220122201000012110211221210022020020212201221102010120102211021012012122111002101201001121201100101002020220001222122012110200011100112100121021100102121112001121022121111121011010102011002111212202121101220011101020101021000210000120002200210022102000111010102102121121202201020102022010221012202021021101210111022101011101202110101110011121202200122200010120112011001012202102222210222122021001212200000012202202122121120012121112110000011220120010012212020202211122002210012110200202210110211011221021000122210211112001220000210021110111220222012200102110102210120202010201022002201022211012120011012200211210020100210221101221002110102122100021021122102022012011120112112011020021100010001012102011111120022100001"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t120transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 120; 5 | constexpr uint64_t k = 44; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 118; 8 | constexpr const char *s = "1202012100201110012111002020200110221020212112102012021121121020020021000211"; 9 | constexpr const char *h = "100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000111012111112020100212220102021120111220211210200212220211021200200021001210121202120222110211201000022110020000222122120022121112221012012210002102010110002002222200020220101002000201020202120100021110021020210112120220020012102120012122121121022012012021001121212220211212002021000211222101221220010120121220011110102202001211000202220002201120011200110102222100100002121120222212212112001210001111201200100211120101200102201111100211110102110112200221200002001001221112220101012010100202120011102002000111200210212212121112202200122110201201212210020000010110021121220202220210122111220020201221101111110020012100110122022011021110010002202102221011002212212022210112202001110112000110222200022221210012100100102011210112101001201100010200002220201120200010112100011111221020022101000120001112002010200112120211210012122011012110111000102220211011001120112201010212100102122012102102112001200112221102111202000112102000111202220201221211112200020112102211212101122112011021020011102020222101002012212002100112110112210120210001111112001022010020010222002120221111022222221211121011000010120001202120101202011211102001002100122211211112001200112101111000000101201210001001111021220211221221100022002100122022210012102210222221020021210121120002211220010020001220020011220210202211110022021212120102120111000122011222201120101220220101200000021001210011011021221101122222102011002022222001000002220201202212022011221020101120102102111110121210222120112011100120122221202211100210222221001202020111211112100020101021221220021102002202022221111101211222110210020222111021220012020212210220201010210221220001012111112101010101112221202112022110112000211000202210101102112020112000012222022022222101200201011221121012002202201002120120212012020210001212111212001002001200120211022010101122121211001101010001001222011222110021102200110100221001102200002202101221000211001001112012002021200001200002200210112212001202100122101101101021120112120221010211202002101211021210011102120110211220010221112012102111201000210012110222201222000000020112212120110122122012221011112111020002222202220222201222010000121102112212100220200202122012211020101201022110210120121221110021012010011212011001010020202200012221220121102000111001121001210211001021211120011210221211111210110101020110021112122021211012200111010201010210002100001200022002100221020001110101021021211212022010201020220102210122020210211012101110221010111012021101011100111212022001222000101201120110010122021022222102221220210012122000000122022021221211200121211121100000112201200100122120202022111220022100121102002022101102110112210210001222102111120012200002100211101112202220122001021101022101202020102010220022010222110121200110122002112100201002102211012210021101021221000210211221020220120111201121120110200211000100010121020111111200221000010021200021200202202021220210010121012210002000202112111211200202000202101220222102012111222100120211111011211221121221220010120202222211111122020112000201000202121022002010112110210200022112010100120222122000120222020111222020101221112112010021221211202102202002112202111021220002000111012002122200010021022211120212020202002111101202020021002001021012001011121122001111212120002121000001220202121122112122212102021112002010112020220021010111110202212212200212201212210021222021121122021101110010221102122010012022220110202120202101112011120000"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t130transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 130; 5 | constexpr uint64_t k = 47; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 128; 8 | constexpr const char *s = "02112202011222011001020100000201010122211211222210202001011112112122022101201111221"; 9 | constexpr const char *h = "10000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000011101211111202010021222010202112011122021121020021222021102120020002100121012120212022211021120100002211002000022212212002212111222101201221000210201011000200222220002022010100200020102020212010002111002102021011212022002001210212001212212112102201201202100112121222021121200202100021122210122122001012012122001111010220200121100020222000220112001120011010222210010000212112022221221211200121000111120120010021112010120010220111110021111010211011220022120000200100122111222010101201010020212001110200200011120021021221212111220220012211020120121221002000001011002112122020222021012211122002020122110111111002001210011012202201102111001000220210222101100221221202221011220200111011200011022220002222121001210010010201121011210100120110001020000222020112020001011210001111122102002210100012000111200201020011212021121001212201101211011100010222021101100112011220101021210010212201210210211200120011222110211120200011210200011120222020122121111220002011210221121210112211201102102001110202022210100201221200210011211011221012021000111111200102201002001022200212022111102222222121112101100001012000120212010120201121110200100210012221121111200120011210111100000010120121000100111102122021122122110002200210012202221001210221022222102002121012112000221122001002000122002001122021020221111002202121212010212011100012201122220112010122022010120000002100121001101102122110112222210201100202222200100000222020120221202201122102010112010210211111012121022212011201110012012222120221110021022222100120202011121111210002010102122122002110200220202222111110121122211021002022211102122001202021221022020101021022122000101211111210101010111222120211202211011200021100020221010110211202011200001222202202222210120020101122112101200220220100212012021201202021000121211121200100200120012021102201010112212121100110101000100122201122211002110220011010022100110220000220210122100021100100111201200202120000120000220021011221200120210012210110110102112011212022101021120200210121102121001110212011021122001022111201210211120100021001211022220122200000002011221212011012212201222101111211102000222220222022220122201000012110211221210022020020212201221102010120102211021012012122111002101201001121201100101002020220001222122012110200011100112100121021100102121112001121022121111121011010102011002111212202121101220011101020101021000210000120002200210022102000111010102102121121202201020102022010221012202021021101210111022101011101202110101110011121202200122200010120112011001012202102222210222122021001212200000012202202122121120012121112110000011220120010012212020202211122002210012110200202210110211011221021000122210211112001220000210021110111220222012200102110102210120202010201022002201022211012120011012200211210020100210221101221002110102122100021021122102022012011120112112011020021100010001012102011111120022100001002120002120020220202122021001012101221000200020211211121120020200020210122022210201211122210012021111101121122112122122001012020222221111112202011200020100020212102200201011211021020002211201010012022212200012022202011122202010122111211201002122121120210220200211220211102122000200011101200212220001002102221112021202020200211110120202002100200102101200101112112200111121212000212100000122020212112211212221210202111200201011202022002101011111020221221220021220121221002122202112112202110111001022110212201001202222011020212020210111201112000020210121211122221000101222112111020202020222122020000210212022201100200001110221000210020122120210222212200002220100120210201121022212200111122101210010220202101122002011112011221202222020121221010100210221220000002110202001000202022222121212122201102200102200001102121112222120201122200010011022122002112201001221222110010122020211020211200001210011202120010200222011221221002022220122000022202022000101212121020010111211012000220020110112220212222101012210211010101210212211222200010121011121021102001122020111220110200121102111112002100022121012201021201"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t20transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 20; 5 | constexpr uint64_t k = 7; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 19; 8 | constexpr const char *s = "1220222201110"; 9 | constexpr const char *h = "10000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000010000000000000100000000000001000000000000011101211111202010021222010202112011122021121020021222021102120020002100121012120212022211021"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t40transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 40; 5 | constexpr uint64_t k = 14; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 39; 8 | constexpr const char *s = "02202200101001201012112002"; 9 | constexpr const char *h = "10000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000011101211111202010021222010202112011122021121020021222021102120020002100121012120212022211021120100002211002000022212212002212111222101201221000210201011000200222220002022010100200020102020212010002111002102021011212022002001210212001212212112102201201202100112121222021121200202100021122210122122001012012122001111010220200121100020222000220112001120011010222210010"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t50transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 50; 5 | constexpr uint64_t k = 18; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 49; 8 | constexpr const char *s = "21122120202120011121201002001211"; 9 | constexpr const char *h = "1000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001110121111120201002122201020211201112202112102002122202110212002000210012101212021202221102112010000221100200002221221200221211122210120122100021020101100020022222000202201010020002010202021201000211100210202101121202200200121021200121221211210220120120210011212122202112120020210002112221012212200101201212200111101022020012110002022200022011200112001101022221001000021211202222122121120012100011112012001002111201012001022011111002111101021101122002212000020010012211122201010120101002021200111020020001112002102122121211122022001221102012012122100200000101100211212202022202"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t60transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 60; 5 | constexpr uint64_t k = 22; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 59; 8 | constexpr const char *s = "01020210022211210200200111011100111210"; 9 | constexpr const char *h = "100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000111012111112020100212220102021120111220211210200212220211021200200021001210121202120222110211201000022110020000222122120022121112221012012210002102010110002002222200020220101002000201020202120100021110021020210112120220020012102120012122121121022012012021001121212220211212002021000211222101221220010120121220011110102202001211000202220002201120011200110102222100100002121120222212212112001210001111201200100211120101200102201111100211110102110112200221200002001001221112220101012010100202120011102002000111200210212212121112202200122110201201212210020000010110021121220202220210122111220020201221101111110020012100110122022011021110010002202102221011002212212022210112202001110112000110222200022221210012100100102011210112101001201100010200002220201120200010112100011111221020022101000120001112002010200112120211210012122011012110111000"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t70transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 70; 5 | constexpr uint64_t k = 25; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 69; 8 | constexpr const char *s = "220211211201121110202110100011221221211110201"; 9 | constexpr const char *h = "100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001110121111120201002122201020211201112202112102002122202110212002000210012101212021202221102112010000221100200002221221200221211122210120122100021020101100020022222000202201010020002010202021201000211100210202101121202200200121021200121221211210220120120210011212122202112120020210002112221012212200101201212200111101022020012110002022200022011200112001101022221001000021211202222122121120012100011112012001002111201012001022011111002111101021101122002212000020010012211122201010120101002021200111020020001112002102122121211122022001221102012012122100200000101100211212202022202101221112200202012211011111100200121001101220220110211100100022021022210110022122120222101122020011101120001102222000222212100121001001020112101121010012011000102000022202011202000101121000111112210200221010001200011120020102001121202112100121220110121101110001022202110110011201122010102121001021220121021021120012001122211021112020001121020001112022202012212111122000201121022112121011221120110210200111020202221010020122120021001121101122101202100011111120010220100200102220021202211110222222212111210110000101200012021201012020112111020010021001"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t80transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 80; 5 | constexpr uint64_t k = 29; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 79; 8 | constexpr const char *s = "020121121110101002122201101200102221110020010220102"; 9 | constexpr const char *h = "100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001110121111120201002122201020211201112202112102002122202110212002000210012101212021202221102112010000221100200002221221200221211122210120122100021020101100020022222000202201010020002010202021201000211100210202101121202200200121021200121221211210220120120210011212122202112120020210002112221012212200101201212200111101022020012110002022200022011200112001101022221001000021211202222122121120012100011112012001002111201012001022011111002111101021101122002212000020010012211122201010120101002021200111020020001112002102122121211122022001221102012012122100200000101100211212202022202101221112200202012211011111100200121001101220220110211100100022021022210110022122120222101122020011101120001102222000222212100121001001020112101121010012011000102000022202011202000101121000111112210200221010001200011120020102001121202112100121220110121101110001022202110110011201122010102121001021220121021021120012001122211021112020001121020001112022202012212111122000201121022112121011221120110210200111020202221010020122120021001121101122101202100011111120010220100200102220021202211110222222212111210110000101200012021201012020112111020010021001222112111120012001121011110000001012012100010011110212202112212211000220021001220222100121022102222210200212101211200022112200100200012200200112202102022111100220212121201021201110001220112222011201012202201012000000210012100110110212211011222221020110020222220010000022202012022120220112210201011201021021111101212102221201120111001201222212022111002102"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/t90transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 90; 5 | constexpr uint64_t k = 33; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 89; 8 | constexpr const char *s = "010110210020221202212100212101012221212212111001211102012"; 9 | constexpr const char *h = "100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001110121111120201002122201020211201112202112102002122202110212002000210012101212021202221102112010000221100200002221221200221211122210120122100021020101100020022222000202201010020002010202021201000211100210202101121202200200121021200121221211210220120120210011212122202112120020210002112221012212200101201212200111101022020012110002022200022011200112001101022221001000021211202222122121120012100011112012001002111201012001022011111002111101021101122002212000020010012211122201010120101002021200111020020001112002102122121211122022001221102012012122100200000101100211212202022202101221112200202012211011111100200121001101220220110211100100022021022210110022122120222101122020011101120001102222000222212100121001001020112101121010012011000102000022202011202000101121000111112210200221010001200011120020102001121202112100121220110121101110001022202110110011201122010102121001021220121021021120012001122211021112020001121020001112022202012212111122000201121022112121011221120110210200111020202221010020122120021001121101122101202100011111120010220100200102220021202211110222222212111210110000101200012021201012020112111020010021001222112111120012001121011110000001012012100010011110212202112212211000220021001220222100121022102222210200212101211200022112200100200012200200112202102022111100220212121201021201110001220112222011201012202201012000000210012100110110212211011222221020110020222220010000022202012022120220112210201011201021021111101212102221201120111001201222212022111002102222210012020201112111121000201010212212200211020022020222211111012112221102100202221110212200120202122102202010102102212200010121111121010101011122212021120221101120002110002022101011021120201120000122220220222221012002010112211210120022022010021201202120120202100012121112120010020012001202110220101011221212110011010100010012220112221100211022001101002210011022000022021012210002110010011120120020212"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/wave100transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 100; 5 | constexpr uint64_t k = 36; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 94; 8 | constexpr const char *s = "1000011011121001200212120121112021201101211201210020022201112120"; 9 | constexpr const char *h = "1000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001110121111120201002122201020211201112202112102002122202110212002000210012101212021202221102112010000221100200002221221200221211122210120122100021020101100020022222000202201010020002010202021201000211100210202101121202200200121021200121221211210220120120210011212122202112120020210002112221012212200101201212200111101022020012110002022200022011200112001101022221001000021211202222122121120012100011112012001002111201012001022011111002111101021101122002212000020010012211122201010120101002021200111020020001112002102122121211122022001221102012012122100200000101100211212202022202101221112200202012211011111100200121001101220220110211100100022021022210110022122120222101122020011101120001102222000222212100121001001020112101121010012011000102000022202011202000101121000111112210200221010001200011120020102001121202112100121220110121101110001022202110110011201122010102121001021220121021021120012001122211021112020001121020001112022202012212111122000201121022112121011221120110210200111020202221010020122120021001121101122101202100011111120010220100200102220021202211110222222212111210110000101200012021201012020112111020010021001222112111120012001121011110000001012012100010011110212202112212211000220021001220222100121022102222210200212101211200022112200100200012200200112202102022111100220212121201021201110001220112222011201012202201012000000210012100110110212211011222221020110020222220010000022202012022120220112210201011201021021111101212102221201120111001201222212022111002102222210012020201112111121000201010212212200211020022020222211111012112221102100202221110212200120202122102202010102102212200010121111121010101011122212021120221101120002110002022101011021120201120000122220220222221012002010112211210120022022010021201202120120202100012121112120010020012001202110220101011221212110011010100010012220112221100211022001101002210011022000022021012210002110010011120120020212000012000022002101122120012021001221011011010211201121202210102112020021012110212100111021201102112200102211120121021112010002100121102222012220000000201122121201101221220122210111121110200022222022202222012220100001211021122121002202002021220122110201012010221102101201212211100210120100112120110010100202022000122212201211020001110011210012102110010212111200112102212111112101101010201100211121220212110122001110102010102"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/wave110transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 110; 5 | constexpr uint64_t k = 40; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 104; 8 | constexpr const char *s = "0011012022021000002101212120100111220011010020120021222100211210001011"; 9 | constexpr const char *h = "10000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000011101211111202010021222010202112011122021121020021222021102120020002100121012120212022211021120100002211002000022212212002212111222101201221000210201011000200222220002022010100200020102020212010002111002102021011212022002001210212001212212112102201201202100112121222021121200202100021122210122122001012012122001111010220200121100020222000220112001120011010222210010000212112022221221211200121000111120120010021112010120010220111110021111010211011220022120000200100122111222010101201010020212001110200200011120021021221212111220220012211020120121221002000001011002112122020222021012211122002020122110111111002001210011012202201102111001000220210222101100221221202221011220200111011200011022220002222121001210010010201121011210100120110001020000222020112020001011210001111122102002210100012000111200201020011212021121001212201101211011100010222021101100112011220101021210010212201210210211200120011222110211120200011210200011120222020122121111220002011210221121210112211201102102001110202022210100201221200210011211011221012021000111111200102201002001022200212022111102222222121112101100001012000120212010120201121110200100210012221121111200120011210111100000010120121000100111102122021122122110002200210012202221001210221022222102002121012112000221122001002000122002001122021020221111002202121212010212011100012201122220112010122022010120000002100121001101102122110112222210201100202222200100000222020120221202201122102010112010210211111012121022212011201110012012222120221110021022222100120202011121111210002010102122122002110200220202222111110121122211021002022211102122001202021221022020101021022122000101211111210101010111222120211202211011200021100020221010110211202011200001222202202222210120020101122112101200220220100212012021201202021000121211121200100200120012021102201010112212121100110101000100122201122211002110220011010022100110220000220210122100021100100111201200202120000120000220021011221200120210012210110110102112011212022101021120200210121102121001110212011021122001022111201210211120100021001211022220122200000002011221212011012212201222101111211102000222220222022220122201000012110211221210022020020212201221102010120102211021012012122111002101201001121201100101002020220001222122012110200011100112100121021100102121112001121022121111121011010102011002111212202121101220011101020101021000210000120002200210022102000111010102102121121202201020102022010221012202021021101210111022101011101202110101110011121202200122200010120112011001012202102222210222122021001212200000012202202122121120012121112110000011220120010012212020202211122002210012110200202210110211011221021000122210211112001220000210021110111220222012200102110102210120202010201022002201022211012120011012200211210020100210221101221002110102122100021021122102022012011120112112011020021100010001012102011111120022100001"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/wave120transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 120; 5 | constexpr uint64_t k = 44; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 113; 8 | constexpr const char *s = "1202012100201110012111002020200110221020212112102012021121121020020021000211"; 9 | constexpr const char *h = "100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000111012111112020100212220102021120111220211210200212220211021200200021001210121202120222110211201000022110020000222122120022121112221012012210002102010110002002222200020220101002000201020202120100021110021020210112120220020012102120012122121121022012012021001121212220211212002021000211222101221220010120121220011110102202001211000202220002201120011200110102222100100002121120222212212112001210001111201200100211120101200102201111100211110102110112200221200002001001221112220101012010100202120011102002000111200210212212121112202200122110201201212210020000010110021121220202220210122111220020201221101111110020012100110122022011021110010002202102221011002212212022210112202001110112000110222200022221210012100100102011210112101001201100010200002220201120200010112100011111221020022101000120001112002010200112120211210012122011012110111000102220211011001120112201010212100102122012102102112001200112221102111202000112102000111202220201221211112200020112102211212101122112011021020011102020222101002012212002100112110112210120210001111112001022010020010222002120221111022222221211121011000010120001202120101202011211102001002100122211211112001200112101111000000101201210001001111021220211221221100022002100122022210012102210222221020021210121120002211220010020001220020011220210202211110022021212120102120111000122011222201120101220220101200000021001210011011021221101122222102011002022222001000002220201202212022011221020101120102102111110121210222120112011100120122221202211100210222221001202020111211112100020101021221220021102002202022221111101211222110210020222111021220012020212210220201010210221220001012111112101010101112221202112022110112000211000202210101102112020112000012222022022222101200201011221121012002202201002120120212012020210001212111212001002001200120211022010101122121211001101010001001222011222110021102200110100221001102200002202101221000211001001112012002021200001200002200210112212001202100122101101101021120112120221010211202002101211021210011102120110211220010221112012102111201000210012110222201222000000020112212120110122122012221011112111020002222202220222201222010000121102112212100220200202122012211020101201022110210120121221110021012010011212011001010020202200012221220121102000111001121001210211001021211120011210221211111210110101020110021112122021211012200111010201010210002100001200022002100221020001110101021021211212022010201020220102210122020210211012101110221010111012021101011100111212022001222000101201120110010122021022222102221220210012122000000122022021221211200121211121100000112201200100122120202022111220022100121102002022101102110112210210001222102111120012200002100211101112202220122001021101022101202020102010220022010222110121200110122002112100201002102211012210021101021221000210211221020220120111201121120110200211000100010121020111111200221000010021200021200202202021220210010121012210002000202112111211200202000202101220222102012111222100120211111011211221121221220010120202222211111122020112000201000202121022002010112110210200022112010100120222122000120222020111222020101221112112010021221211202102202002112202111021220002000111012002122200010021022211120212020202002111101202020021002001021012001011121122001111212120002121000001220202121122112122212102021112002010112020220021010111110202212212200212201212210021222021121122021101110010221102122010012022220110202120202101112011120000"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/wave130transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 130; 5 | constexpr uint64_t k = 47; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 123; 8 | constexpr const char *s = "02112202011222011001020100000201010122211211222210202001011112112122022101201111221"; 9 | constexpr const char *h = "10000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000011101211111202010021222010202112011122021121020021222021102120020002100121012120212022211021120100002211002000022212212002212111222101201221000210201011000200222220002022010100200020102020212010002111002102021011212022002001210212001212212112102201201202100112121222021121200202100021122210122122001012012122001111010220200121100020222000220112001120011010222210010000212112022221221211200121000111120120010021112010120010220111110021111010211011220022120000200100122111222010101201010020212001110200200011120021021221212111220220012211020120121221002000001011002112122020222021012211122002020122110111111002001210011012202201102111001000220210222101100221221202221011220200111011200011022220002222121001210010010201121011210100120110001020000222020112020001011210001111122102002210100012000111200201020011212021121001212201101211011100010222021101100112011220101021210010212201210210211200120011222110211120200011210200011120222020122121111220002011210221121210112211201102102001110202022210100201221200210011211011221012021000111111200102201002001022200212022111102222222121112101100001012000120212010120201121110200100210012221121111200120011210111100000010120121000100111102122021122122110002200210012202221001210221022222102002121012112000221122001002000122002001122021020221111002202121212010212011100012201122220112010122022010120000002100121001101102122110112222210201100202222200100000222020120221202201122102010112010210211111012121022212011201110012012222120221110021022222100120202011121111210002010102122122002110200220202222111110121122211021002022211102122001202021221022020101021022122000101211111210101010111222120211202211011200021100020221010110211202011200001222202202222210120020101122112101200220220100212012021201202021000121211121200100200120012021102201010112212121100110101000100122201122211002110220011010022100110220000220210122100021100100111201200202120000120000220021011221200120210012210110110102112011212022101021120200210121102121001110212011021122001022111201210211120100021001211022220122200000002011221212011012212201222101111211102000222220222022220122201000012110211221210022020020212201221102010120102211021012012122111002101201001121201100101002020220001222122012110200011100112100121021100102121112001121022121111121011010102011002111212202121101220011101020101021000210000120002200210022102000111010102102121121202201020102022010221012202021021101210111022101011101202110101110011121202200122200010120112011001012202102222210222122021001212200000012202202122121120012121112110000011220120010012212020202211122002210012110200202210110211011221021000122210211112001220000210021110111220222012200102110102210120202010201022002201022211012120011012200211210020100210221101221002110102122100021021122102022012011120112112011020021100010001012102011111120022100001002120002120020220202122021001012101221000200020211211121120020200020210122022210201211122210012021111101121122112122122001012020222221111112202011200020100020212102200201011211021020002211201010012022212200012022202011122202010122111211201002122121120210220200211220211102122000200011101200212220001002102221112021202020200211110120202002100200102101200101112112200111121212000212100000122020212112211212221210202111200201011202022002101011111020221221220021220121221002122202112112202110111001022110212201001202222011020212020210111201112000020210121211122221000101222112111020202020222122020000210212022201100200001110221000210020122120210222212200002220100120210201121022212200111122101210010220202101122002011112011221202222020121221010100210221220000002110202001000202022222121212122201102200102200001102121112222120201122200010011022122002112201001221222110010122020211020211200001210011202120010200222011221221002022220122000022202022000101212121020010111211012000220020110112220212222101012210211010101210212211222200010121011121021102001122020111220110200121102111112002100022121012201021201"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/wave40transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 40; 5 | constexpr uint64_t k = 14; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 37; 8 | constexpr const char *s = "02202200101001201012112002"; 9 | constexpr const char *h = "10000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000010000000000000000000000000011101211111202010021222010202112011122021121020021222021102120020002100121012120212022211021120100002211002000022212212002212111222101201221000210201011000200222220002022010100200020102020212010002111002102021011212022002001210212001212212112102201201202100112121222021121200202100021122210122122001012012122001111010220200121100020222000220112001120011010222210010"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/wave50transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 50; 5 | constexpr uint64_t k = 18; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 47; 8 | constexpr const char *s = "21122120202120011121201002001211"; 9 | constexpr const char *h = "1000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000001110121111120201002122201020211201112202112102002122202110212002000210012101212021202221102112010000221100200002221221200221211122210120122100021020101100020022222000202201010020002010202021201000211100210202101121202200200121021200121221211210220120120210011212122202112120020210002112221012212200101201212200111101022020012110002022200022011200112001101022221001000021211202222122121120012100011112012001002111201012001022011111002111101021101122002212000020010012211122201010120101002021200111020020001112002102122121211122022001221102012012122100200000101100211212202022202"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/wave60transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 60; 5 | constexpr uint64_t k = 22; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 56; 8 | constexpr const char *s = "01020210022211210200200111011100111210"; 9 | constexpr const char *h = "100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000100000000000000000000000000000000000000111012111112020100212220102021120111220211210200212220211021200200021001210121202120222110211201000022110020000222122120022121112221012012210002102010110002002222200020220101002000201020202120100021110021020210112120220020012102120012122121121022012012021001121212220211212002021000211222101221220010120121220011110102202001211000202220002201120011200110102222100100002121120222212212112001210001111201200100211120101200102201111100211110102110112200221200002001001221112220101012010100202120011102002000111200210212212121112202200122110201201212210020000010110021121220202220210122111220020201221101111110020012100110122022011021110010002202102221011002212212022210112202001110112000110222200022221210012100100102011210112101001201100010200002220201120200010112100011111221020022101000120001112002010200112120211210012122011012110111000"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/wave70transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 70; 5 | constexpr uint64_t k = 25; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 66; 8 | constexpr const char *s = "220211211201121110202110100011221221211110201"; 9 | constexpr const char *h = "100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001110121111120201002122201020211201112202112102002122202110212002000210012101212021202221102112010000221100200002221221200221211122210120122100021020101100020022222000202201010020002010202021201000211100210202101121202200200121021200121221211210220120120210011212122202112120020210002112221012212200101201212200111101022020012110002022200022011200112001101022221001000021211202222122121120012100011112012001002111201012001022011111002111101021101122002212000020010012211122201010120101002021200111020020001112002102122121211122022001221102012012122100200000101100211212202022202101221112200202012211011111100200121001101220220110211100100022021022210110022122120222101122020011101120001102222000222212100121001001020112101121010012011000102000022202011202000101121000111112210200221010001200011120020102001121202112100121220110121101110001022202110110011201122010102121001021220121021021120012001122211021112020001121020001112022202012212111122000201121022112121011221120110210200111020202221010020122120021001121101122101202100011111120010220100200102220021202211110222222212111210110000101200012021201012020112111020010021001"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/wave80transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 80; 5 | constexpr uint64_t k = 29; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 75; 8 | constexpr const char *s = "020121121110101002122201101200102221110020010220102"; 9 | constexpr const char *h = "100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001110121111120201002122201020211201112202112102002122202110212002000210012101212021202221102112010000221100200002221221200221211122210120122100021020101100020022222000202201010020002010202021201000211100210202101121202200200121021200121221211210220120120210011212122202112120020210002112221012212200101201212200111101022020012110002022200022011200112001101022221001000021211202222122121120012100011112012001002111201012001022011111002111101021101122002212000020010012211122201010120101002021200111020020001112002102122121211122022001221102012012122100200000101100211212202022202101221112200202012211011111100200121001101220220110211100100022021022210110022122120222101122020011101120001102222000222212100121001001020112101121010012011000102000022202011202000101121000111112210200221010001200011120020102001121202112100121220110121101110001022202110110011201122010102121001021220121021021120012001122211021112020001121020001112022202012212111122000201121022112121011221120110210200111020202221010020122120021001121101122101202100011111120010220100200102220021202211110222222212111210110000101200012021201012020112111020010021001222112111120012001121011110000001012012100010011110212202112212211000220021001220222100121022102222210200212101211200022112200100200012200200112202102022111100220212121201021201110001220112222011201012202201012000000210012100110110212211011222221020110020222220010000022202012022120220112210201011201021021111101212102221201120111001201222212022111002102"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/challenges/ternary/wave90transformed.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 90; 5 | constexpr uint64_t k = 33; 6 | constexpr uint64_t seed = 0; 7 | constexpr uint64_t w = 85; 8 | constexpr const char *s = "010110210020221202212100212101012221212212111001211102012"; 9 | constexpr const char *h = "100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001110121111120201002122201020211201112202112102002122202110212002000210012101212021202221102112010000221100200002221221200221211122210120122100021020101100020022222000202201010020002010202021201000211100210202101121202200200121021200121221211210220120120210011212122202112120020210002112221012212200101201212200111101022020012110002022200022011200112001101022221001000021211202222122121120012100011112012001002111201012001022011111002111101021101122002212000020010012211122201010120101002021200111020020001112002102122121211122022001221102012012122100200000101100211212202022202101221112200202012211011111100200121001101220220110211100100022021022210110022122120222101122020011101120001102222000222212100121001001020112101121010012011000102000022202011202000101121000111112210200221010001200011120020102001121202112100121220110121101110001022202110110011201122010102121001021220121021021120012001122211021112020001121020001112022202012212111122000201121022112121011221120110210200111020202221010020122120021001121101122101202100011111120010220100200102220021202211110222222212111210110000101200012021201012020112111020010021001222112111120012001121011110000001012012100010011110212202112212211000220021001220222100121022102222210200212101211200022112200100200012200200112202102022111100220212121201021201110001220112222011201012202201012000000210012100110110212211011222221020110020222220010000022202012022120220112210201011201021021111101212102221201120111001201222212022111002102222210012020201112111121000201010212212200211020022020222211111012112221102100202221110212200120202122102202010102102212200010121111121010101011122212021120221101120002110002022101011021120201120000122220220222221012002010112211210120022022010021201202120120202100012121112120010020012001202110220101011221212110011010100010012220112221100211022001101002210011022000022021012210002110010011120120020212"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h)` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/fq/prange/50.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../challenges/50_20_4.h" 5 | #include "fq/prange.h" 6 | 7 | using ::testing::EmptyTestEventListener; 8 | using ::testing::InitGoogleTest; 9 | using ::testing::Test; 10 | using ::testing::TestEventListeners; 11 | using ::testing::TestInfo; 12 | using ::testing::TestPartResult; 13 | using ::testing::UnitTest; 14 | 15 | TEST(Prange, t1p0) { 16 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=q,.w=w,.p=0,.l=0,.c=0,.threads=1}; 17 | 18 | FqPrange prange{}; 19 | prange.from_string(h, s); 20 | prange.run(); 21 | EXPECT_EQ(prange.correct(), true); 22 | } 23 | 24 | TEST(Prange, q3t1p1) { 25 | static constexpr ConfigISD isdConfig{.n=50,.k=20,.q=3,.w=2,.p=1,.l=0,.c=0,.threads=1}; 26 | FqPrange prange{}; 27 | prange.random(); 28 | prange.run(); 29 | EXPECT_EQ(prange.correct(), true); 30 | } 31 | 32 | TEST(Prange, q3t1p1c5) { 33 | static constexpr ConfigISD isdConfig{.n=50,.k=20,.q=3,.w=2,.p=1,.l=0,.c=5,.threads=1}; 34 | FqPrange prange{}; 35 | prange.random(); 36 | prange.run(); 37 | EXPECT_EQ(prange.correct(), true); 38 | } 39 | 40 | TEST(Prange, t1p1) { 41 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=q,.w=w-2,.p=1,.l=0,.c=0,.threads=1}; 42 | 43 | FqPrange prange{}; 44 | prange.from_string(h, s); 45 | prange.run(); 46 | EXPECT_EQ(prange.correct(), true); 47 | } 48 | 49 | TEST(Prange, t1p2) { 50 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=q,.w=w,.p=2,.l=0,.c=0,.threads=1}; 51 | 52 | FqPrange prange{}; 53 | prange.from_string(h, s); 54 | prange.run(); 55 | EXPECT_EQ(prange.correct(), true); 56 | } 57 | int main(int argc, char **argv) { 58 | InitGoogleTest(&argc, argv); 59 | srand(time(NULL)); 60 | random_seed(rand()); 61 | return RUN_ALL_TESTS(); 62 | } -------------------------------------------------------------------------------- /tests/fq/prange/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 2 | 3 | foreach(testfile ${TEST_SOURCES}) 4 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 5 | string(REPLACE ".cpp" "" file ${filename}) 6 | add_executable(test_fq_prange_${file} ${testfile}) 7 | target_compile_options(test_fq_prange_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 8 | target_link_libraries(test_fq_prange_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 9 | endforeach(testfile ${TEST_SOURCES}) 10 | 11 | if(USE_SCLANG) 12 | use_sclang_compiler() 13 | foreach(testfile ${TEST_SOURCES}) 14 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 15 | string(REPLACE ".cpp" "" file ${filename}) 16 | add_executable(sclang_fq_prange_${file} ${testfile}) 17 | target_compile_options(sclang_fq_prange_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 18 | target_link_libraries(sclang_fq_prange_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 19 | endforeach(testfile ${TEST_SOURCES}) 20 | use_host_compiler() 21 | endif() -------------------------------------------------------------------------------- /tests/fq/sieving/50.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../challenges/50_20_4.h" 4 | #include "fq/sieving.h" 5 | 6 | using ::testing::EmptyTestEventListener; 7 | using ::testing::InitGoogleTest; 8 | using ::testing::Test; 9 | using ::testing::TestEventListeners; 10 | using ::testing::TestInfo; 11 | using ::testing::TestPartResult; 12 | using ::testing::UnitTest; 13 | 14 | // TODO 15 | // TEST(Sieving, t1p2) { 16 | // static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=q,.w=w,.p=2,.l=3,.c=0,.threads=1}; 17 | // static constexpr ConfigFqSieving config{isdConfig, 20, 5, 3}; 18 | // 19 | // FqSieving sieve{}; 20 | // sieve.from_string(h, s); 21 | // sieve.run(); 22 | // EXPECT_EQ(sieve.correct(), true); 23 | // } 24 | 25 | int main(int argc, char **argv) { 26 | InitGoogleTest(&argc, argv); 27 | srand(time(NULL)); 28 | random_seed(rand()); 29 | return RUN_ALL_TESTS(); 30 | } 31 | -------------------------------------------------------------------------------- /tests/fq/sieving/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 2 | 3 | foreach(testfile ${TEST_SOURCES}) 4 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 5 | string(REPLACE ".cpp" "" file ${filename}) 6 | add_executable(test_fq_sieving_${file} ${testfile}) 7 | target_compile_options(test_fq_sieving_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 8 | target_link_libraries(test_fq_sieving_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 9 | endforeach(testfile ${TEST_SOURCES}) 10 | 11 | if(USE_SCLANG) 12 | use_sclang_compiler() 13 | foreach(testfile ${TEST_SOURCES}) 14 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 15 | string(REPLACE ".cpp" "" file ${filename}) 16 | add_executable(sclang_fq_sieving${file} ${testfile}) 17 | target_compile_options(sclang_fq_sieving_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 18 | target_link_libraries(sclang_fq_sieving_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 19 | endforeach(testfile ${TEST_SOURCES}) 20 | use_host_compiler() 21 | endif() -------------------------------------------------------------------------------- /tests/fq/stern/50.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../challenges/50_20_4.h" 5 | #include "fq/stern.h" 6 | #include "fq/stern_v2.h" 7 | 8 | using ::testing::EmptyTestEventListener; 9 | using ::testing::InitGoogleTest; 10 | using ::testing::Test; 11 | using ::testing::TestEventListeners; 12 | using ::testing::TestInfo; 13 | using ::testing::TestPartResult; 14 | using ::testing::UnitTest; 15 | 16 | 17 | TEST(Stern, t1p1) { 18 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=q,.w=w,.p=1,.l=5,.c=0,.threads=1}; 19 | static constexpr ConfigStern config{isdConfig, .HM_bucketsize=10}; 20 | FqStern stern{}; 21 | stern.from_string(h, s); 22 | stern.run(); 23 | EXPECT_EQ(stern.correct(), true); 24 | } 25 | 26 | TEST(Stern, q4t1p1) { 27 | static constexpr ConfigISD isdConfig{.n=50,.k=20,.q=4,.w=4,.p=1,.l=3,.c=0,.threads=1}; 28 | static constexpr ConfigStern config{isdConfig, .HM_bucketsize=10}; 29 | FqStern stern{}; 30 | stern.random(); 31 | stern.run(); 32 | EXPECT_EQ(stern.correct(), true); 33 | } 34 | 35 | TEST(Stern, q4t1p1c4) { 36 | static constexpr ConfigISD isdConfig{.n=70,.k=30,.q=4,.w=4,.p=1,.l=3,.c=4,.threads=1}; 37 | static constexpr ConfigStern config{isdConfig, .HM_bucketsize=10}; 38 | FqStern stern{}; 39 | stern.random(); 40 | stern.run(); 41 | EXPECT_EQ(stern.correct(), true); 42 | } 43 | 44 | TEST(SternV2, t1p1) { 45 | static constexpr ConfigISD isdConfig{.n=70,.k=30,.q=4,.w=4,.p=1,.l=3,.c=0,.threads=1}; 46 | static constexpr ConfigStern config{isdConfig, .HM_bucketsize=10}; 47 | FqSternV2 stern{}; 48 | stern.random(); 49 | stern.run(); 50 | EXPECT_EQ(stern.correct(), true); 51 | } 52 | 53 | 54 | int main(int argc, char **argv) { 55 | InitGoogleTest(&argc, argv); 56 | srand(time(NULL)); 57 | random_seed(rand()); 58 | return RUN_ALL_TESTS(); 59 | } -------------------------------------------------------------------------------- /tests/fq/stern/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 2 | 3 | foreach(testfile ${TEST_SOURCES}) 4 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 5 | string(REPLACE ".cpp" "" file ${filename}) 6 | add_executable(test_fq_stern_${file} ${testfile}) 7 | target_compile_options(test_fq_stern_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 8 | target_link_libraries(test_fq_stern_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 9 | endforeach(testfile ${TEST_SOURCES}) 10 | 11 | if(USE_SCLANG) 12 | use_sclang_compiler() 13 | foreach(testfile ${TEST_SOURCES}) 14 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 15 | string(REPLACE ".cpp" "" file ${filename}) 16 | add_executable(sclang_fq_sieving${file} ${testfile}) 17 | target_compile_options(sclang_fq_stern_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 18 | target_link_libraries(sclang_fq_stern_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 19 | endforeach(testfile ${TEST_SOURCES}) 20 | use_host_compiler() 21 | endif() -------------------------------------------------------------------------------- /tests/isd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "decoding/challenges/100.h" 5 | #include "mitm.h" 6 | 7 | using ::testing::EmptyTestEventListener; 8 | using ::testing::InitGoogleTest; 9 | using ::testing::Test; 10 | using ::testing::TestEventListeners; 11 | using ::testing::TestInfo; 12 | using ::testing::TestPartResult; 13 | using ::testing::UnitTest; 14 | 15 | TEST(EnumHashMapConfig, print) { 16 | static constexpr ConfigISD config{.n=n,.k=k,.q=2,.w=w,.p=2,.l=10,.c=0,.threads=1}; 17 | config.print(); 18 | } 19 | 20 | TEST(EnumHashMap, fromstring) { 21 | static constexpr ConfigISD config{.n=n,.k=k,.q=2,.w=w,.p=2,.l=10,.c=0,.threads=1}; 22 | ISDInstance isd{}; 23 | isd.from_string(h, s); 24 | isd.print(); 25 | } 26 | 27 | TEST(EnumHashMap, random) { 28 | static constexpr ConfigISD config{.n=n,.k=k,.q=2,.w=w,.p=2,.l=10,.c=0,.threads=1}; 29 | ISDInstance isd{}; 30 | isd.random(); 31 | 32 | isd.wA.print(); 33 | isd.s.print(); 34 | isd.e.print(); 35 | } 36 | 37 | TEST(EnumHashMap, step) { 38 | constexpr uint32_t l = 10; 39 | static constexpr ConfigISD config{.n=n,.k=k,.q=2,.w=w,.p=2,.l=l,.c=20,.threads=1}; 40 | ISDInstance isd{}; 41 | isd.from_string(h, s); 42 | 43 | for (size_t i = 0; i < 1; ++i) { 44 | isd.step(); 45 | 46 | // check systemized 47 | for (uint32_t j = 0; j < n-k; ++j) { 48 | for (uint32_t m = 0; m < n-k-l; ++m) { 49 | EXPECT_EQ(isd.wA.get(j, m), j == m); 50 | } 51 | } 52 | 53 | // check syndrome, note: swapped 54 | for (uint32_t j = 0; j < n - k; ++j) { 55 | EXPECT_EQ(isd.wA.get(j, n), isd.ws.get(n-k-j-1)); 56 | } 57 | 58 | // note swapped 59 | for (uint32_t j = 0; j < l; ++j) { 60 | EXPECT_EQ(isd.ws.get(j), (isd.syndrome >> j) & 1u); 61 | } 62 | 63 | // check submatrix, note H is swapped 64 | for (uint32_t j = 0; j < n-k; ++j) { 65 | for (uint32_t m = 0; m < k+l; ++m) { 66 | EXPECT_EQ(isd.wA.get(j, m+(n-k-l)), isd.H.get(n-k-j-1, m)); 67 | } 68 | } 69 | 70 | // check transpose/swap 71 | for (uint32_t j = 0; j < n-k; ++j) { 72 | for (uint32_t m = 0; m < k+l; ++m) { 73 | EXPECT_EQ(isd.H.get(j, m), isd.HT.get(m, j)); 74 | } 75 | } 76 | } 77 | } 78 | 79 | int main(int argc, char **argv) { 80 | InitGoogleTest(&argc, argv); 81 | srand(time(NULL)); 82 | random_seed(rand()); 83 | return RUN_ALL_TESTS(); 84 | } 85 | -------------------------------------------------------------------------------- /tests/mceliece/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 2 | 3 | foreach(testfile ${TEST_SOURCES}) 4 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 5 | string(REPLACE ".cpp" "" file ${filename}) 6 | add_executable(mceliece_${file} ${testfile}) 7 | target_compile_options(mceliece_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 8 | #add_dependencies(mceliece_${file} cryptanalysislib_project) 9 | target_link_libraries(mceliece_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 10 | endforeach(testfile ${TEST_SOURCES}) 11 | 12 | 13 | if(USE_SCLANG) 14 | use_sclang_compiler() 15 | foreach(testfile ${TEST_SOURCES}) 16 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 17 | string(REPLACE ".cpp" "" file ${filename}) 18 | add_executable(sclang_mceliece_${file} ${testfile}) 19 | target_compile_options(sclang_mceliece_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 20 | target_link_libraries(sclang_mceliece_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 21 | endforeach(testfile ${TEST_SOURCES}) 22 | use_host_compiler() 23 | endif() 24 | 25 | if(USE_CUDA) 26 | add_subdirectory("cuda") 27 | endif() 28 | add_subdirectory(bjmm) 29 | add_subdirectory(prange) 30 | #TODO add_subdirectory(pcs) 31 | #TODO add_subdirectory(sieving) 32 | add_subdirectory(stern) 33 | #TODOadd_subdirectory(mo) 34 | -------------------------------------------------------------------------------- /tests/mceliece/bjmm/1284.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../challenges/mce640.h" 5 | #include "bjmm.h" 6 | 7 | using ::testing::EmptyTestEventListener; 8 | using ::testing::InitGoogleTest; 9 | using ::testing::Test; 10 | using ::testing::TestEventListeners; 11 | using ::testing::TestInfo; 12 | using ::testing::TestPartResult; 13 | using ::testing::UnitTest; 14 | 15 | 16 | TEST(BJMM, t1284t1p1) { 17 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=1,.l=19,.c=0,.threads=1}; 18 | static constexpr ConfigBJMM config{isdConfig, 2, 1<<6, 4}; 19 | 20 | BJMM bjmm{}; 21 | bjmm.from_string(h, s); 22 | bjmm.run(); 23 | EXPECT_EQ(bjmm.correct(), true); 24 | } 25 | 26 | int main(int argc, char **argv) { 27 | InitGoogleTest(&argc, argv); 28 | ident(); 29 | srand(time(NULL)); 30 | random_seed(rand()); 31 | return RUN_ALL_TESTS(); 32 | } 33 | -------------------------------------------------------------------------------- /tests/mceliece/bjmm/240.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../challenges/mce240.h" 6 | #include "bjmm.h" 7 | 8 | using ::testing::EmptyTestEventListener; 9 | using ::testing::InitGoogleTest; 10 | using ::testing::Test; 11 | using ::testing::TestEventListeners; 12 | using ::testing::TestInfo; 13 | using ::testing::TestPartResult; 14 | using ::testing::UnitTest; 15 | 16 | 17 | TEST(Bjmm, t240) { 18 | constexpr uint32_t bucketsize1 = 16; 19 | constexpr uint32_t bucketsize2 = 8; 20 | 21 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=1,.l=10,.c=0,.threads=1}; 22 | static constexpr ConfigBJMM config{isdConfig, 4, bucketsize1, bucketsize2}; 23 | 24 | BJMM bjmm{}; 25 | bjmm.from_string(h, s); 26 | bjmm.run(); 27 | EXPECT_EQ(bjmm.correct(), true); 28 | } 29 | 30 | int main(int argc, char **argv) { 31 | InitGoogleTest(&argc, argv); 32 | srand(time(NULL)); 33 | random_seed(rand()); 34 | return RUN_ALL_TESTS(); 35 | } 36 | -------------------------------------------------------------------------------- /tests/mceliece/bjmm/431.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../challenges/mce431.h" 5 | #include "bjmm.h" 6 | 7 | using ::testing::EmptyTestEventListener; 8 | using ::testing::InitGoogleTest; 9 | using ::testing::Test; 10 | using ::testing::TestEventListeners; 11 | using ::testing::TestInfo; 12 | using ::testing::TestPartResult; 13 | using ::testing::UnitTest; 14 | 15 | TEST(BJMM, t431t1p2) { 16 | constexpr uint32_t bucketsize1 = 16; 17 | constexpr uint32_t bucketsize2 = 8; 18 | 19 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=1,.l=16,.c=0,.threads=1}; 20 | static constexpr ConfigBJMM config{isdConfig, 2, bucketsize1, bucketsize2}; 21 | 22 | BJMM bjmm{}; 23 | bjmm.from_string(h, s); 24 | bjmm.run(); 25 | EXPECT_EQ(bjmm.correct(), true); 26 | } 27 | 28 | TEST(BJMM, t431t1p2c20) { 29 | constexpr uint32_t bucketsize1 = 16; 30 | constexpr uint32_t bucketsize2 = 8; 31 | 32 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=1,.l=16,.c=20,.threads=1}; 33 | static constexpr ConfigBJMM config{isdConfig, 2, bucketsize1, bucketsize2}; 34 | 35 | BJMM bjmm{}; 36 | bjmm.from_string(h, s); 37 | bjmm.run(); 38 | EXPECT_EQ(bjmm.correct(), true); 39 | } 40 | 41 | // TODO 42 | //TEST(EB, t431t1p2) { 43 | // constexpr uint32_t bucketsize1 = 16; 44 | // constexpr uint32_t bucketsize2 = 8; 45 | // 46 | // static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=1,.l=16,.c=0,.threads=1}; 47 | // static constexpr ConfigBJMM configBJMM{isdConfig, 2, bucketsize1, bucketsize2}; 48 | // static constexpr ConfigEB config{isdConfig, .l1=2, .HM1_bucketsize=bucketsize1, .HM2_bucketsize=bucketsize2, .p2=1}; 49 | // 50 | // EB bjmm{}; 51 | // bjmm.from_string(h, s); 52 | // bjmm.run(); 53 | // EXPECT_EQ(bjmm.correct(), true); 54 | //} 55 | int main(int argc, char **argv) { 56 | InitGoogleTest(&argc, argv); 57 | ident(); 58 | srand(time(NULL)); 59 | random_seed(rand()); 60 | return RUN_ALL_TESTS(); 61 | } 62 | -------------------------------------------------------------------------------- /tests/mceliece/bjmm/640.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../challenges/mce640.h" 5 | #include "bjmm.h" 6 | 7 | using ::testing::EmptyTestEventListener; 8 | using ::testing::InitGoogleTest; 9 | using ::testing::Test; 10 | using ::testing::TestEventListeners; 11 | using ::testing::TestInfo; 12 | using ::testing::TestPartResult; 13 | using ::testing::UnitTest; 14 | 15 | 16 | TEST(BJMM, t640t1p2) { 17 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=1,.l=16,.c=0,.threads=1}; 18 | static constexpr ConfigBJMM config{isdConfig, 2, 1<<6, 20}; 19 | 20 | BJMM bjmm{}; 21 | bjmm.from_string(h, s); 22 | bjmm.run(); 23 | EXPECT_EQ(bjmm.correct(), true); 24 | } 25 | 26 | TEST(BJMM, t640t1p2c20) { 27 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=1,.l=16,.c=20,.threads=1}; 28 | static constexpr ConfigBJMM config{isdConfig, 2, 1<<6, 20}; 29 | 30 | BJMM bjmm{}; 31 | bjmm.from_string(h, s); 32 | bjmm.run(); 33 | EXPECT_EQ(bjmm.correct(), true); 34 | } 35 | 36 | int main(int argc, char **argv) { 37 | InitGoogleTest(&argc, argv); 38 | ident(); 39 | srand(time(NULL)); 40 | random_seed(rand()); 41 | return RUN_ALL_TESTS(); 42 | } 43 | -------------------------------------------------------------------------------- /tests/mceliece/bjmm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 2 | 3 | foreach(testfile ${TEST_SOURCES}) 4 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 5 | string(REPLACE ".cpp" "" file ${filename}) 6 | add_executable(mceliece_test_bjmm_${file} ${testfile}) 7 | target_compile_options(mceliece_test_bjmm_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 8 | target_link_libraries(mceliece_test_bjmm_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 9 | endforeach(testfile ${TEST_SOURCES}) 10 | 11 | if(USE_SCLANG) 12 | use_sclang_compiler() 13 | foreach(testfile ${TEST_SOURCES}) 14 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 15 | string(REPLACE ".cpp" "" file ${filename}) 16 | add_executable(sclang_mceliece_bjmm_${file} ${testfile}) 17 | target_compile_options(sclang_mceliece_bjmm_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 18 | target_link_libraries(sclang_mceliece_bjmm_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 19 | endforeach(testfile ${TEST_SOURCES}) 20 | use_host_compiler() 21 | endif() 22 | 23 | -------------------------------------------------------------------------------- /tests/mceliece/challenges/mce156.h: -------------------------------------------------------------------------------- 1 | #ifndef SMALLSECRETLWE_DECODING_FILE_H 2 | #define SMALLSECRETLWE_DECODING_FILE_H 3 | #include 4 | constexpr uint64_t n = 156; 5 | constexpr uint64_t k = 125; 6 | constexpr uint64_t seed = 125; 7 | constexpr uint64_t w = 4; 8 | constexpr const char *s = "0110011111101110001011100111001"; 9 | constexpr const char *h = "001101011101100001000111011100111010000000101110101010100001010001011001000000111001100000111001110001100110011011000001000111101011000000111011111010110001110101101100010111010010010101110110101111000101111100101011111000000111101111010110110111110000001111100000011000101010010010010001101001010010010101111010001101010110100100110100110001010111001100011100101110110010100011111000111001100001101101101110000100111010010110010001011000011011001100111101010111100001100011010111111000101100001101001110010100011111110001110110001100000101101001110110001011101110110011100010001011001101100010011110101010101001001110001110111000010011111110000101000100110010000101011100110111001010010111100110010101111110000000000111001101111110010101100010011000100010010101111110000000011111111010100000000100011111001000011110100100111010011000111011111000001100010100100011010001001000001110110111000001100111111001101001111111000101110001000010001000101011110100011000110000101111010110001101001100000100001000100000111110000010101110111100001000111111110100110010011000001110100100011111001110000001101011110111110100101110000110000110110000100100001111111011010111111101111110110010000111000111110000111110000010110001011110001101110101100110110011010111101011011101010001101001010000101100011001001010010111000110100001111010011101110111101100111111111011100101110010011110001011010101010100110110101000001011011000011011110101000001100011111101101011010000001111110101010110011011000111010010001010001101011110010001100011100001011000110100111001111110101100101100000111110100011000010011010110100101111010000111001000101100101000000010001011010010110100110101011100010010010001001100010110110011010101101101110010010110111100001101100100100010111111000101010111100011010111001101110001000011011110111101001011001011100101111000100101111100100110001101100000110000101000010011011010001010000111101101001000110100000001010011010000100111010001011110100011001000111110000111100110011111001011111111010101011000010110010101100111110101001001001001010001101100001011000100111101110100000100011101111001011001100000110011001111010000100011101001101101011110010011111111111001111010011100010100001110101010111111010110111000100011010011010101110000011010011111111100111111000110000000100101111010000101110110001100110110001111010100110110100011011010001001011010111010101100011101010100100110010100111101000101101011101000111001110101001110000100001110001111110001010110110100010011001110000100100011000110111101101100010011100101001110111101011111011110011001111100010101010010100010011011010011001110111010011100001110000101100111010001011111110000111111100011000001100011110100010100111101000110100111101101011001010010101110001100110001110110100100001011000010110111110010101001101001110110100001010111010110111000010000000001100111110100001001000110001000000011001011111010000001110101110001001100101011110100001011000100101110100000010110000000000010100011011101111101001101111101111011001101110011110001011001110000111010100001011111011101001110100001110110110101111011101001111110011001100001000001101100010100000001111110011110010100011001001111000011100111111001110100110100100000010101110100011001110101111001101110011110000101000001101101101001011111010001000000111001101000011000001101011110111111111001110110111000111011111010101100011101001001001000000100001101101111000010001111011001111111100011111101000000110011100001110111101011011000101100111110110100001101001000110001010011111011010010111011011110111011110110111111001011001111000001000001100111111000110100110000011101000101100110110100011110001011011010010011100111001100110001001101100010010011100001011101101011101110001001110010010001111100110010011100111000010000101101111010101100011110110101010101111100101100010110000000011100000101001100100011101110000101101001010010010110111101110010110010100000001011000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001"; 10 | // load with `mzd_t *A = mzd_from_str(k, n, h);` 11 | #endif //SMALLSECRETLWE_DECODING_FILE_H -------------------------------------------------------------------------------- /tests/mceliece/prange/240.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../challenges/mce240.h" 5 | #include "prange.h" 6 | 7 | using ::testing::EmptyTestEventListener; 8 | using ::testing::InitGoogleTest; 9 | using ::testing::Test; 10 | using ::testing::TestEventListeners; 11 | using ::testing::TestInfo; 12 | using ::testing::TestPartResult; 13 | using ::testing::UnitTest; 14 | 15 | TEST(Stern, t240) { 16 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=0,.l=0,.c=0,.threads=1}; 17 | 18 | Prange prange{}; 19 | prange.from_string(h, s); 20 | prange.run(); 21 | EXPECT_EQ(prange.correct(), true); 22 | } 23 | 24 | TEST(Stern, t240c10) { 25 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=0,.l=0,.c=10,.threads=1}; 26 | 27 | Prange prange{}; 28 | prange.from_string(h, s); 29 | prange.run(); 30 | EXPECT_EQ(prange.correct(), true); 31 | } 32 | 33 | TEST(Stern, t240c40) { 34 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=0,.l=0,.c=40,.threads=1}; 35 | 36 | Prange prange{}; 37 | prange.from_string(h, s); 38 | prange.run(); 39 | EXPECT_EQ(prange.correct(), true); 40 | } 41 | 42 | int main(int argc, char **argv) { 43 | InitGoogleTest(&argc, argv); 44 | srand(time(NULL)); 45 | random_seed(rand()); 46 | return RUN_ALL_TESTS(); 47 | } -------------------------------------------------------------------------------- /tests/mceliece/prange/431.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../challenges/mce431.h" 5 | #include "prange.h" 6 | 7 | using ::testing::EmptyTestEventListener; 8 | using ::testing::InitGoogleTest; 9 | using ::testing::Test; 10 | using ::testing::TestEventListeners; 11 | using ::testing::TestInfo; 12 | using ::testing::TestPartResult; 13 | using ::testing::UnitTest; 14 | 15 | TEST(Prange, t431) { 16 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=0,.l=0,.c=0,.threads=1}; 17 | 18 | Prange prange{}; 19 | prange.from_string(h, s); 20 | prange.run(); 21 | EXPECT_EQ(prange.correct(), true); 22 | } 23 | 24 | TEST(Prange, t431c10) { 25 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=0,.l=0,.c=10,.threads=1}; 26 | Prange prange{}; 27 | prange.from_string(h, s); 28 | prange.run(); 29 | EXPECT_EQ(prange.correct(), true); 30 | } 31 | 32 | int main(int argc, char **argv) { 33 | InitGoogleTest(&argc, argv); 34 | srand(time(NULL)); 35 | random_seed(rand()); 36 | return RUN_ALL_TESTS(); 37 | } -------------------------------------------------------------------------------- /tests/mceliece/prange/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 2 | 3 | foreach(testfile ${TEST_SOURCES}) 4 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 5 | string(REPLACE ".cpp" "" file ${filename}) 6 | add_executable(mceliece_test_prange_${file} ${testfile}) 7 | target_compile_options(mceliece_test_prange_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 8 | target_link_libraries(mceliece_test_prange_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 9 | endforeach(testfile ${TEST_SOURCES}) 10 | 11 | if(USE_SCLANG) 12 | use_sclang_compiler() 13 | foreach(testfile ${TEST_SOURCES}) 14 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 15 | string(REPLACE ".cpp" "" file ${filename}) 16 | add_executable(sclang_mceliece_prange_${file} ${testfile}) 17 | target_compile_options(sclang_mceliece_prange_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 18 | target_link_libraries(sclang_mceliece_prange_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 19 | endforeach(testfile ${TEST_SOURCES}) 20 | use_host_compiler() 21 | endif() -------------------------------------------------------------------------------- /tests/mceliece/stern/1284.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../challenges/mce1284.h" 6 | #include "stern.h" 7 | #include "stern_im.h" 8 | #include "stern_mo.h" 9 | 10 | 11 | using ::testing::EmptyTestEventListener; 12 | using ::testing::InitGoogleTest; 13 | using ::testing::Test; 14 | using ::testing::TestEventListeners; 15 | using ::testing::TestInfo; 16 | using ::testing::TestPartResult; 17 | using ::testing::UnitTest; 18 | 19 | constexpr size_t loops = 10000; 20 | 21 | TEST(Stern, t1284t1p2) { 22 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=19,.c=0,.threads=1, .loops=loops}; 23 | static constexpr ConfigStern config{isdConfig, 8}; 24 | 25 | Stern stern{}; 26 | stern.from_string(h, s); 27 | stern.run(); 28 | EXPECT_EQ(stern.correct(), true); 29 | } 30 | 31 | TEST(Stern, t1284t1p2c20) { 32 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=21,.c=20,.threads=1, .loops=loops}; 33 | static constexpr ConfigStern config{isdConfig, 4}; 34 | 35 | Stern stern{}; 36 | stern.from_string(h, s); 37 | stern.run(); 38 | EXPECT_EQ(stern.correct(), true); 39 | } 40 | 41 | TEST(SternIM, t1284t1p2c20) { 42 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=21,.c=20,.threads=1, .loops=loops}; 43 | static constexpr ConfigStern configStern{isdConfig, 4}; 44 | static constexpr ConfigSternIM config{isdConfig, 2}; 45 | 46 | SternIM stern{}; 47 | stern.from_string(h, s); 48 | stern.run(); 49 | EXPECT_EQ(stern.correct(), true); 50 | } 51 | 52 | //TEST(SternMO, t1284t1p2) { 53 | // static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=17,.c=0,.threads=1, .loops=loops}; 54 | // static constexpr ConfigSternMO config{isdConfig, 2}; 55 | // 56 | // SternMO stern{}; 57 | // stern.from_string(h, s); 58 | // stern.run(); 59 | // EXPECT_EQ(stern.correct(), true); 60 | //} 61 | 62 | 63 | int main(int argc, char **argv) { 64 | InitGoogleTest(&argc, argv); 65 | ident(); 66 | srand(time(NULL)); 67 | random_seed(rand()); 68 | return RUN_ALL_TESTS(); 69 | } 70 | -------------------------------------------------------------------------------- /tests/mceliece/stern/240.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../challenges/mce240.h" 4 | #include "stern.h" 5 | #include "stern_im.h" 6 | #include "stern_mo.h" 7 | 8 | using ::testing::EmptyTestEventListener; 9 | using ::testing::InitGoogleTest; 10 | using ::testing::Test; 11 | using ::testing::TestEventListeners; 12 | using ::testing::TestInfo; 13 | using ::testing::TestPartResult; 14 | using ::testing::UnitTest; 15 | 16 | 17 | TEST(Stern, t240) { 18 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=13,.c=0,.threads=1}; 19 | static constexpr ConfigStern config{isdConfig, 16, }; 20 | 21 | Stern stern{}; 22 | stern.from_string(h, s); 23 | stern.run(); 24 | EXPECT_EQ(stern.correct(), true); 25 | } 26 | 27 | TEST(Stern, t240c20) { 28 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=13,.c=20,.threads=1}; 29 | static constexpr ConfigStern config{isdConfig, 16, }; 30 | 31 | Stern stern{}; 32 | stern.from_string(h, s); 33 | stern.run(); 34 | EXPECT_EQ(stern.correct(), true); 35 | } 36 | 37 | TEST(SternIM, t240) { 38 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=10,.c=0,.threads=1}; 39 | static constexpr ConfigStern configStern{isdConfig, 16}; 40 | static constexpr ConfigSternIM config{isdConfig, 2}; 41 | 42 | SternIM stern{}; 43 | stern.from_string(h, s); 44 | stern.run(); 45 | EXPECT_EQ(stern.correct(), true); 46 | } 47 | 48 | TEST(SternIM, t240c20) { 49 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=10,.c=20,.threads=1}; 50 | static constexpr ConfigStern configStern{isdConfig, 16}; 51 | static constexpr ConfigSternIM config{isdConfig, 2}; 52 | 53 | SternIM stern{}; 54 | stern.from_string(h, s); 55 | stern.run(); 56 | EXPECT_EQ(stern.correct(), true); 57 | } 58 | 59 | int main(int argc, char **argv) { 60 | InitGoogleTest(&argc, argv); 61 | srand(time(NULL)); 62 | random_seed(rand()); 63 | return RUN_ALL_TESTS(); 64 | } 65 | -------------------------------------------------------------------------------- /tests/mceliece/stern/431.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../challenges/mce431.h" 4 | #include "stern.h" 5 | #include "stern_im.h" 6 | #include "stern_mo.h" 7 | 8 | 9 | using ::testing::EmptyTestEventListener; 10 | using ::testing::InitGoogleTest; 11 | using ::testing::Test; 12 | using ::testing::TestEventListeners; 13 | using ::testing::TestInfo; 14 | using ::testing::TestPartResult; 15 | using ::testing::UnitTest; 16 | 17 | 18 | TEST(Stern, t431t1p2) { 19 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=13,.c=0,.threads=1}; 20 | static constexpr ConfigStern config{isdConfig, 16}; 21 | 22 | Stern stern{}; 23 | stern.from_string(h, s); 24 | stern.run(); 25 | EXPECT_EQ(stern.correct(), true); 26 | } 27 | 28 | TEST(Stern, t431t1p2c20) { 29 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=13,.c=20,.threads=1}; 30 | static constexpr ConfigStern config{isdConfig, 16}; 31 | 32 | Stern stern{}; 33 | stern.from_string(h, s); 34 | stern.run(); 35 | EXPECT_EQ(stern.correct(), true); 36 | } 37 | 38 | TEST(SternIM, t431t1p2) { 39 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=17,.c=0,.threads=1}; 40 | static constexpr ConfigStern configStern{isdConfig, 16}; 41 | static constexpr ConfigSternIM config{isdConfig, 3}; 42 | 43 | SternIM stern{}; 44 | stern.from_string(h, s); 45 | stern.run(); 46 | EXPECT_EQ(stern.correct(), true); 47 | } 48 | 49 | TEST(SternIM, t431t1p2c20) { 50 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=19,.c=20,.threads=1}; 51 | static constexpr ConfigStern configStern{isdConfig, 16}; 52 | static constexpr ConfigSternIM config{isdConfig, 3}; 53 | 54 | SternIM stern{}; 55 | stern.from_string(h, s); 56 | stern.run(); 57 | EXPECT_EQ(stern.correct(), true); 58 | } 59 | 60 | // to small. bruteforcing finds to many solutions 61 | //TEST(SternMO, t431t1p2) { 62 | // static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=19,.c=0,.threads=1}; 63 | // static constexpr ConfigSternMO config{isdConfig}; 64 | // 65 | // SternMO stern{}; 66 | // stern.from_string(h, s); 67 | // stern.run(); 68 | // EXPECT_EQ(stern.correct(), true); 69 | //} 70 | 71 | 72 | int main(int argc, char **argv) { 73 | InitGoogleTest(&argc, argv); 74 | ident(); 75 | srand(time(NULL)); 76 | random_seed(rand()); 77 | return RUN_ALL_TESTS(); 78 | } 79 | -------------------------------------------------------------------------------- /tests/mceliece/stern/640.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../challenges/mce640.h" 4 | #include "stern.h" 5 | #include "stern_im.h" 6 | #include "stern_mo.h" 7 | 8 | 9 | using ::testing::EmptyTestEventListener; 10 | using ::testing::InitGoogleTest; 11 | using ::testing::Test; 12 | using ::testing::TestEventListeners; 13 | using ::testing::TestInfo; 14 | using ::testing::TestPartResult; 15 | using ::testing::UnitTest; 16 | 17 | TEST(Stern, t640t1p2) { 18 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=16,.c=0,.threads=1}; 19 | static constexpr ConfigStern config{isdConfig, 16}; 20 | 21 | Stern stern{}; 22 | stern.from_string(h, s); 23 | stern.run(); 24 | EXPECT_EQ(stern.correct(), true); 25 | } 26 | 27 | TEST(Stern, t640t1p2c20) { 28 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=16,.c=20,.threads=1}; 29 | static constexpr ConfigStern config{isdConfig, 16}; 30 | 31 | Stern stern{}; 32 | stern.from_string(h, s); 33 | stern.run(); 34 | EXPECT_EQ(stern.correct(), true); 35 | } 36 | 37 | TEST(SternIM, t640t1p2) { 38 | static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=19,.c=0,.threads=1}; 39 | static constexpr ConfigStern configStern{isdConfig, 16}; 40 | static constexpr ConfigSternIM config{isdConfig, 2}; 41 | 42 | SternIM stern{}; 43 | stern.from_string(h, s); 44 | stern.run(); 45 | EXPECT_EQ(stern.correct(), true); 46 | } 47 | 48 | //TEST(SternMO, t640t1p2) { 49 | // static constexpr ConfigISD isdConfig{.n=n,.k=k,.q=2,.w=w,.p=2,.l=19,.c=0,.threads=1}; 50 | // static constexpr ConfigSternMO config{isdConfig, 4, 20, 14, 32}; 51 | // 52 | // SternMO stern{}; 53 | // stern.from_string(h, s); 54 | // stern.run(); 55 | // EXPECT_EQ(stern.correct(), true); 56 | //} 57 | 58 | 59 | int main(int argc, char **argv) { 60 | InitGoogleTest(&argc, argv); 61 | ident(); 62 | srand(time(NULL)); 63 | random_seed(rand()); 64 | return RUN_ALL_TESTS(); 65 | } 66 | -------------------------------------------------------------------------------- /tests/mceliece/stern/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 2 | 3 | foreach(testfile ${TEST_SOURCES}) 4 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 5 | string(REPLACE ".cpp" "" file ${filename}) 6 | add_executable(mceliece_test_stern_${file} ${testfile}) 7 | target_compile_options(mceliece_test_stern_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 8 | target_link_libraries(mceliece_test_stern_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 9 | endforeach(testfile ${TEST_SOURCES}) 10 | 11 | if(USE_SCLANG) 12 | use_sclang_compiler() 13 | foreach(testfile ${TEST_SOURCES}) 14 | file(RELATIVE_PATH filename ${CMAKE_CURRENT_SOURCE_DIR} ${testfile}) 15 | string(REPLACE ".cpp" "" file ${filename}) 16 | add_executable(sclang_mceliece_stern_${file} ${testfile}) 17 | target_compile_options(sclang_mceliece_stern_${file} PUBLIC ${COMPILE_TEST_FLAGS}) 18 | target_link_libraries(sclang_mceliece_stern_${file} ${LINK_TEST_FLAGS} ${TCMALLOC_LIBRARIES}) 19 | endforeach(testfile ${TEST_SOURCES}) 20 | use_host_compiler() 21 | endif() 22 | 23 | --------------------------------------------------------------------------------