zuse: make it clear where the secp jet should make explicit size checks
Well-behaved secp jets can now plausibly exit if they are given inputs
of the wrong size/range. Previously this was either not checked or the inputs
were silently truncated.
(into.j p)
scalar
::
+ ++ valid-hash
+ |= has=@
+ (lte (met 3 has) bytes)
+ ::
++ in-order
|= i=@
?& (gth i 0)
|= [hash=@ private-key=@]
^- @
?> (in-order private-key)
- :: hash is truncated to bytes
+ ?> (valid-hash hash)
=/ v (fil 3 bytes 1)
=/ k 0
=. k %+ hmc [bytes k]
++ ecdsa-raw-sign
|= [hash=@ private-key=@]
^- [r=@ s=@ y=@]
+ :: make-k and priv-to pub will validate inputs
=/ k (make-k hash private-key)
=/ rp (priv-to-pub k)
=* r x.rp
++ make-k
~/ %make
|= [hash=@uvI private-key=@]
+ :: checks sizes
(make-k:curve hash private-key)
++ priv-to-pub
|= private-key=@
+ :: checks sizes
(priv-to-pub:curve private-key)
::
++ ecdsa-raw-sign
|= [hash=@uvI private-key=@]
^- [v=@ r=@ s=@]
=/ c curve
+ :: raw-sign checks sizes
=+ (ecdsa-raw-sign.c hash private-key)
=/ rp=point [r y]
=/ s-high (gte (mul 2 s) n.domain.c)
^- point
?> (lte v.sig 3)
=/ c curve
- ?> (in-order.c hash)
+ ?> (valid-hash.c hash)
?> (in-order.c r.sig)
?> (in-order.c s.sig)
=/ x ?: (gte v.sig 2)
