mirror of
https://github.com/codex-storage/nim-poseidon2.git
synced 2025-02-23 16:28:07 +00:00
19 lines
406 B
Nim
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)
|