Fix bug in random generator. Correct a proof
This commit is contained in:
@ -3,13 +3,14 @@ let p, q, pubKey, privKey;
|
||||
class PubKey {
|
||||
constructor(p, q) {
|
||||
this.n = p * q;
|
||||
this.g = this.n + 1n;
|
||||
// this.g = this.n + 1n;
|
||||
}
|
||||
|
||||
encrypt(m) {
|
||||
// Compute g^m r^n mod n^2
|
||||
let r = random2048();
|
||||
|
||||
// Resample to avoid modulo bias.
|
||||
while (r >= this.n) {
|
||||
r = random2048();
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ function generate_bigint() {
|
||||
// Drop the MSB to force into range from above
|
||||
intRepr >>= 1n;
|
||||
|
||||
// Add 2^127 to force into range from below
|
||||
intRepr += 2n ** 127n;
|
||||
// Add 2^2047 to force into range from below
|
||||
intRepr += 2n ** 2047n;
|
||||
|
||||
return intRepr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user