Skip to content

Commit

Permalink
feat: home-baked FiniteField trait (#38)
Browse files Browse the repository at this point in the history
* feat: new `FiniteField` trait

Now everything compiles again. Will work to clean this all up and get all the tests to pass.

* fix: `GF101` tests pass

* fix: reimplement monty optimizations

* clean: udeps

---------

Co-authored-by: Waylon Jepsen <[email protected]>
  • Loading branch information
Autoparallel and 0xJepsen authored May 6, 2024
1 parent 96c8b66 commit d1c84eb
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 266 deletions.
38 changes: 2 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ repository ="https://github.com/thor314/ronkathon"
version ="0.1.0"

[dependencies]
anyhow = "1.0"
p3-field = { version="0.1.0", git="https://github.com/Plonky3/Plonky3.git" }
itertools = "0.12.0"
rand = "0.8"
serde = { version="1.0", default-features=false, features=["derive"] }
num-bigint= { version="0.4.3", default-features=false }
ark-std = { version = "0.4.0", default-features = false }
ark-bn254 = "0.4.0"
ark-poly = "0.4.0"
ark-ff = "0.4.0"
ark-ec = "0.4.0"
rand ="0.8"
serde ={ version="1.0", default-features=false, features=["derive"] }
num-bigint={ version="0.4.3", default-features=false }
ark-std ={ version="0.4.0", default-features=false }
ark-bn254 ="0.4.0"
ark-poly ="0.4.0"
ark-ff ="0.4.0"
ark-ec ="0.4.0"
20 changes: 9 additions & 11 deletions src/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ use std::{
ops::{Add, Neg},
};

use p3_field::{AbstractField, Field};

use crate::field::PlutoField;
use crate::field::{gf_101::GF101, FiniteField};

/// Elliptic curve in Weierstrass form: y^2 = x^3 + ax + b
pub struct Curve<F: Field> {
pub struct Curve<F: FiniteField> {
pub a: F,
pub b: F,
three: F,
Expand All @@ -17,7 +15,7 @@ pub struct Curve<F: Field> {

pub trait CurveParams: 'static + Copy + Clone + fmt::Debug + Default + Eq + Ord {
/// Integer field element type
type FieldElement: Field + Neg;
type FieldElement: FiniteField;
/// Order of this elliptic curve, i.e. number of elements in the scalar field.
const ORDER: u32;
/// Coefficient `a` in the Weierstrass equation of this elliptic curve.
Expand Down Expand Up @@ -47,14 +45,14 @@ pub trait CurveParams: 'static + Copy + Clone + fmt::Debug + Default + Eq + Ord
pub struct C101;

impl CurveParams for C101 {
type FieldElement = crate::field::PlutoField;
type FieldElement = GF101;

const EQUATION_A: Self::FieldElement = PlutoField::const_new(0);
const EQUATION_B: Self::FieldElement = PlutoField::const_new(3);
const EQUATION_A: Self::FieldElement = GF101::new(0);
const EQUATION_B: Self::FieldElement = GF101::new(3);
const GENERATOR: (Self::FieldElement, Self::FieldElement) = todo!();
const ORDER: u32 = PlutoField::ORDER_U32;
const THREE: Self::FieldElement = PlutoField::const_new(3);
const TWO: Self::FieldElement = PlutoField::const_new(2);
const ORDER: u32 = GF101::ORDER;
const THREE: Self::FieldElement = GF101::new(3);
const TWO: Self::FieldElement = GF101::new(2);
}

/// An Affine Coordinate Point on a Weierstrass elliptic curve
Expand Down
Loading

0 comments on commit d1c84eb

Please sign in to comment.