mirror of
https://github.com/logos-storage/nim-poseidon2.git
synced 2026-01-04 06:33:11 +00:00
Move compress() into its own module
This commit is contained in:
parent
457b8623be
commit
6fddd3e39e
@ -5,22 +5,16 @@ import poseidon2/types
|
||||
import poseidon2/permutation
|
||||
import poseidon2/io
|
||||
import poseidon2/sponge
|
||||
import poseidon2/compress
|
||||
|
||||
export sponge
|
||||
export compress
|
||||
export toBytes
|
||||
export elements
|
||||
export types
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# 2-to-1 compression
|
||||
func compress*(a, b : F) : F =
|
||||
var x = a
|
||||
var y = b
|
||||
var z : F ; setZero(z)
|
||||
permInplace(x, y, z)
|
||||
return x
|
||||
|
||||
func merkleRoot*(xs: openArray[F]) : F =
|
||||
let a = low(xs)
|
||||
let b = high(xs)
|
||||
|
||||
10
poseidon2/compress.nim
Normal file
10
poseidon2/compress.nim
Normal file
@ -0,0 +1,10 @@
|
||||
import ./types
|
||||
import ./permutation
|
||||
|
||||
# 2-to-1 compression
|
||||
func compress*(a, b : F) : F =
|
||||
var x = a
|
||||
var y = b
|
||||
var z : F = zero
|
||||
permInplace(x, y, z)
|
||||
return x
|
||||
Loading…
x
Reference in New Issue
Block a user