Skip to content

Commit

Permalink
Add comment about group check caching and use new deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Dec 4, 2020
1 parent faeb71d commit 0b72673
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions blscurve/blst/bls_sig_min_pubkey_size_pop.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
# approach, since the size of (PK_1, ..., PK_n, signature) is
# dominated by the public keys even for small n.

# We expose the same API as nim-blscurve
# We expose the same API as MIRACL
#
# Design:
# - We check public keys and signatures at deserialization
# - non-zero
# - in the correct subgroup
# The primitives called assume that input are already subgroup-checked
# and so do not call "KeyValidate" again in verification procs.

import
# Status libraries
Expand Down Expand Up @@ -166,7 +173,7 @@ func fromBytes*(
return false
let pa = cast[ptr array[L, byte]](raw[0].unsafeAddr)
obj.scalar.blst_scalar_from_bendian(pa[])
if obj.vec_is_zero():
if obj.vec_is_zero() or not obj.blst_sk_check():
return false
return true

Expand Down
1 change: 1 addition & 0 deletions blscurve/blst/blst_abi.nim
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ proc blst_bendian_from_scalar*(ret: var array[32, byte]; a: blst_scalar)
proc blst_scalar_from_lendian*(ret: var blst_scalar; a: array[32, byte])
proc blst_lendian_from_scalar*(ret: var array[32, byte]; a: blst_scalar)
proc blst_scalar_fr_check*(a: blst_scalar): CTBool
proc blst_sk_check*(a: blst_scalar): CTBool

# BLS12-381-specific Fr operations (Modulo curve order)
proc blst_fr_add*(ret: var blst_fr; a: blst_fr; b: blst_fr)
Expand Down

0 comments on commit 0b72673

Please sign in to comment.