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

fix: use ec library instead of standard library #13

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ authors = [""]
compiler_version = ">=0.37.0"

[dependencies]
ec = { tag = "v0.1.2", git = "https://github.com/noir-lang/ec" }
2 changes: 1 addition & 1 deletion src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod scalar_field;
mod test;
mod bjj;

use crate::scalar_field::ScalarField;
pub use crate::scalar_field::ScalarField;

pub struct Curve<Params> {
x: Field,
Expand Down
8 changes: 4 additions & 4 deletions src/scalar_field.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
///
/// N.B. ScalarField bit values are not constrained to be smaller than the TE curve group order.
/// ScalarField is used when performing scalar multiplications, where all operations wrap modulo the curve order
struct ScalarField<let N: u32> {
base4_slices: [u8; N],
skew: bool,
pub struct ScalarField<let N: u32> {
pub(crate) base4_slices: [u8; N],
pub(crate) skew: bool,
}

unconstrained fn get_wnaf_slices<let N: u32>(x: Field) -> ([u8; N], bool) {
Expand Down Expand Up @@ -148,7 +148,7 @@ impl<let N: u32> std::convert::Into<Field> for ScalarField<N> {

impl<let N: u32> ScalarField<N> {

fn new() -> Self {
pub fn new() -> Self {
Self { base4_slices: [0; N], skew: false }
}
fn get(self, idx: u64) -> u8 {
Expand Down
4 changes: 2 additions & 2 deletions src/test.nr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::bjj::BabyJubJubParams;
use crate::Curve;
use crate::scalar_field::ScalarField;
use std::ec::consts::te::baby_jubjub;
use std::ec::tecurve::affine::Point as TEPoint;

use ec::{consts::te::baby_jubjub, tecurve::affine::Point as TEPoint};

type BabyJubJub = Curve<BabyJubJubParams>;

Expand Down