Skip to content

Commit

Permalink
moving poseidon constants to icicle/hash/poseidon_constants (#658)
Browse files Browse the repository at this point in the history
* moving poseidon constants to icicle/include/icicle/hash/poseidon_constants

* aligne path to new loation of poseidon constants

* small fix

* format

* rerun
  • Loading branch information
mickeyasa authored Nov 19, 2024
1 parent 1f1d5ef commit 3b4b6a0
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/docs/icicle/primitives/poseidon.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ So for Poseidon of arity 2 and input of size 1024 * 2, we would expect 1024 elem

Poseidon is extremely customizable and using different constants will produce different hashes, security levels and performance results.

We support pre-calculated and optimized constants for each of the [supported curves](../libraries#supported-curves-and-operations).The constants can be found [here](https://github.com/ingonyama-zk/icicle/tree/main/icicle/include/poseidon/constants) and are labeled clearly per curve `<curve_name>_poseidon.h`.
We support pre-calculated and optimized constants for each of the [supported curves](../libraries#supported-curves-and-operations).The constants can be found [here](https://github.com/ingonyama-zk/icicle/tree/main/icicle/include/icicle/hash/poseidon_constants) and are labeled clearly per curve `<curve_name>_poseidon.h`.

If you wish to generate your own constants you can use our python script which can be found [here](https://github.com/ingonyama-zk/icicle/tree/main/icicle/include/poseidon/constants/generate_parameters.py).
If you wish to generate your own constants you can use our python script which can be found [here](https://github.com/ingonyama-zk/icicle/tree/main/icicle/include/icicle/hash/poseidon_constants/generate_parameters.py).

Prerequisites:

Expand Down
16 changes: 8 additions & 8 deletions icicle/backend/cpu/src/hash/cpu_poseidon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@
#include <vector>

#if FIELD_ID == BN254
#include "poseidon/constants/bn254_poseidon.h"
#include "icicle/hash/poseidon_constants/bn254_poseidon.h"
using namespace poseidon_constants_bn254;
#elif FIELD_ID == BLS12_381
#include "poseidon/constants/bls12_381_poseidon.h"
#include "icicle/hash/poseidon_constants/bls12_381_poseidon.h"
using namespace poseidon_constants_bls12_381;
#elif FIELD_ID == BLS12_377
#include "poseidon/constants/bls12_377_poseidon.h"
#include "icicle/hash/poseidon_constants/bls12_377_poseidon.h"
using namespace poseidon_constants_bls12_377;
#elif FIELD_ID == BW6_761
#include "poseidon/constants/bw6_761_poseidon.h"
#include "icicle/hash/poseidon_constants/bw6_761_poseidon.h"
using namespace poseidon_constants_bw6_761;
#elif FIELD_ID == GRUMPKIN
#include "poseidon/constants/grumpkin_poseidon.h"
#include "icicle/hash/poseidon_constants/grumpkin_poseidon.h"
using namespace poseidon_constants_grumpkin;
#elif FIELD_ID == M31
#include "poseidon/constants/m31_poseidon.h"
#include "icicle/hash/poseidon_constants/m31_poseidon.h"
using namespace poseidon_constants_m31;
#elif FIELD_ID == BABY_BEAR
#include "poseidon/constants/babybear_poseidon.h"
#include "icicle/hash/poseidon_constants/babybear_poseidon.h"
using namespace poseidon_constants_babybear;
#elif FIELD_ID == STARK_252
#include "poseidon/constants/stark252_poseidon.h"
#include "icicle/hash/poseidon_constants/stark252_poseidon.h"
using namespace poseidon_constants_stark252;
#endif

Expand Down
4 changes: 2 additions & 2 deletions icicle/tests/test_hash_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ TEST_F(HashApiTest, MerkleTreeBasic)

TEST_F(HashApiTest, MerkleTreeZeroPadding)
{
// TODO add loop on devices (and change hash to one supported on gpu)
// TODO:add loop on devices (and change hash to one supported on gpu)
const int leaf_size = sizeof(uint32_t);
const int nof_leaves = 100;
uint32_t leaves[nof_leaves];
Expand Down Expand Up @@ -915,7 +915,7 @@ TEST_F(HashApiTest, MerkleTreeLarge)
// p = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001

#include "icicle/fields/field_config.h"
#include "poseidon/constants/bn254_poseidon.h"
#include "icicle/hash/poseidon_constants/bn254_poseidon.h"

using namespace field_config;
using namespace poseidon_constants_bn254;
Expand Down

0 comments on commit 3b4b6a0

Please sign in to comment.