def verify_rs

bend-collections@1.0.0.0 · src/crypto/secp256k1/ecdsa.bend:179

import bend-collections@1.0.0.0/src/crypto/secp256k1/ecdsa.bend as Ecdsa
import Base
import bend-collections@1.0.0.0/src/crypto/secp256k1/scalar.bend as S
import bend-collections@1.0.0.0/src/crypto/secp256k1/point.bend as P

179# u1 = z w, u2 = r w with w = s^-1; R = [u1] G + [u2] Q must not be the
180# point at infinity and x(R) mod n must be r
181def verify_rs(+q: P.Point, +z: List<&2, Nat>, +r: List<&2, Nat>, +s: List<&2, Nat>) -> Bool:
182  +w = S.inv(s)
183  +rr = P.add(P.mul(S.mul(z, w), P.g()), P.mul(S.mul(r, w), q))
184  Bool.and(Bool.not(P.is_inf(rr)), S.eq(S.reduce(P.aff_x(P.to_affine(rr))), r))

Uses (16)

Used by (1)