nim-poseidon2/poseidon2/permutation.nim
2023-11-13 11:46:45 +01:00

19 lines
406 B
Nim

import ./types
import ./roundfun
# 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)