def recover_len
bend-collections-laws-crypto@1.0.0.0 · spec/crypto/secp256k1/ecdsa.bend:231
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/ecdsa.bend as Ecdsa
import Base
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/curve.bend as CV
231def recover_len(+one: Nat, +h: List<&2, U32>, +sig: List<&2, U32>, ok: Bool) -> Maybe<&2, List<&2, U32>>:
232 match ok:
233 case True{}:
234 +r = CV.os2ip(CV.first(32n, sig))
235 +s = CV.os2ip(CV.first(32n, CV.after(32n, sig)))
236 +id = U32.to_nat(CV.head(CV.after(64n, sig)))
237 recover_ok(one, hash_scalar(one, h), r, s, id, Bool.and(Bool.and(scalar_ok(one, r), scalar_ok(one, s)), Nat.is_lt(id, 4n)))
238 case False{}: None{}