fep256.bend checks
raw source on the hub · import element-crypto@0.1.0.0/fep256.bend as Fep256
1 import
import Base
Types
type Fe source · line 11 · raw
Data
Fe@l0:U32 -> @l1:U32 -> @l2:U32 -> @l3:U32 -> @l4:U32 -> @l5:U32 -> @l6:U32 -> @l7:U32 -> @l8:U32 -> @l9:U32 -> @l10:U32 -> @l11:U32 -> @l12:U32 -> @l13:U32 -> @l14:U32 -> @l15:U32 -> @l16:U32 -> @l17:U32 -> @l18:U32 -> @l19:U32 -> Fe
Definitions
def zero source · line 14 · raw
Fe
def one source · line 18 · raw
Fe
1 in Montgomery form: R mod p.
def r2 source · line 22 · raw
Fe
R^2 mod p, which to_mont multiplies by.
def unit source · line 26 · raw
Fe
The plain integer 1 (from_mont multiplies by it).
def less_2p source · line 30 · raw
@x:Fe -> Fe
x below 4p back below 2p: 2p subtracted by a mask (no branch on a limb).
def canon source · line 77 · raw
@x:Fe -> Fe
x below 2p to its canonical value in [0, p): p subtracted by a mask.
def is_reduced source · line 124 · raw
@x:Fe -> Bool
x below p (x from bytes: limbs below 2^13): the borrow of x - p.
def add source · line 169 · raw
@a:Fe -> @b:Fe -> Fe
def sub source · line 217 · raw
@a:Fe -> @b:Fe -> Fe
a - b: a borrow chain, then 2p added by a mask when it borrowed (a - b + 2p is in (0, 2p) then); the carry out of the top limb is the R the borrow lent.
def mul source · line 305 · raw
@a:Fe -> @b:Fe -> Fe
a b R^-1 mod p, below 2p.
def sq source · line 411 · raw
@a:Fe -> Fe
a a R^-1 mod p, below 2p: each cross product once, against 2 a_j.
def select source · line 535 · raw
@+s:U32 -> @a:Fe -> @b:Fe -> Fe
Swap-free select: a when s is 0, b when s is 1 (a mask, no branch).
def or_limbs source · line 543 · raw
@x:Fe -> U32
def is_zero source · line 548 · raw
@+x:Fe -> Bool
def eq source · line 551 · raw
@+a:Fe -> @+b:Fe -> Bool
def to_mont source · line 554 · raw
@+x:Fe -> Fe
def from_mont source · line 558 · raw
@+x:Fe -> Fe
Out of Montgomery form, canonical.
def or0 source · line 561 · raw
@m:Maybe<&2, U32> -> U32
def byte_at source · line 568 · raw
@xs:List<&2, U32> -> @+n:Nat -> U32
def of_bytes source · line 573 · raw
@+bs:List<&2, U32> -> Fe
The plain value of big-endian bytes; only the last 32 count (callers check the length), so the value is below 2^256. Not reduced: see is_reduced.
def canon_bytes source · line 630 · raw
@x:Fe -> List<&2, U32>
A canonical plain value as 32 big-endian bytes.
def to_bytes source · line 668 · raw
@+x:Fe -> List<&2, U32>
A Montgomery-form value as its canonical big-endian bytes.
def pow_step source · line 671 · raw
@b:Bool -> @+x:Fe -> @a:Fe -> Fe
def pow_go source · line 678 · raw
@+x:Fe -> @bits:List<&2, Bool> -> @acc:Fe -> Fe
def inv_bits source · line 686 · raw
List<&2, Bool>
The bits of p - 2, top first (a public exponent: branching on it leaks nothing).
def inv source · line 690 · raw
@+x:Fe -> Fe
x^-1 = x^(p-2) (Fermat), in Montgomery form; 0 for 0.