def recover
import bend-collections-laws-crypto@1.0.0.0/src/crypto/secp256k1/ecdsa.bend as Ecdsaimport Base
import bend-collections-laws-crypto@1.0.0.0/src/crypto/secp256k1/bytes.bend as B
271# the 65-byte uncompressed public key that signed the 32-byte hash, from a
272# 65-byte r || s || id with id in 0..3 (go-ethereum's crypto.Ecrecover;
273# Ethereum's precompile passes id = v - 27); None when r or s is not in
274# [1, n - 1], x(R) is not a field element on the curve, or Q is infinity.
275# High s is accepted, as the precompile does.
276def recover(+h: List<&2, U32>, +sig: List<&2, U32>) -> Maybe<&2, List<&2, U32>>:
277 recover_len(h, sig, Bool.and(B.has_len(32n, h), B.has_len(65n, sig)))