~/bend-docscommunity

src/crypto/argon2/sub.bend source

src/crypto/argon2/sub.bend on the hub · documented module

# Generated by tools/generators/argon2_gen.py; do not edit by hand.import Baseimport ../blake/blake2b/types.bend as Timport ./types.bend as A# The 32 words of a row: lane n is words 2n (low) and 2n+1 (high).def row_words(v: T.State) -> List<&2,U32>:  match v:    case T.V{T.W{l0,h0},T.W{l1,h1},T.W{l2,h2},T.W{l3,h3},T.W{l4,h4},T.W{l5,h5},T.W{l6,h6},T.W{l7,h7},T.W{l8,h8},T.W{l9,h9},T.W{l10,h10},T.W{l11,h11},T.W{l12,h12},T.W{l13,h13},T.W{l14,h14},T.W{l15,h15}}:      [l0,h0,l1,h1,l2,h2,l3,h3,l4,h4,l5,h5,l6,h6,l7,h7,l8,h8,l9,h9,l10,h10,l11,h11,l12,h12,l13,h13,l14,h14,l15,h15]def app(xs: List<&2,U32>, ys: List<&2,U32>) -> List<&2,U32>:  List.append(&2, U32, xs, ys)# The 256 words of a block, row after row.def words(b: A.Block) -> List<&2,U32>:  match b:    case A.B{r0,r1,r2,r3,r4,r5,r6,r7}:      app(row_words(r0),app(row_words(r1),app(row_words(r2),app(row_words(r3),app(row_words(r4),app(row_words(r5),app(row_words(r6),app(row_words(r7),Nil{}))))))))# Sixteen lanes from 32 words, and the words left over.def row(ws: List<&2,U32>) -> T.State & List<&2,U32>:  match ws:    case w0 <> w1 <> w2 <> w3 <> w4 <> w5 <> w6 <> w7 <> w8 <> w9 <> w10 <> w11 <> w12 <> w13 <> w14 <> w15 <> w16 <> w17 <> w18 <> w19 <> w20 <> w21 <> w22 <> w23 <> w24 <> w25 <> w26 <> w27 <> w28 <> w29 <> w30 <> w31 <> rest:      (T.V{T.W{w0,w1},T.W{w2,w3},T.W{w4,w5},T.W{w6,w7},T.W{w8,w9},T.W{w10,w11},T.W{w12,w13},T.W{w14,w15},T.W{w16,w17},T.W{w18,w19},T.W{w20,w21},T.W{w22,w23},T.W{w24,w25},T.W{w26,w27},T.W{w28,w29},T.W{w30,w31}},rest)    case _: (T.V{T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0},T.W{0,0}},Nil{})def rows8_7(r0: T.State, r1: T.State, r2: T.State, r3: T.State, r4: T.State, r5: T.State, r6: T.State, p: T.State & List<&2,U32>) -> A.Block:  (r7,ws) = p  A.B{r0,r1,r2,r3,r4,r5,r6,r7}def rows8_6(r0: T.State, r1: T.State, r2: T.State, r3: T.State, r4: T.State, r5: T.State, p: T.State & List<&2,U32>) -> A.Block:  (r6,ws) = p  rows8_7(r0,r1,r2,r3,r4,r5,r6,row(ws))def rows8_5(r0: T.State, r1: T.State, r2: T.State, r3: T.State, r4: T.State, p: T.State & List<&2,U32>) -> A.Block:  (r5,ws) = p  rows8_6(r0,r1,r2,r3,r4,r5,row(ws))def rows8_4(r0: T.State, r1: T.State, r2: T.State, r3: T.State, p: T.State & List<&2,U32>) -> A.Block:  (r4,ws) = p  rows8_5(r0,r1,r2,r3,r4,row(ws))def rows8_3(r0: T.State, r1: T.State, r2: T.State, p: T.State & List<&2,U32>) -> A.Block:  (r3,ws) = p  rows8_4(r0,r1,r2,r3,row(ws))def rows8_2(r0: T.State, r1: T.State, p: T.State & List<&2,U32>) -> A.Block:  (r2,ws) = p  rows8_3(r0,r1,r2,row(ws))def rows8_1(r0: T.State, p: T.State & List<&2,U32>) -> A.Block:  (r1,ws) = p  rows8_2(r0,r1,row(ws))def rows8_0(p: T.State & List<&2,U32>) -> A.Block:  (r0,ws) = p  rows8_1(r0,row(ws))# The block of 256 words (the inverse of words).def rows8(ws: List<&2,U32>) -> A.Block:  rows8_0(row(ws))