diff --git a/hash/cpu/bench/Poseidon2/Zikkurat/poseidon2.c b/hash/cpu/bench/Poseidon2/Zikkurat/poseidon2.c index fbcfd5d..cd82478 100644 --- a/hash/cpu/bench/Poseidon2/Zikkurat/poseidon2.c +++ b/hash/cpu/bench/Poseidon2/Zikkurat/poseidon2.c @@ -295,6 +295,32 @@ void permutation_example() { print_std( " w = ", tgt + 2*NLIMBS ); } +// ----------------------------------------------------------------------------- +// * single-threaded iterated permutation + +void permutation_iterated(int n) { + uint64_t state[3*NLIMBS]; + uint64_t tgt [3*NLIMBS]; + + bn128_r_mont_from_std( example_input_std , state ); + bn128_r_mont_from_std( example_input_std + NLIMBS , state + NLIMBS ); + bn128_r_mont_from_std( example_input_std + 2*NLIMBS , state + 2*NLIMBS ); + + for(int i=0; i:\n"); printf("$ poseidon2 :\n"); + printf("$ poseidon2 :\n"); exit(-1); break; } - printf("calculating Poseidon2 Merkle root with depth=%d on %d threads...\n",mtDepth,nThreads); - if (nThreads == 1) { - merkle_root_example(mtDepth); + if (mtDepth < 32) { + printf("calculating Poseidon2 Merkle root with depth=%d on %d threads...\n",mtDepth,nThreads); + if (nThreads == 1) { + merkle_root_example(mtDepth); + } + else { + merkle_root_multithread(mtDepth, nThreads); + } } else { - merkle_root_multithread(mtDepth, nThreads); + int nIters = mtDepth; + printf("calculating Poseidon2 permutation iterated %d times on 1 threads...\n",nIters); + permutation_iterated(nIters); } printf("\n");