Skip to content

Commit 64c077a

Browse files
committed
reexport
1 parent 99ec9b0 commit 64c077a

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

Nargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ compiler_version = ">=1.0.0"
77
[dependencies]
88
bignum = { git = "https://github.com/noir-lang/noir-bignum", tag = "v0.8.2" }
99
poseidon = { git = "https://github.com/noir-lang/poseidon", tag = "v0.1.1" }
10-

src/bigcurve_test.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ fn test_make_table() {
583583
unsafe {
584584
let P: BN254J = BN254J::one();
585585

586-
let mut transcript: [JTranscript<BN254_Fq>] = &[];
586+
let mut transcript: [JTranscript<BN254_Fq>] = @[];
587587
let T: curve_jac::PointTable<BN254_Fq> = curve_jac::PointTable::new(P);
588588
for i in 0..8 {
589589
transcript = transcript.push_back(T.transcript[i]);

src/curve_jac.nr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub struct CurveJ<B, BigCurve> {
2929
pub(crate) x: B,
3030
pub(crate) y: B,
3131
pub(crate) z: B,
32-
pub(crate) is_infinity: bool,
32+
pub is_infinity: bool,
3333
}
3434

3535
/// A transcript of a group operation in Jacobian coordinates.
@@ -67,9 +67,9 @@ where
6767
/// # Optimization
6868
/// If you have an array of `JTranscript` objects, you can convert them into `AffineTranscript` objects using only one modular inverse.
6969
pub struct AffineTranscript<B> {
70-
pub(crate) lambda: B,
71-
pub(crate) x3: B,
72-
pub(crate) y3: B,
70+
pub lambda: B,
71+
pub x3: B,
72+
pub y3: B,
7373
}
7474

7575
impl<B> AffineTranscript<B>
@@ -80,7 +80,7 @@ where
8080
AffineTranscript { lambda: B::zero(), x3: B::zero(), y3: B::zero() }
8181
}
8282

83-
pub(crate) unconstrained fn from_j(j_tx: JTranscript<B>) -> Self {
83+
pub unconstrained fn from_j(j_tx: JTranscript<B>) -> Self {
8484
AffineTranscript::from_jacobian_transcript([j_tx])[0]
8585
}
8686

@@ -279,11 +279,11 @@ where
279279
CurveJ { x: B::zero(), y: B::zero(), z: B::zero(), is_infinity: true }
280280
}
281281

282-
pub(crate) unconstrained fn sub(self, p2: Self) -> (Self, JTranscript<B>) {
282+
pub unconstrained fn sub(self, p2: Self) -> (Self, JTranscript<B>) {
283283
self.add(p2.neg())
284284
}
285285

286-
pub(crate) unconstrained fn add(self, p2: Self) -> (Self, JTranscript<B>) {
286+
pub unconstrained fn add(self, p2: Self) -> (Self, JTranscript<B>) {
287287
let X1 = self.x;
288288
let X2 = p2.x;
289289
let Y1 = self.y;

src/lib.nr

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ pub(crate) mod utils;
66
pub mod curves;
77

88
use bignum::BigNum;
9-
use bignum::bignum::evaluate_quadratic_expression;
109

11-
use crate::curve_jac::AffineTranscript;
1210
use crate::scalar_field::ScalarField;
1311
use std::ops::{Add, Neg, Sub};
1412
mod benchmarks;
1513

14+
// Re-exports for derive_curve_impl macro
15+
pub use bignum::bignum::evaluate_quadratic_expression;
16+
pub use curve_jac::{AffineTranscript, CurveJ};
17+
pub use utils::hash_to_curve::hash_to_curve;
18+
1619
/// Implements an elliptic curve over a prime field that is not the circuit's native field.
1720

1821
pub struct BigCurveParams<B> {
@@ -77,8 +80,8 @@ pub comptime fn derive_curve_impl(
7780
params: Quoted,
7881
) -> Quoted {
7982
let typ = struct_def.as_type();
80-
let CurveJ = quote { $crate::curve_jac::CurveJ };
81-
let AffineTranscript = quote { $crate::curve_jac::AffineTranscript };
83+
let CurveJ = quote { $crate::CurveJ };
84+
let AffineTranscript = quote { $crate::AffineTranscript };
8285

8386
quote {
8487
impl $crate::BigCurve<$field_type> for $typ {
@@ -168,7 +171,7 @@ pub comptime fn derive_curve_impl(
168171
}
169172

170173
fn hash_to_curve<let N: u32>(seed: [u8; N]) -> Self {
171-
let r = $crate::utils::hash_to_curve::hash_to_curve::<$field_type, N>(seed, $params.a, $params.b);
174+
let r = $crate::hash_to_curve::<$field_type, N>(seed, $params.a, $params.b);
172175
Self { x: r.0, y: r.1, is_infinity: false }
173176
}
174177

@@ -183,15 +186,15 @@ pub comptime fn derive_curve_impl(
183186
// Expensive witness generation! Avoid if possible
184187
impl std::ops::Add for $typ {
185188
fn add(self, other: Self) -> Self {
186-
let lhsJ = $crate::curve_jac::CurveJ::<$field_type, $typ>::from(self);
187-
let rhsJ = $crate::curve_jac::CurveJ::<$field_type, $typ>::from(other);
189+
let lhsJ = $crate::CurveJ::<$field_type, $typ>::from(self);
190+
let rhsJ = $crate::CurveJ::<$field_type, $typ>::from(other);
188191
let (result_jac, j_transcript) = unsafe { lhsJ.add(rhsJ) };
189-
let transcript = unsafe { $crate::curve_jac::AffineTranscript::from_j(j_transcript) };
192+
let transcript = unsafe { $crate::AffineTranscript::from_j(j_transcript) };
190193
if std::runtime::is_unconstrained() {
191194
$typ::from_coordinates(transcript.x3, transcript.y3, result_jac.is_infinity)
192195

193196
} else {
194-
$crate::add_with_hint::<$field_type, $typ>(self, other, transcript)
197+
$crate::add_with_hint::<$field_type, $typ>(self, other, transcript)
195198
}
196199
}
197200
}
@@ -207,12 +210,12 @@ pub comptime fn derive_curve_impl(
207210

208211
impl std::ops::Sub for $typ {
209212
fn sub(self, other: Self) -> Self {
210-
let lhsJ = $crate::curve_jac::CurveJ::<$field_type, $typ>::from(self);
211-
let rhsJ = $crate::curve_jac::CurveJ::<$field_type, $typ>::from(other);
213+
let lhsJ = $crate::CurveJ::<$field_type, $typ>::from(self);
214+
let rhsJ = $crate::CurveJ::<$field_type, $typ>::from(other);
212215
let (result_jac, j_transcript) = unsafe { lhsJ.sub(rhsJ) };
213-
216+
214217
// Convert back to affine coordinates using the transcript
215-
let transcript = unsafe { $crate::curve_jac::AffineTranscript::from_j(j_transcript) };
218+
let transcript = unsafe { $crate::AffineTranscript::from_j(j_transcript) };
216219
if std::runtime::is_unconstrained() {
217220
$typ::from_coordinates(transcript.x3, transcript.y3, result_jac.is_infinity)
218221
} else {
@@ -528,7 +531,7 @@ fn incomplete_subtract_with_hint<B: BigNum, P: BigCurve<B>>(
528531
P::from_coordinates(x3, y3, false)
529532
}
530533

531-
pub(crate) fn add_with_hint<B: BigNum, P: BigCurve<B>>(
534+
pub fn add_with_hint<B: BigNum, P: BigCurve<B>>(
532535
point: P,
533536
other: P,
534537
transcript: AffineTranscript<B>,
@@ -658,7 +661,7 @@ pub(crate) fn add_with_hint<B: BigNum, P: BigCurve<B>>(
658661
result
659662
}
660663

661-
pub(crate) fn sub_with_hint<B: BigNum, P: BigCurve<B>>(
664+
pub fn sub_with_hint<B: BigNum, P: BigCurve<B>>(
662665
point: P,
663666
other: P,
664667
transcript: AffineTranscript<B>,
@@ -807,7 +810,7 @@ pub(crate) fn sub_with_hint<B: BigNum, P: BigCurve<B>>(
807810
/// # Note
808811
///
809812
/// This function assumes the transcript is generated using unconstrained functions.
810-
pub(crate) fn mul_with_hint<let NScalarSlices: u32, let NTranscriptSlices: u32, B: BigNum, P: BigCurve<B>>(
813+
pub fn mul_with_hint<let NScalarSlices: u32, let NTranscriptSlices: u32, B: BigNum, P: BigCurve<B>>(
811814
point: P,
812815
scalar: ScalarField<NScalarSlices>,
813816
transcript: [AffineTranscript<B>; NTranscriptSlices],
@@ -888,7 +891,7 @@ fn msm_with_hint<let Size: u32, let NScalarSlices: u32, let NTranscriptSlices: u
888891
accumulator
889892
}
890893

891-
unconstrained fn get_mul_transcript<let NScalarSlices: u32, B: BigNum, P: BigCurve<B>>(
894+
pub unconstrained fn get_mul_transcript<let NScalarSlices: u32, B: BigNum, P: BigCurve<B>>(
892895
point: P,
893896
scalar: ScalarField<NScalarSlices>,
894897
) -> [AffineTranscript<B>; 6 + NScalarSlices * 5] {
@@ -897,7 +900,7 @@ unconstrained fn get_mul_transcript<let NScalarSlices: u32, B: BigNum, P: BigCur
897900
transcript
898901
}
899902

900-
fn evaluate_linear_expression<F: BigNum, Curve: BigCurve<F>, let NScalarSlices: u32, let NMuls: u32, let NAdds: u32>(
903+
pub fn evaluate_linear_expression<F: BigNum, Curve: BigCurve<F>, let NScalarSlices: u32, let NMuls: u32, let NAdds: u32>(
901904
mul_points: [Curve; NMuls],
902905
mul_scalars: [ScalarField<NScalarSlices>; NMuls],
903906
add_points: [Curve; NAdds],

0 commit comments

Comments
 (0)