nim-poseidon2/tests/poseidon2/testReadme.nim
Mark Spanbroek 457b8623be Add usage example to Readme
- unit test that example code works
- fixes for said unit test
2023-11-13 11:46:45 +01:00

15 lines
411 B
Nim

# Test that the example code from the Readme.md compiles
{.hint[XDeclaredButNotUsed]: off.}
import poseidon2
let input = [1'u8, 2'u8, 3'u8] # some bytes that you want to hash
let digest: F = Sponge.digest(input) # a field element
let output: array[32, byte] = digest.toBytes
let left = Sponge.digest([1'u8, 2'u8, 3'u8])
let right = Sponge.digest([4'u8, 5'u8, 6'u8])
let combination = compress(left, right)