Skip to content

Commit

Permalink
Update weak_signature_generator.py
Browse files Browse the repository at this point in the history
  • Loading branch information
daedalus authored Sep 30, 2022
1 parent 3403139 commit c566377
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions weak_signature_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
pub_key = ecdsa.ecdsa.Public_key(gen, gen * secret)
priv_key = ecdsa.ecdsa.Private_key(pub_key, secret)

fixed_bits = random.randrange(2**bits, order)

if mode == 'MSB':
# generate n most significant bits, nonce must be less than order
yubikey_fixed_prefix = random.randrange(2**bits, order)
nonces = [yubikey_fixed_prefix + random.randrange(1, 2**bits) for i in range(n)]
nonces = [fixed_bits + random.randrange(1, 2 ** bits) for i in range(n)]
else:
# generate n least significant bits, nonce must be less than order
yubikey_fixed_sufix = random.randrange(1, 2**bits)
nonces = [random.randrange(2**bits, order) + yubikey_fixed_sufix for i in range(n)]
nonces = [random.randrange(2 ** bits, order) + fixed_bits for i in range(n)]

msgs = [random.randrange(1, order) for i in range(n)]
sigs = [priv_key.sign(msgs[i],nonces[i]) for i in range(n)]
Expand Down

0 comments on commit c566377

Please sign in to comment.