def verify_p

bend-collections-laws-crypto@1.0.0.0 · spec/crypto/secp256k1/schnorr.bend:82

import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/schnorr.bend as Schnorr
import Base
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/curve.bend as CV

82# fail if r >= p or s >= n
83def verify_p(+one: Nat, +pk: List<&2, U32>, +m: List<&2, U32>, +sig: List<&2, U32>, mp: Maybe<&2, CV.SPoint>) -> Bool:
84  match mp:
85    case None{}: False{}
86    case Some{+pp}:
87      +r = CV.os2ip(CV.first(32n, sig))
88      +s = CV.os2ip(CV.after(32n, sig))
89      +e = Nat.mod(CV.os2ip(tagged(tag_challenge(), cat(CV.first(32n, sig), cat(pk, m)))), n(one))
90      verify_ok(one, r, s, e, pp, Bool.and(Nat.is_lt(r, p(one)), Nat.is_lt(s, n(one))))

Uses (18)

Used by (3)