-
Notifications
You must be signed in to change notification settings - Fork 15
Traits for Default Poseidon Parameters + Poseidon cleanup #22
Conversation
Note that ideally, the interface should use |
I will make more cleanup to this repo---the reference implementation puts the capacity at the beginning, while we put it at the end. Since it is better to avoid such differences, I will make a PR to change so, as well as adding some test numbers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! This PR is quite useful. Left a few comments
impl Fp256Parameters for TestFrParameters {} | ||
impl FftParameters for TestFrParameters { | ||
type BigInt = <FrParameters as FftParameters>::BigInt; | ||
const TWO_ADICITY: u32 = FrParameters::TWO_ADICITY; | ||
const TWO_ADIC_ROOT_OF_UNITY: Self::BigInt = FrParameters::TWO_ADIC_ROOT_OF_UNITY; | ||
} | ||
|
||
// This TestFrParameters is the same as the BLS12-381's Fr. | ||
// MODULUS = 52435875175126190479447740508185965837690552500527637822603658699938581184513 | ||
impl FpParameters for TestFrParameters { | ||
const MODULUS: BigInteger256 = FrParameters::MODULUS; | ||
const MODULUS_BITS: u32 = FrParameters::MODULUS_BITS; | ||
const CAPACITY: u32 = FrParameters::CAPACITY; | ||
const REPR_SHAVE_BITS: u32 = FrParameters::REPR_SHAVE_BITS; | ||
const R: BigInteger256 = FrParameters::R; | ||
const R2: BigInteger256 = FrParameters::R2; | ||
const INV: u64 = FrParameters::INV; | ||
const GENERATOR: BigInteger256 = FrParameters::GENERATOR; | ||
const MODULUS_MINUS_ONE_DIV_TWO: BigInteger256 = FrParameters::MODULUS_MINUS_ONE_DIV_TWO; | ||
const T: BigInteger256 = FrParameters::T; | ||
const T_MINUS_ONE_DIV_TWO: BigInteger256 = FrParameters::T_MINUS_ONE_DIV_TWO; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just set TestFrParameters
to be bls12_381::FrParameters
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this TestFrParameters would be slightly different in that it has:
impl PoseidonDefaultParameters for TestFrParameters
and I cannot add this to the existing struct bls12_381::FrParameters
that is in another crate (as this is the test mod).
} | ||
|
||
/// A field with Poseidon parameters associated | ||
pub trait PoseidonDefaultParametersField: PrimeField { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm the issue with this design is that we can only add an impl for PoseidonDefaultParametersField
in two places: the ark-curves crate corresponding to that field, or in this crate. Do you think there's a better way to do this?
Also, what does it mean for Parameters to be "default" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider this for a future PR. This PR probably will just provide a "default parameter retriever".
I think we need to make sure that a user can freely choose a different set of Poseidon parameters for, e.g., Marlin.
Thanks for the PR @weikengchen It might also be worth it to look at zcash/orchard#41 (or the more recent version of the code here) to see if we can port anything from their design (and if there are any incompatibilities) |
Co-authored-by: Pratyush Mishra <[email protected]>
Co-authored-by: Pratyush Mishra <[email protected]>
Co-authored-by: Pratyush Mishra <[email protected]>
Co-authored-by: Pratyush Mishra <[email protected]>
The PR is ready for a follow-up review. And I would consider this to be the preliminary API which we will make further improvements over. For example, we may need more optimization goals, as there can be a "balanced" version which takes into account that (1) one may use this same sponge in both Groth16 and Marlin, (2) Marlin has a different metrics, and (3) Groth16 is faster than Marlin. |
Description
This PR is from a branch named
add-rescue
, although this PR did not add Rescue.It consists of two parts:
This marks the first step toward the handling of Poseidon parameter generation.
More changes may show up in separate PRs. This one is long enough and should be concluded.
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the Github PR explorer