Skip to content

Commit

Permalink
expose size of the base field (lurk-lang#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
srinathsetty authored Nov 16, 2023
1 parent bb27f98 commit 264479a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/provider/bn256_grumpkin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ impl_traits!(
Bn256Compressed,
Bn256Point,
Bn256Affine,
"30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"
"30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001",
"30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47"
);

impl_traits!(
grumpkin,
GrumpkinCompressed,
GrumpkinPoint,
GrumpkinAffine,
"30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47"
"30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47",
"30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"
);

#[cfg(test)]
Expand Down
8 changes: 5 additions & 3 deletions src/provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ macro_rules! impl_traits {
$name_compressed:ident,
$name_curve:ident,
$name_curve_affine:ident,
$order_str:literal
$order_str:literal,
$base_str:literal
) => {
impl Group for $name::Point {
type Base = $name::Base;
Expand All @@ -228,12 +229,13 @@ macro_rules! impl_traits {
type TE = Keccak256Transcript<Self>;
type CE = CommitmentEngine<Self>;

fn get_curve_params() -> (Self::Base, Self::Base, BigInt) {
fn get_curve_params() -> (Self::Base, Self::Base, BigInt, BigInt) {
let A = $name::Point::a();
let B = $name::Point::b();
let order = BigInt::from_str_radix($order_str, 16).unwrap();
let base = BigInt::from_str_radix($base_str, 16).unwrap();

(A, B, order)
(A, B, order, base)
}
}

Expand Down
14 changes: 9 additions & 5 deletions src/provider/pasta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ macro_rules! impl_traits {
$name_compressed:ident,
$name_curve:ident,
$name_curve_affine:ident,
$order_str:literal
$order_str:literal,
$base_str:literal
) => {
impl Group for $name::Point {
type Base = $name::Base;
Expand All @@ -66,12 +67,13 @@ macro_rules! impl_traits {
type TE = Keccak256Transcript<Self>;
type CE = CommitmentEngine<Self>;

fn get_curve_params() -> (Self::Base, Self::Base, BigInt) {
fn get_curve_params() -> (Self::Base, Self::Base, BigInt, BigInt) {
let A = $name::Point::a();
let B = $name::Point::b();
let order = BigInt::from_str_radix($order_str, 16).unwrap();
let base = BigInt::from_str_radix($base_str, 16).unwrap();

(A, B, order)
(A, B, order, base)
}
}

Expand Down Expand Up @@ -201,15 +203,17 @@ impl_traits!(
PallasCompressedElementWrapper,
Ep,
EpAffine,
"40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001"
"40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001",
"40000000000000000000000000000000224698fc094cf91b992d30ed00000001"
);

impl_traits!(
vesta,
VestaCompressedElementWrapper,
Eq,
EqAffine,
"40000000000000000000000000000000224698fc094cf91b992d30ed00000001"
"40000000000000000000000000000000224698fc094cf91b992d30ed00000001",
"40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001"
);

#[cfg(test)]
Expand Down
6 changes: 4 additions & 2 deletions src/provider/secp_secq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ impl_traits!(
Secp256k1Compressed,
Secp256k1,
Secp256k1Affine,
"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"
"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"
);

impl_traits!(
secq256k1,
Secq256k1Compressed,
Secq256k1,
Secq256k1Affine,
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"
);

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ pub trait Group: Clone + Copy + Debug + Send + Sync + Sized + Eq + PartialEq {
/// A type that defines a commitment engine over scalars in the group
type CE: CommitmentEngineTrait<Self>;

/// Returns A, B, and the order of the group as a big integer
fn get_curve_params() -> (Self::Base, Self::Base, BigInt);
/// Returns A, B, the order of the group, the size of the base field as big integers
fn get_curve_params() -> (Self::Base, Self::Base, BigInt, BigInt);
}

/// A helper trait to absorb different objects in RO
Expand Down

0 comments on commit 264479a

Please sign in to comment.