agcd print update
This commit is contained in:
parent
9c352c22df
commit
34ab20c982
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
scripts/__pycache__/
|
scripts/__pycache__/
|
||||||
|
*.txt
|
||||||
|
Cargo.lock
|
||||||
|
@ -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));
|
let q0 = &shortest_vector[0] / (Integer::from(1) << (noise_bits + 1));
|
||||||
println!("q0: {}", q0);
|
println!("q0: {}", q0);
|
||||||
|
|
||||||
|
if q0 == 0 {
|
||||||
|
println!("Couldn't recover p.");
|
||||||
|
return Integer::from(0);
|
||||||
|
}
|
||||||
|
|
||||||
// 5. Find p
|
// 5. Find p
|
||||||
// compute r0 = x0 (mod q0)
|
// compute r0 = x0 (mod q0)
|
||||||
// and p = (x0 − r0)/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);
|
let p_guess = abs((x0 - r0) / q0);
|
||||||
|
|
||||||
println!("Recovered p: {}", p_guess);
|
println!("Recovered p: {}", p_guess);
|
||||||
|
println!("Approximate GCD with noise_bits={}: {}", noise_bits, p_guess);
|
||||||
|
|
||||||
p_guess
|
p_guess
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user