def fBlaMka

bend-collections-laws-crypto@1.0.0.0 · spec/crypto/argon2/blamka.bend:21

import bend-collections-laws-crypto@1.0.0.0/spec/crypto/argon2/blamka.bend as Blamka
import Base
import bend-collections-laws-crypto@1.0.0.0/src/crypto/blake/blake2b/types.bend as T
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/blake/blake2b.bend as B

21# fBlaMka(x, y) = x + y + 2 * trunc(x) * trunc(y), modulo 2^64, where
22# trunc(x) * trunc(y) is the 64-bit product of the low 32 bits of x and y.
23def fBlaMka(x: T.Lane, y: T.Lane) -> T.Lane:
24  match x y:
25    case T.W{+xl, +xh} T.W{+yl, +yh}:
26      +p = lane_of(Nat.mul(U32.to_nat(xl), U32.to_nat(yl)))
27      B.add(B.add(T.W{xl, xh}, T.W{yl, yh}), B.add(p, p))

Uses (5)

Used by (9)