def step_r

bend-collections-laws-crypto@1.0.0.0 · proofs/crypto/secp256k1/scalarpow.bend:45

import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/secp256k1/scalarpow.bend as Scalarpow
import Base
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/field.bend as FS
import bend-collections-laws-crypto@1.0.0.0/src/crypto/secp256k1/scalar.bend as S
import bend-collections-laws-crypto@1.0.0.0/proofs/lib/nat.bend as N
import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/secp256k1/scalarops.bend as SO

45def step_r(+one: Nat, +h1: {one == 1n : Nat}, +x: List<&2, Nat>, +hx: {FS.reduced(one, FS.order(one), x) == True{} : Bool}, +acc: List<&2, Nat>, +ha: {FS.reduced(one, FS.order(one), acc) == True{} : Bool}, b: Nat, +hb: {Nat.is_lt(b, 2n) == True{} : Bool}) -> {FS.reduced(one, FS.order(one), S.pow_step(b, x, S.mul(acc, acc))) == True{} : Bool}:
46  match b:
47    case 0n:
48      SO.mul_r(one, h1, acc, acc, ha, ha)
49    case 1n:
50      SO.mul_r(one, h1, S.mul(acc, acc), x, SO.mul_r(one, h1, acc, acc, ha, ha), hx)
51    case 2n+ +k:
52      Empty.absurd({FS.reduced(one, FS.order(one), S.pow_step(2n+k, x, S.mul(acc, acc))) == True{} : Bool}, N.lt_zero_absurd(k, hb))

Uses (11)

Used by (2)