Schnorr.sign_r: def of bend-collections@1.0.0.0 Import: import bend-collections@1.0.0.0/spec/crypto/secp256k1/schnorr.bend as Schnorr Lines 130-138 of bend-collections@1.0.0.0/spec/crypto/secp256k1/schnorr.bend: https://jend.leeeet.dev/read.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/schnorr.bend&start_line=130&end_line=138 import Base import bend-collections@1.0.0.0/spec/crypto/secp256k1/field.bend as FS import bend-collections@1.0.0.0/spec/crypto/secp256k1/curve.bend as CV # R = k' G; k = k' if has_even_y(R), otherwise n - k'; # e = int(hash_challenge(bytes(R) || bytes(P) || m)) mod n def sign_r(+one: Nat, +d: Nat, +pb: List<&2, U32>, +m: List<&2, U32>, +k0: Nat, ra: CV.SAffine) -> Maybe<&2, List<&2, U32>>: match ra: case CV.SAffine{rx, +ry}: +k = even(n(one), ry, k0) +rb = bytes32(rx) +e = Nat.mod(CV.os2ip(tagged(tag_challenge(), cat(rb, cat(pb, m)))), n(one)) sign_fin(one, pb, m, cat(rb, bytes32(FS.madd(n(one), k, FS.mmul(n(one), e, d))))) Uses (16): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mod https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/curve.bend&name=SAffine https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/curve.bend&name=os2ip https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/field.bend&name=madd https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/field.bend&name=mmul https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/schnorr.bend&name=bytes32 https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/schnorr.bend&name=cat https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/schnorr.bend&name=even https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/schnorr.bend&name=n https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/schnorr.bend&name=sign_fin https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/schnorr.bend&name=tag_challenge https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/secp256k1/schnorr.bend&name=tagged