approximate-gcd/README.md
2025-05-25 23:24:20 +02:00

1.9 KiB

Rust implementation for the approximate greatest common divisor (AGCD) problem using LLL algorithm.

commands

use the provided Makefile to compile the release version

approximate-gcd agcd <path to input file> [algorithm]

Input file must have the following format:

  • first non-comment line: number of noise bits (written in decimal)
  • all the other lines, one per line: the numbers Xi (written in decimal) to find the approximate GCD of
  • // can be used to comment a line, MUST be used at the begining of a new line and not at the end of a line containing a number

By default the algorithm used is L², the possibilities are:

  • 0: L² (external crate)
  • 1: BKZ with L² oracle
  • 2: DeepLLL (not working properly)
  • 3: L² (non external crate)

generating values

The script gen_values can be used to generate test values

usage: gen_values.py [-h] [--noise-bits NOISE_BITS] [--p-bits P_BITS] [--number NUMBER]

Generate test input for AGCD computation

options:
  -h, --help            show this help message and exit
  --noise-bits NOISE_BITS
                        Number of noise bits (default: 5)
  --p-bits P_BITS       Number of key bits (default: 16)
  --number NUMBER       Number of numbers to generate (default: 20)

the output can be directly written to a file

python gen_values.py [options] > input.txt

test script

usage: script.py [-h] [--noise-bits NOISE_BITS] [--p-bits P_BITS] [--min-values MIN_VALUES] [--max-values MAX_VALUES] [--trials TRIALS]

Test AGCD with varying number of test values.

options:
  -h, --help            show this help message and exit
  --noise-bits NOISE_BITS
                        Number of noise bits
  --p-bits P_BITS       Number of bits for p
  --min-values MIN_VALUES
                        Minimum number of test values
  --max-values MAX_VALUES
                        Maximum number of test values
  --trials TRIALS       Number of trials per setting