Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: poseidon hash #388

Merged
merged 146 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
f7b5940
++
qalisander Oct 3, 2024
0b0cf3d
add original poseidon2 hash and vesta prime field
qalisander Oct 6, 2024
f305557
++
qalisander Oct 10, 2024
3369577
++
qalisander Oct 16, 2024
e41a63e
++
qalisander Oct 17, 2024
57d880c
++
qalisander Oct 18, 2024
76250c4
++
qalisander Oct 18, 2024
e897579
++
qalisander Oct 18, 2024
423503e
++
qalisander Oct 19, 2024
2563a53
++
qalisander Oct 19, 2024
264afa5
++
qalisander Oct 19, 2024
bd7e14c
compiles: port fields traits
qalisander Oct 19, 2024
5557280
compiles: port fp and biginteger
qalisander Oct 26, 2024
c10c78a
compiles: poseidon uses inhouse fields
qalisander Oct 26, 2024
1c76850
compiles: remove ark-ff-macros from deps
qalisander Oct 26, 2024
f62c298
++
qalisander Oct 26, 2024
a29a630
++
qalisander Oct 27, 2024
e8b722a
++
qalisander Oct 27, 2024
d80db6e
compiles: remove fft field
qalisander Oct 27, 2024
b8b7286
compiles: remove sqrt
qalisander Oct 27, 2024
f6ddc87
++
qalisander Oct 27, 2024
2d84081
++
qalisander Oct 27, 2024
e53769e
compiles: remove montgomery_backend abstraction
qalisander Oct 27, 2024
2500b1a
++
qalisander Oct 27, 2024
375d042
++
qalisander Oct 27, 2024
fc77caf
compiles: remove BasePrimeField associated type
qalisander Oct 27, 2024
d461172
++
qalisander Oct 27, 2024
745edcf
compiles: remove num_bigint from fields
qalisander Oct 27, 2024
2de8819
compiles
qalisander Oct 27, 2024
b489a8e
++
qalisander Oct 27, 2024
ed3835b
++
qalisander Oct 27, 2024
cfc6d91
++
qalisander Oct 27, 2024
181339c
++
qalisander Oct 27, 2024
617f141
++
qalisander Oct 27, 2024
b0b1b1d
++
qalisander Oct 27, 2024
343064a
++
qalisander Oct 27, 2024
e77c5d0
++
qalisander Oct 27, 2024
b5b4a3a
compiles: test not pass
qalisander Oct 27, 2024
74b86f7
++
qalisander Oct 27, 2024
886b955
++
qalisander Oct 27, 2024
1662190
compiles: test fails
qalisander Oct 28, 2024
090024b
compiles: test pass
qalisander Oct 28, 2024
c19dbf7
++
qalisander Oct 28, 2024
f86e6cc
++
qalisander Oct 28, 2024
8d43485
++
qalisander Oct 28, 2024
ffad719
++
qalisander Oct 28, 2024
b64460e
++
qalisander Oct 28, 2024
7275e0e
++
qalisander Oct 28, 2024
bb1eac4
compiles: remove ark-std
qalisander Oct 28, 2024
d71142d
++
qalisander Oct 28, 2024
5ace24d
++
qalisander Oct 28, 2024
d08b77c
store Residue in Fp
qalisander Oct 28, 2024
bdc066c
++
qalisander Oct 28, 2024
cd180c0
++
qalisander Oct 28, 2024
5dc350a
++
qalisander Oct 28, 2024
de78208
++
qalisander Oct 28, 2024
f5e64af
++
qalisander Oct 28, 2024
cb47ec0
++
qalisander Oct 29, 2024
c8f51ee
++
qalisander Oct 29, 2024
91d5b80
++
qalisander Oct 29, 2024
0771112
++
qalisander Oct 29, 2024
d822dce
++
qalisander Oct 29, 2024
1d47d65
parse from str number
qalisander Oct 29, 2024
5a85494
compiles: refactor
qalisander Oct 29, 2024
4a85e8e
introduce fp and uint macros
qalisander Oct 29, 2024
7110fec
++
qalisander Oct 29, 2024
13d1ee7
++
qalisander Oct 29, 2024
4826fb5
++
qalisander Oct 29, 2024
702052c
++
qalisander Oct 29, 2024
0fa044f
++
qalisander Oct 29, 2024
474711c
++
qalisander Oct 29, 2024
3d6f402
++
qalisander Oct 29, 2024
c082f78
add field docs
qalisander Oct 29, 2024
5ddd2bc
++
qalisander Oct 29, 2024
fbbf8f0
++
qalisander Oct 30, 2024
40f08a5
Merge remote-tracking branch 'origin/main' into finite-fields-2
qalisander Oct 30, 2024
3361106
++
qalisander Oct 30, 2024
5c3961c
fix compilation for wasm
qalisander Oct 30, 2024
444754a
Merge remote-tracking branch 'origin/main' into finite-fields-2
qalisander Oct 30, 2024
9f39a09
++
qalisander Oct 30, 2024
80ce59a
++
qalisander Oct 30, 2024
5c5251a
++
qalisander Oct 30, 2024
ddce394
++
qalisander Oct 30, 2024
a3b89ad
++
qalisander Oct 30, 2024
ed1ce9a
++
qalisander Oct 30, 2024
43b0483
++
qalisander Oct 30, 2024
fb0932f
++
qalisander Oct 30, 2024
dea904f
++
qalisander Oct 30, 2024
9c9e8fa
++
qalisander Oct 30, 2024
b80fb7a
++
qalisander Oct 30, 2024
bdce479
++
qalisander Oct 30, 2024
1b543c4
++
qalisander Oct 30, 2024
66c85cd
++
qalisander Oct 30, 2024
6cc65fc
++
qalisander Oct 31, 2024
e98a830
++
qalisander Oct 31, 2024
c964fb2
refactor
qalisander Oct 31, 2024
2998534
++
qalisander Nov 1, 2024
de698b0
++
qalisander Nov 1, 2024
387527e
++
qalisander Nov 1, 2024
f0c8e94
++
qalisander Nov 1, 2024
30430e6
refactor
qalisander Oct 31, 2024
24c1e6e
++
qalisander Nov 1, 2024
7e213d2
++
qalisander Nov 1, 2024
1df589e
++
qalisander Nov 1, 2024
79caad0
++
qalisander Nov 1, 2024
14d7546
++
qalisander Nov 1, 2024
2043e83
compiles: other fields for poseidon hash
qalisander Nov 2, 2024
6fa8405
move tests to instances
qalisander Nov 2, 2024
f8886b8
++
qalisander Nov 3, 2024
bdc94ad
++
qalisander Nov 3, 2024
3e7b37a
remove _mat_internal
qalisander Nov 3, 2024
f02c161
use generic params for vesta
qalisander Nov 3, 2024
9f580cc
from_str_hex
qalisander Nov 3, 2024
1147c88
use generic params for other fields
qalisander Nov 3, 2024
99cf440
Merge remote-tracking branch 'origin/main' into poseidon
qalisander Nov 7, 2024
080c60f
Merge remote-tracking branch 'origin/main' into poseidon
qalisander Nov 10, 2024
088b5c1
Merge branch 'main' into poseidon
bidzyyys Nov 20, 2024
639c720
++
qalisander Nov 20, 2024
f5d870a
remove computed constants
qalisander Nov 20, 2024
c48488d
add capacity param
qalisander Nov 22, 2024
850023d
turn poseidon into sponge hash function
qalisander Nov 22, 2024
9e8cdb5
++
qalisander Nov 24, 2024
2540dbb
++
qalisander Nov 25, 2024
745e3e4
add 64 bit field params + docs
qalisander Nov 25, 2024
dfeb6cc
++
qalisander Nov 27, 2024
231e739
++
qalisander Nov 27, 2024
a000bc5
Merge remote-tracking branch 'origin/main' into poseidon
qalisander Nov 27, 2024
b866627
++
qalisander Nov 27, 2024
33d13e1
++
qalisander Nov 27, 2024
0593bc4
++
qalisander Nov 27, 2024
f73cbae
++
qalisander Nov 27, 2024
c762be8
add convert_from_str_hex fuzz test
qalisander Nov 28, 2024
fcb1db5
++
qalisander Nov 28, 2024
72b01ec
++
qalisander Nov 29, 2024
8b2da4b
++
qalisander Dec 9, 2024
0213da1
++
qalisander Dec 9, 2024
5a4b537
introduce external_round & internal_round fns
qalisander Dec 9, 2024
93728e5
update CHANGELOG.md
qalisander Dec 9, 2024
3444407
Merge branch 'main' into poseidon
qalisander Dec 9, 2024
b29f99c
++
qalisander Dec 10, 2024
e31cd8c
add docks to poseidon instances
qalisander Dec 10, 2024
a125af0
add docks to poseidon instances
qalisander Dec 10, 2024
4c8f3e8
add docks to poseidon instances
qalisander Dec 10, 2024
7f31aed
Merge branch 'main' into poseidon
bidzyyys Dec 10, 2024
4d7070e
update CHANGELOG.md
qalisander Dec 10, 2024
215ddf4
Merge branch 'main' into poseidon
bidzyyys Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/crypto/src/poseidon2/instance/babybear.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#![allow(missing_docs)]
use crate::{
field::instance::FpBabyBear, fp_from_hex, poseidon2::params::PoseidonParams,
};

