noir
noir copied to clipboard
Investigate using `BigInt`'s with `< 4` limbs for `FieldElement`'s
Problem
bn254
FieldElement
's are defined in acir_field
pub type FieldElement = field_element::FieldElement<ark_bn254::Fr>;
Where field_element::FieldElement
wraps its argument and ensures it's a PrimeField
:
pub struct FieldElement<F: PrimeField>(F);
ark_bn254::Fr
is defined as:
pub type Fr = Fp256<MontBackend<FrConfig, 4>>;
Where Fp256
defines the contents (MontBackend..
defines the FpConfig
):
pub type Fp256<P> = Fp<P, 4>;
And Fp
:
pub struct Fp<P: FpConfig<N>, const N: usize>(pub BigInt<N>, _);
Is an N
-limbed BigInt
:
pub struct BigInt<const N: usize>(pub [u64; N]);
So our bn254
FieldElement
's are always represented by [u64; 4]
, even when their values are much smaller than u64::MAX
Happy Case
Investigate client-size memory savings and performance overhead of using a flexibly-sized big integer type instead of BigInt<N>
, e.g. this BigInt, which uses a Vec
of limbs
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
Nice-to-have
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response