import constantine/math/arithmetic import poseidon2/types import poseidon2/roundfun import poseidon2/io export toBytes #------------------------------------------------------------------------------- # the Poseidon2 permutation (mutable, in-place version) proc permInplace*(x, y, z : var F) = linearLayer(x, y, z); for j in 0..3: externalRound(j, x, y, z) for j in 0..55: internalRound(j, x, y, z) for j in 4..7: externalRound(j, x, y, z) # the Poseidon2 permutation func perm*(xyz: S) : S = var (x,y,z) = xyz permInplace(x, y, z) return (x,y,z) #------------------------------------------------------------------------------- # sponge with rate=1 (capacity=2) func spongeWithRate1*(xs: openArray[F]) : F = let a = low(xs) let b = high(xs) let n = b-a+1 var s0 : F = zero var s1 : F = zero var s2 : F = zero for i in 0..