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

Add Pallas and Vesta fields #690

Merged
merged 10 commits into from
Dec 6, 2023
4 changes: 4 additions & 0 deletions math/src/field/fields/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ pub mod mersenne31;
pub mod montgomery_backed_prime_fields;
/// Implementation of the Goldilocks Prime field (p = 2^448 - 2^224 - 1)
pub mod p448_goldilocks_prime_field;
/// Implemenation of Pallas field
pub mod pallas_field;
/// Implementation of the u64 Goldilocks Prime field (p = 2^64 - 2^32 + 1)
pub mod u64_goldilocks_field;
/// Implementation of prime fields over 64 bit unsigned integers.
pub mod u64_prime_field;
/// Implemenation of Vesta Prime field (p = 2^254 + 45560315531506369815346746415080538113)
mod vesta_field;
17 changes: 17 additions & 0 deletions math/src/field/fields/pallas_field.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::{
field::fields::montgomery_backed_prime_fields::{IsModulus, MontgomeryBackendPrimeField},
unsigned_integer::element::U256,
};

type PallasMontgomeryBackendPrimeField<T> = MontgomeryBackendPrimeField<T, 4>;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MontgomeryConfigPallas255PrimeField;
impl IsModulus<U256> for MontgomeryConfigPallas255PrimeField {
const MODULUS: U256 = U256::from_hex_unchecked(
"40000000000000000000000000000000224698fc094cf91b992d30ed00000001",
);
}

pub type Pallas255PrimeField =
PallasMontgomeryBackendPrimeField<MontgomeryConfigPallas255PrimeField>;
11 changes: 11 additions & 0 deletions math/src/field/fields/vesta_field.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::{
field::fields::montgomery_backed_prime_fields::IsModulus, unsigned_integer::element::U256,
};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MontgomeryConfigVesta255PrimeField;
impl IsModulus<U256> for MontgomeryConfigVesta255PrimeField {
const MODULUS: U256 = U256::from_hex_unchecked(
"0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001",
);
}
Loading