~/bend-docscommunity

src/crypto/secp256k1/scalar.bend checks

raw source on the hub · import 0xd9a2fae439ac7ff9e21e0853948f94fe/src/crypto/secp256k1/scalar.bend as Scalar

2 imports
import Base
import ./limbs.bend as L

Definitions

def c source · line 11 · raw

List<&2, Nat>

2^256 - n, in radix 2^16

def reduce_u source · line 14 · raw

@xs:List<&2, Nat> -> List<&2, Nat>

def reduce source · line 17 · raw

@xs:List<&2, Nat> -> List<&2, Nat>

def zero source · line 20 · raw

List<&2, Nat>

def small source · line 23 · raw

@+k:Nat -> List<&2, Nat>

def one source · line 26 · raw

List<&2, Nat>

def add_u source · line 29 · raw

@a:List<&2, Nat> -> @b:List<&2, Nat> -> List<&2, Nat>

def add_b source · line 32 · raw

@a:List<&2, Nat> -> @b:List<&2, Nat> -> List<&2, Nat>

def add source · line 37 · raw

@a:List<&2, Nat> -> @b:List<&2, Nat> -> List<&2, Nat>

def neg_u source · line 42 · raw

@a:List<&2, Nat> -> List<&2, Nat>

def neg source · line 46 · raw

@a:List<&2, Nat> -> List<&2, Nat>

(one argument: nothing to look at first)

def mul_u source · line 49 · raw

@a:List<&2, Nat> -> @+b:List<&2, Nat> -> List<&2, Nat>

def mul_b source · line 52 · raw

@a:List<&2, Nat> -> @b:List<&2, Nat> -> List<&2, Nat>

def mul source · line 57 · raw

@a:List<&2, Nat> -> @b:List<&2, Nat> -> List<&2, Nat>

def pow_step source · line 62 · raw

@b:Nat -> @+x:List<&2, Nat> -> @+s:List<&2, Nat> -> List<&2, Nat>

def pow_go source · line 67 · raw

@+x:List<&2, Nat> -> @bits:List<&2, Nat> -> @+acc:List<&2, Nat> -> List<&2, Nat>

def pow source · line 73 · raw

@x:List<&2, Nat> -> @bits:List<&2, Nat> -> @+acc:List<&2, Nat> -> List<&2, Nat>

x is looked at first, so that on an unknown x nothing is unfolded

def inv_bits source · line 80 · raw

List<&2, Nat>

the bits of n - 2, most significant first (the proofs show they are those of 2^256 - 1 - (c + 1), c + 1 = 2^256 - n + 1)

def inv source · line 91 · raw

@+a:List<&2, Nat> -> List<&2, Nat>

a^(n - 2): the inverse of a nonzero a, 0 for 0

def is_zero source · line 94 · raw

@a:List<&2, Nat> -> Bool

def eq_b source · line 97 · raw

@a:List<&2, Nat> -> @b:List<&2, Nat> -> Bool

def eq source · line 102 · raw

@a:List<&2, Nat> -> @b:List<&2, Nat> -> Bool

def lt_n source · line 108 · raw

@a:List<&2, Nat> -> Bool

a < n, for 16 limbs below 2^16

def cm1 source · line 112 · raw

List<&2, Nat>

2^256 - n - 1

def is_high source · line 117 · raw

@a:List<&2, Nat> -> Bool

a > n / 2 (n is odd), i.e. 2 a >= n + 1 = 2^256 - cm1: the carry out of 2 a + cm1

def select source · line 120 · raw

@+b:Nat -> @x:List<&2, Nat> -> @y:List<&2, Nat> -> List<&2, Nat>