def verify_q

bend-collections@1.0.0.0 · spec/crypto/secp256k1/ecdsa.bend:178

import bend-collections@1.0.0.0/spec/crypto/secp256k1/ecdsa.bend as Ecdsa
import Base
import bend-collections@1.0.0.0/spec/crypto/secp256k1/curve.bend as CV

178# r and s in [1, n - 1]; strict verification also rejects s > n / 2
179def verify_q(+one: Nat, +h: List<&2, U32>, +sig: List<&2, U32>, strict: Bool, mq: Maybe<&2, CV.SPoint>) -> Bool:
180  match mq:
181    case None{}: False{}
182    case Some{+q}:
183      +r = CV.os2ip(CV.first(32n, sig))
184      +s = CV.os2ip(CV.after(32n, sig))
185      verify_ok(one, q, hash_scalar(one, h), r, s, Bool.and(Bool.and(scalar_ok(one, r), scalar_ok(one, s)), Bool.or(Bool.not(strict), Bool.not(Nat.is_lt(n(one), Nat.double(s))))))

Uses (18)

Used by (1)