def sign_loop

bend-collections-laws-crypto@1.0.0.0 · spec/crypto/secp256k1/ecdsa.bend:118

import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/ecdsa.bend as Ecdsa
import Base

118# step h, with the retry of step h.3 (K = HMAC_K(V || 0x00),
119# V = HMAC_K(V)) before the next V = HMAC_K(V); at most `fuel` candidates
120def sign_loop(fuel: Nat, +one: Nat, +e: Nat, +d: Nat, +k: List<&2, U32>, +v: List<&2, U32>, att: Attempt) -> Maybe<&2, List<&2, U32>>:
121  match fuel att:
122    case 0n Retry{}: None{}
123    case 0n Sig{sig}: Some{sig}
124    case 1n+f Retry{}:
125      +k2 = hmac(k, cat(v, [0]))
126      +v3 = hmac(k2, hmac(k2, v))
127      sign_loop(f, one, e, d, k2, v3, attempt(one, e, d, v3))
128    case 1n+f Sig{sig}: Some{sig}

Uses (8)

Used by (3)