agcd print update

This commit is contained in:
Sam Hadow 2025-05-18 23:01:41 +02:00
parent 9c352c22df
commit 34ab20c982
2 changed files with 9 additions and 0 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
/target
scripts/__pycache__/
*.txt
Cargo.lock

View File

@ -21,6 +21,11 @@ pub fn agcd(ciphertexts: Vec<Integer>, noise_bits: usize) -> Integer {
let q0 = &shortest_vector[0] / (Integer::from(1) << (noise_bits + 1));
println!("q0: {}", q0);
if q0 == 0 {
println!("Couldn't recover p.");
return Integer::from(0);
}
// 5. Find p
// compute r0 = x0 (mod q0)
// and p = (x0 r0)/q0.
@ -31,5 +36,7 @@ pub fn agcd(ciphertexts: Vec<Integer>, noise_bits: usize) -> Integer {
let p_guess = abs((x0 - r0) / q0);
println!("Recovered p: {}", p_guess);
println!("Approximate GCD with noise_bits={}: {}", noise_bits, p_guess);
p_guess
}