Skip to content

Commit

Permalink
Fix #40 - Milagro can't parse integer with more than 381 used bits in…
Browse files Browse the repository at this point in the history
… a BIG_384 (but doesn't error)
  • Loading branch information
mratsim committed Mar 11, 2020
1 parent 49bed1a commit 532f668
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions blscurve/bls_signature_scheme.nim
Original file line number Diff line number Diff line change
Expand Up @@ -526,19 +526,14 @@ func keyGen*(ikm: openarray[byte], publicKey: var PublicKey, secretKey: var Secr

# 3. x = OS2IP(OKM) mod r
# 5. SK = x
debugecho "keyGen:"
if not secretKey.intVal.fromBytes(okm):
var dseckey: DBIG_384
if not dseckey.fromBytes(okm):
return false
{.noSideEffect.}:
debugecho " CURVE_Order: ", CURVE_Order.toHex()
BIG_384_mod(secretKey.intVal, CURVE_Order)

debugecho " seckey (mod): ", secretKey.toHex()
{.noSideEffect.}:
BIG_384_dmod(secretKey.intVal, dseckey, CURVE_Order)

# 4. xP = x * P
# 6. PK = point_to_pubkey(xP)
publicKey = privToPub(secretKey)

debugecho " seckey (exit): ", secretKey.toHex()

return true

0 comments on commit 532f668

Please sign in to comment.