Curve.pick_if: def of bend-collections-laws-crypto@1.0.0.0 Import: import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/curve.bend as Curve Lines 256-261 of bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/curve.bend: https://jend.leeeet.dev/read.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/curve.bend&start_line=256&end_line=261 import Base import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/field.bend as FS # y = (x^3 + 7)^((p + 1) / 4), then y or p - y to get the wanted parity; # no point when that y does not square to x^3 + 7 def pick_if(+p: Nat, +y: Nat, same: Bool) -> Nat: match same: case True{}: y case False{}: FS.mneg(p, y) Uses (3): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/field.bend&name=mneg