~/bend-docscommunity

src/crypto/blake/blake2b/lane.bend source

src/crypto/blake/blake2b/lane.bend on the hub · documented module

# Generated by tools/generators/blake2b_gen.py; do not edit by hand.import Baseimport ./types.bend as T# 64-bit addition modulo 2^64: the low halves add, their carry-out enters the high half.def add(a: T.Lane, b: T.Lane) -> T.Lane:  match a b:    case T.W{+al,ah} T.W{bl,bh}:      +lo = U32.add(al,bl)      T.W{lo,U32.add(U32.add(ah,bh),Bool.to_u32(U32.is_lt(lo,al)))}def xor(a: T.Lane, b: T.Lane) -> T.Lane:  match a b:    case T.W{al,ah} T.W{bl,bh}: T.W{U32.xor(al,bl),U32.xor(ah,bh)}# The four fixed right rotations of BLAKE2b.def rot32(a: T.Lane) -> T.Lane:  match a:    case T.W{lo,hi}: T.W{hi,lo}def rot24(a: T.Lane) -> T.Lane:  match a:    case T.W{+lo,+hi}:      T.W{U32.or(U32.shrn(lo,24n),U32.shln(hi,8n)),U32.or(U32.shrn(hi,24n),U32.shln(lo,8n))}def rot16(a: T.Lane) -> T.Lane:  match a:    case T.W{+lo,+hi}:      T.W{U32.or(U32.shrn(lo,16n),U32.shln(hi,16n)),U32.or(U32.shrn(hi,16n),U32.shln(lo,16n))}def rot63(a: T.Lane) -> T.Lane:  match a:    case T.W{+lo,+hi}:      T.W{U32.or(U32.shrn(hi,31n),U32.shln(lo,1n)),U32.or(U32.shrn(lo,31n),U32.shln(hi,1n))}