def pick_if

bend-collections-laws-crypto@1.0.0.0 · spec/crypto/secp256k1/curve.bend:256

import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/curve.bend as Curve
import Base
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/field.bend as FS

256# y = (x^3 + 7)^((p + 1) / 4), then y or p - y to get the wanted parity;
257# no point when that y does not square to x^3 + 7
258def pick_if(+p: Nat, +y: Nat, same: Bool) -> Nat:
259  match same:
260    case True{}: y
261    case False{}: FS.mneg(p, y)

Uses (3)

Used by (3)