type Scalar = FpBabyBear;

/// Poseidon sponge hash parameters for [`FpBabyBear`] field instance.
pub struct BabyBear24Params;

#[rustfmt::skip]
impl PoseidonParams<Scalar> for BabyBear24Params {
impl PoseidonParams<FpBabyBear> for BabyBear24Params {
const T: usize = 24;
const D: u8 = 7;
const CAPACITY: usize = 1;
const ROUNDS_F: usize = 8;
const ROUNDS_P: usize = 21;
const MAT_INTERNAL_DIAG_M_1: &'static [Scalar] = &[
const MAT_INTERNAL_DIAG_M_1: &'static [FpBabyBear] = &[
fp_from_hex!("409133f0"),
fp_from_hex!("1667a8a1"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some resource we can use to to verify the correctness of the hex values used in all these instances?

Copy link
Member Author

@qalisander qalisander Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an implementation referenced in the whitepaper. This implementation is built by one of the authors of the hash

fp_from_hex!("06a6c7b6"),
Expand All @@ -40,7 +38,7 @@ impl PoseidonParams<Scalar> for BabyBear24Params {
fp_from_hex!("00d0ca4c"),
fp_from_hex!("36c0e388"),
];
const ROUND_CONSTANTS: &'static [&'static [Scalar]] = &[
const ROUND_CONSTANTS: &'static [&'static [FpBabyBear]] = &[
&[
fp_from_hex!("0fa20c37"),
fp_from_hex!("0795bb97"),
Expand Down
22 changes: 10 additions & 12 deletions lib/crypto/src/poseidon2/instance/bls12.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
#![allow(missing_docs)]
use crate::{
field::instance::FpBLS12, fp_from_hex, poseidon2::params::PoseidonParams,
};

type Scalar = FpBLS12;

/// Poseidon sponge hash parameters for [`FpBLS12`] field instance.
pub struct BLS2Params;

#[rustfmt::skip]
impl PoseidonParams<Scalar> for BLS2Params {
impl PoseidonParams<FpBLS12> for BLS2Params {
const T: usize = 2;
const D: u8 = 5;
const CAPACITY: usize = 1;
const ROUNDS_F: usize = 8;
const ROUNDS_P: usize = 56;
const MAT_INTERNAL_DIAG_M_1: &'static [Scalar] = &[
const MAT_INTERNAL_DIAG_M_1: &'static [FpBLS12] = &[
fp_from_hex!("0000000000000000000000000000000000000000000000000000000000000001"),
fp_from_hex!("0000000000000000000000000000000000000000000000000000000000000002"),
];
const ROUND_CONSTANTS: &'static [&'static [Scalar]] = &[
const ROUND_CONSTANTS: &'static [&'static [FpBLS12]] = &[
&[
fp_from_hex!("6267f5556c88257324c1c8b00d5871b2eba13cc39d72aa10dde6b69bc44c41c7"),
fp_from_hex!("30347723511438a085118166c68bf0c4f4ab5c10a2c55adb5cf87cc9e030f60f"),
Expand Down Expand Up @@ -278,20 +276,20 @@
];
}

pub struct BLS3Params;

Check warning on line 279 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / wasm32-unknown-unknown

missing documentation for a struct

Check warning on line 279 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] lib/crypto/src/poseidon2/instance/bls12.rs#L279

warning: missing documentation for a struct --> lib/crypto/src/poseidon2/instance/bls12.rs:279:1 | 279 | pub struct BLS3Params; | ^^^^^^^^^^^^^^^^^^^^^
Raw output
lib/crypto/src/poseidon2/instance/bls12.rs:279:1:w:warning: missing documentation for a struct
   --> lib/crypto/src/poseidon2/instance/bls12.rs:279:1
    |
279 | pub struct BLS3Params;
    | ^^^^^^^^^^^^^^^^^^^^^


__END__

Check warning on line 279 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / macos-latest / stable

missing documentation for a struct

Check warning on line 279 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

missing documentation for a struct

Check warning on line 279 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

missing documentation for a struct

Check warning on line 279 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / Check WASM binary

missing documentation for a struct

Check warning on line 279 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

missing documentation for a struct

Check warning on line 279 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / coverage

missing documentation for a struct

Check warning on line 279 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

missing documentation for a struct

Check warning on line 279 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / tests

missing documentation for a struct
0xNeshi marked this conversation as resolved.
Show resolved Hide resolved
#[rustfmt::skip]
impl PoseidonParams<Scalar> for BLS3Params {
impl PoseidonParams<FpBLS12> for BLS3Params {
const T: usize = 3;
const D: u8 = 5;
const CAPACITY: usize = 1;
const ROUNDS_F: usize = 8;
const ROUNDS_P: usize = 56;
const MAT_INTERNAL_DIAG_M_1: &'static [Scalar] = &[
const MAT_INTERNAL_DIAG_M_1: &'static [FpBLS12] = &[
fp_from_hex!("0000000000000000000000000000000000000000000000000000000000000001"),
fp_from_hex!("0000000000000000000000000000000000000000000000000000000000000001"),
fp_from_hex!("0000000000000000000000000000000000000000000000000000000000000002"),
];
const ROUND_CONSTANTS: &'static [&'static [Scalar]] = &[
const ROUND_CONSTANTS: &'static [&'static [FpBLS12]] = &[
&[
fp_from_hex!("6f007a551156b3a449e44936b7c093644a0ed33f33eaccc628e942e836c1a875"),
fp_from_hex!("360d7470611e473d353f628f76d110f34e71162f31003b7057538c2596426303"),
Expand Down Expand Up @@ -615,21 +613,21 @@
];
}

pub struct BLS4Params;

Check warning on line 616 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / wasm32-unknown-unknown

missing documentation for a struct

Check warning on line 616 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] lib/crypto/src/poseidon2/instance/bls12.rs#L616

warning: missing documentation for a struct --> lib/crypto/src/poseidon2/instance/bls12.rs:616:1 | 616 | pub struct BLS4Params; | ^^^^^^^^^^^^^^^^^^^^^
Raw output
lib/crypto/src/poseidon2/instance/bls12.rs:616:1:w:warning: missing documentation for a struct
   --> lib/crypto/src/poseidon2/instance/bls12.rs:616:1
    |
616 | pub struct BLS4Params;
    | ^^^^^^^^^^^^^^^^^^^^^


__END__

Check warning on line 616 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / macos-latest / stable

missing documentation for a struct

Check warning on line 616 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

missing documentation for a struct

Check warning on line 616 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable

missing documentation for a struct

Check warning on line 616 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / Check WASM binary

missing documentation for a struct

Check warning on line 616 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / features

missing documentation for a struct

Check warning on line 616 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / coverage

missing documentation for a struct

Check warning on line 616 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / Gas usage report

missing documentation for a struct

Check warning on line 616 in lib/crypto/src/poseidon2/instance/bls12.rs

View workflow job for this annotation

GitHub Actions / tests

missing documentation for a struct
#[rustfmt::skip]
impl PoseidonParams<Scalar> for BLS4Params {
impl PoseidonParams<FpBLS12> for BLS4Params {
const T: usize = 4;
const D: u8 = 5;
const CAPACITY: usize = 1;
const ROUNDS_F: usize = 8;
const ROUNDS_P: usize = 56;
const MAT_INTERNAL_DIAG_M_1: &'static [Scalar] = &[
const MAT_INTERNAL_DIAG_M_1: &'static [FpBLS12] = &[
fp_from_hex!("07564ad691bf01c8601d68757a561d224f00f313ada673ab83e6255fb4fd5b3d"),
fp_from_hex!("6184e3be38549f7c0850cd069b32f6decbfde312dd4b8c18349b1b3776a6eaa4"),
fp_from_hex!("419289088178ad742be6f78425c0156b6546a18fd338f0169937dea46cfb64d2"),
fp_from_hex!("3244cdec173b71a4659e2529b499362dac10cb2fd17562860c8bb9d0fd45b787"),
];
const ROUND_CONSTANTS: &'static [&'static [Scalar]] = &[
const ROUND_CONSTANTS: &'static [&'static [FpBLS12]] = &[
&[
fp_from_hex!("1a3bdcbfc11dabfb6ed0dd5f5a9b38191488bce9eecd811c10f9378b32db8c61"),
fp_from_hex!("52b733e857912fdd2248dc9638dd79b1ce18b285b27792238b44c2b23c0f5d5f"),
Expand Down
10 changes: 4 additions & 6 deletions lib/crypto/src/poseidon2/instance/bn256.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#![allow(missing_docs)]
use crate::{
field::instance::FpBN256, fp_from_hex, poseidon2::params::PoseidonParams,
};

type Scalar = FpBN256;

/// Poseidon sponge hash parameters for [`FpBN256`] field instance.
pub struct BN256Params;

#[rustfmt::skip]
impl PoseidonParams<Scalar> for BN256Params {
impl PoseidonParams<FpBN256> for BN256Params {
const T: usize = 3;
const D: u8 = 5;
const CAPACITY: usize = 1;
const ROUNDS_F: usize = 8;
const ROUNDS_P: usize = 56;
const MAT_INTERNAL_DIAG_M_1: &'static [Scalar] = &[
const MAT_INTERNAL_DIAG_M_1: &'static [FpBN256] = &[
fp_from_hex!(
"0000000000000000000000000000000000000000000000000000000000000001"
),
Expand All @@ -25,7 +23,7 @@ impl PoseidonParams<Scalar> for BN256Params {
"0000000000000000000000000000000000000000000000000000000000000002"
),
];
const ROUND_CONSTANTS: &'static [&'static [Scalar]] = &[
const ROUND_CONSTANTS: &'static [&'static [FpBN256]] = &[
&[
fp_from_hex!("1d066a255517b7fd8bddd3a93f7804ef7f8fcde48bb4c37a59a09a1a97052816"),
fp_from_hex!("29daefb55f6f2dc6ac3f089cebcc6120b7c6fef31367b68eb7238547d32c1610"),
Expand Down
10 changes: 4 additions & 6 deletions lib/crypto/src/poseidon2/instance/goldilocks.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
#![allow(missing_docs)]
use crate::{
field::instance::FpGoldiLocks, fp_from_hex,
poseidon2::params::PoseidonParams,
};

type Scalar = FpGoldiLocks;

/// Poseidon sponge hash parameters for [`FpGoldiLocks`] field instance.
pub struct Goldilocks12Params;

#[rustfmt::skip]
impl PoseidonParams<Scalar> for Goldilocks12Params {
impl PoseidonParams<FpGoldiLocks> for Goldilocks12Params {
const T: usize = 12;
const D: u8 = 7;
const CAPACITY: usize = 1;
const ROUNDS_F: usize = 8;
const ROUNDS_P: usize = 22;
const MAT_INTERNAL_DIAG_M_1: &'static [Scalar] = &[
const MAT_INTERNAL_DIAG_M_1: &'static [FpGoldiLocks] = &[
fp_from_hex!("c3b6c08e23ba9300"),
fp_from_hex!("d84b5de94a324fb6"),
fp_from_hex!("0d0c371c5b35b84f"),
Expand All @@ -29,7 +27,7 @@ impl PoseidonParams<Scalar> for Goldilocks12Params {
fp_from_hex!("0c6388b51545e883"),
fp_from_hex!("d27dbb6944917b60"),
];
const ROUND_CONSTANTS: &'static [&'static [Scalar]] = &[
const ROUND_CONSTANTS: &'static [&'static [FpGoldiLocks]] = &[
&[
fp_from_hex!("13dcf33aba214f46"),
fp_from_hex!("30b3b654a1da6d83"),
Expand Down
10 changes: 4 additions & 6 deletions lib/crypto/src/poseidon2/instance/pallas.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#![allow(missing_docs)]
use crate::{
field::instance::FpPallas, fp_from_hex, poseidon2::params::PoseidonParams,
};

type Scalar = FpPallas;

/// Poseidon sponge hash parameters for [`FpPallas`] field instance.
pub struct PallasParams;

#[rustfmt::skip]
impl PoseidonParams<Scalar> for PallasParams {
impl PoseidonParams<FpPallas> for PallasParams {
const T: usize = 3;
const D: u8 = 5;
const CAPACITY: usize = 1;
const ROUNDS_F: usize = 8;
const ROUNDS_P: usize = 56;
const MAT_INTERNAL_DIAG_M_1: &'static [Scalar] = &[
const MAT_INTERNAL_DIAG_M_1: &'static [FpPallas] = &[
fp_from_hex!(
"0000000000000000000000000000000000000000000000000000000000000001"
),
Expand All @@ -25,7 +23,7 @@ impl PoseidonParams<Scalar> for PallasParams {
"0000000000000000000000000000000000000000000000000000000000000002"
),
];
const ROUND_CONSTANTS: &'static [&'static [Scalar]] = &[
const ROUND_CONSTANTS: &'static [&'static [FpPallas]] = &[
&[
fp_from_hex!("360d7470611e473d353f628f76d110f34e71162f31003b7057538c2596426303"),
fp_from_hex!("2bab94d7ae222d135dc3c6c5febfaa314908ac2f12ebe06fbdb74213bf63188b"),
Expand Down
10 changes: 4 additions & 6 deletions lib/crypto/src/poseidon2/instance/vesta.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#![allow(missing_docs)]
use crate::{
field::instance::FpVesta, fp_from_hex, poseidon2::params::PoseidonParams,
};

type Scalar = FpVesta;

/// Poseidon sponge hash parameters for [`FpVesta`] field instance.
pub struct VestaParams;

#[rustfmt::skip]
impl PoseidonParams<Scalar> for VestaParams {
impl PoseidonParams<FpVesta> for VestaParams {
const T: usize = 3;
const D: u8 = 5;
const CAPACITY: usize = 1;
const ROUNDS_F: usize = 8;
const ROUNDS_P: usize = 56;
const MAT_INTERNAL_DIAG_M_1: &'static [Scalar] = &[
const MAT_INTERNAL_DIAG_M_1: &'static [FpVesta] = &[
fp_from_hex!(
"0000000000000000000000000000000000000000000000000000000000000001"
),
Expand All @@ -25,7 +23,7 @@ impl PoseidonParams<Scalar> for VestaParams {
"0000000000000000000000000000000000000000000000000000000000000002"
),
];
const ROUND_CONSTANTS: &'static [&'static [Scalar]] = &[
const ROUND_CONSTANTS: &'static [&'static [FpVesta]] = &[
&[
fp_from_hex!("360d7470611e473d353f628f76d110f34e71162f31003b7057538c2596426303"),
fp_from_hex!("2bab94d7ae222d135dc3c6c5febfaa314908ac2f12ebe06fbdb74213bf63188b"),
Expand Down
Loading