def absorb

bend-collections-laws-crypto@1.0.0.0 · src/crypto/poly1305/poly1305.bend:38

import bend-collections-laws-crypto@1.0.0.0/src/crypto/poly1305/poly1305.bend as Poly1305
import Base
import bend-collections-laws-crypto@1.0.0.0/src/crypto/poly1305/limbs.bend as L

38# The accumulator over 16-byte blocks (the last one possibly shorter); fuel
39# bounds the number of blocks. (A one-byte message is its own case only so
40# that a proof about a message b <> rest with rest unknown stays small.)
41def absorb(fuel: Nat, +msg: List<&2, U32>, +r: List<&2, U32>, h: List<&2, U32>) -> List<&2, U32>:
42  match fuel msg:
43    case 0n _: h
44    case 1n+k Nil{}: h
45    case 1n+k b <> Nil{}:
46      absorb(k, L.skip(16n, [b]), r, L.block(r, h, load(L.take(16n, [b]))))
47    case 1n+k b <> c <> rest:
48      absorb(k, L.skip(16n, b <> c <> rest), r, L.block(r, h, load(L.take(16n, b <> c <> rest))))

Uses (7)

Used by (4)