Skip to content

Commit

Permalink
fix: bump minimum noir version to 0.35.0 and address privacy warnings (
Browse files Browse the repository at this point in the history
…#24)

* feat: address privacy warnings

* chore: bump msnv to 0.35.0
  • Loading branch information
TomAFrench authored Oct 3, 2024
1 parent 615937a commit fc53098
Show file tree
Hide file tree
Showing 38 changed files with 153 additions and 124 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
toolchain: [nightly, 0.34.0]
toolchain: [nightly, 0.35.0]
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Install Nargo
uses: noir-lang/[email protected]
with:
toolchain: 0.34.0
toolchain: 0.35.0

- name: Run formatter
run: nargo fmt --check
2 changes: 1 addition & 1 deletion Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
name = "bignum"
type = "lib"
authors = [""]
compiler_version = ">=0.34.0"
compiler_version = ">=0.35.0"

[dependencies]
9 changes: 8 additions & 1 deletion src/bignum_test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ use crate::runtime_bignum::BigNumInstance;
use crate::BigNumTrait;

struct Test2048Params{}

// See https://github.com/noir-lang/noir/issues/6172
#[test]
fn silence_warning() {
let _ = Test2048Params {};
}

impl RuntimeBigNumParamsTrait<18> for Test2048Params {
fn modulus_bits() -> u32 {
2048
Expand Down Expand Up @@ -85,7 +92,6 @@ impl BigNumParamsTrait<18> for Test2048Params {
}

type Fq = BigNum<3, BNParams>;
type Fqq = BigNum<18, Test2048Params>;

fn test_eq<BigNum, let N: u32>(_: BigNum, __: [Field; N]) where BigNum: BigNumTrait {
let a = BigNum::__derive_from_seed([1, 2, 3, 4]);
Expand Down Expand Up @@ -635,3 +641,4 @@ fn test_expressions() {
let wx_constrained = w * x;
assert(wx_constrained.limbs == wx.limbs);
}

2 changes: 1 addition & 1 deletion src/fields/U1024.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct U1024Params {}
pub struct U1024Params {}
impl RuntimeBigNumParamsTrait<9> for U1024Params {
fn modulus_bits() -> u32 {
1025
Expand Down
2 changes: 1 addition & 1 deletion src/fields/U2048.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct U2048Params {}
pub struct U2048Params {}
impl RuntimeBigNumParamsTrait<18> for U2048Params {
fn modulus_bits() -> u32 {
2049
Expand Down
2 changes: 1 addition & 1 deletion src/fields/U256.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct U256Params {}
pub struct U256Params {}
impl RuntimeBigNumParamsTrait<3> for U256Params {
fn modulus_bits() -> u32 {
257
Expand Down
2 changes: 1 addition & 1 deletion src/fields/U384.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct U384_Params {}
pub struct U384_Params {}
impl RuntimeBigNumParamsTrait<4> for U384_Params {
fn modulus_bits() -> u32 {
385
Expand Down
2 changes: 1 addition & 1 deletion src/fields/U4096.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct U4096Params {}
pub struct U4096Params {}
impl RuntimeBigNumParamsTrait<35> for U4096Params {
fn modulus_bits() -> u32 {
4097
Expand Down
2 changes: 1 addition & 1 deletion src/fields/U512.nr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::utils::u60_representation::U60Repr;
// a / b = c

// b * c + (rem < modulus) = a
struct U512Params {}
pub struct U512Params {}
impl RuntimeBigNumParamsTrait<5> for U512Params {
fn modulus_bits() -> u32 {
513
Expand Down
2 changes: 1 addition & 1 deletion src/fields/U768.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct U768Params {}
pub struct U768Params {}
impl RuntimeBigNumParamsTrait<13> for U768Params {
fn modulus_bits() -> u32 {
1537
Expand Down
2 changes: 1 addition & 1 deletion src/fields/U8192.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct U8192Params {}
pub struct U8192Params {}
impl RuntimeBigNumParamsTrait<69> for U8192Params {
fn modulus_bits() -> u32 {
8193
Expand Down
2 changes: 1 addition & 1 deletion src/fields/bls12_377Fq.nr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct BLS12_377_Fq_Params {}
pub struct BLS12_377_Fq_Params {}
impl RuntimeBigNumParamsTrait<4> for BLS12_377_Fq_Params {
fn modulus_bits() -> u32 {
377
Expand Down
2 changes: 1 addition & 1 deletion src/fields/bls12_377Fr.nr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct BLS12_377_Fr_Params {}
pub struct BLS12_377_Fr_Params {}
impl RuntimeBigNumParamsTrait<3> for BLS12_377_Fr_Params {
fn modulus_bits() -> u32 {
253
Expand Down
2 changes: 1 addition & 1 deletion src/fields/bls12_381Fq.nr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct BLS12_381_Fq_Params {}
pub struct BLS12_381_Fq_Params {}
impl RuntimeBigNumParamsTrait<4> for BLS12_381_Fq_Params {
fn modulus_bits() -> u32 {
381
Expand Down
2 changes: 1 addition & 1 deletion src/fields/bls12_381Fr.nr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct BLS12_381_Fr_Params {}
pub struct BLS12_381_Fr_Params {}
impl RuntimeBigNumParamsTrait<3> for BLS12_381_Fr_Params {
fn modulus_bits() -> u32 {
255
Expand Down
2 changes: 1 addition & 1 deletion src/fields/bn254Fq.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct BNParams {}
pub struct BNParams {}
impl RuntimeBigNumParamsTrait<3> for BNParams {
fn modulus_bits() -> u32 {
254
Expand Down
2 changes: 1 addition & 1 deletion src/fields/ed25519Fq.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::BigNumParamsTrait as BigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct ED25519_Fq_Params {}
pub struct ED25519_Fq_Params {}
impl RuntimeBigNumParamsTrait<3> for ED25519_Fq_Params {
fn modulus_bits() -> u32 {
255
Expand Down
2 changes: 1 addition & 1 deletion src/fields/ed25519Fr.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct ED25519_Fr_Params {}
pub struct ED25519_Fr_Params {}
impl RuntimeBigNumParamsTrait<3> for ED25519_Fr_Params {
fn modulus_bits() -> u32 {
253
Expand Down
4 changes: 2 additions & 2 deletions src/fields/mnt4_753Fq.nr
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
//! * G2 curve equation: y^2 = x^3 + Ax + B, where
//! * A = Fq2 = (a * NON_RESIDUE, 0)
//! * B = Fq2(0, b * NON_RESIDUE)
//! * NON_RESIDUE = 13 is the quadratic non-residue used to construct the
//! * NON_RESIDUE = 13 is the quadratic non-residue used to conpub struct the
//! extension field Fq2
use crate::BigNumParamsTrait;
use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct MNT4_753_Fq_Params {}
pub struct MNT4_753_Fq_Params {}
impl RuntimeBigNumParamsTrait<7> for MNT4_753_Fq_Params {
fn modulus_bits() -> u32 {
753
Expand Down
4 changes: 2 additions & 2 deletions src/fields/mnt4_753Fr.nr
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
//! * G2 curve equation: y^2 = x^3 + Ax + B, where
//! * A = Fq2 = (a * NON_RESIDUE, 0)
//! * B = Fq2(0, b * NON_RESIDUE)
//! * NON_RESIDUE = 13 is the quadratic non-residue used to construct the
//! * NON_RESIDUE = 13 is the quadratic non-residue used to conpub struct the
//! extension field Fq2
use crate::BigNumParamsTrait;
use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct MNT4_753_Fr_Params {}
pub struct MNT4_753_Fr_Params {}
impl RuntimeBigNumParamsTrait<7> for MNT4_753_Fr_Params {
fn modulus_bits() -> u32 {
753
Expand Down
4 changes: 2 additions & 2 deletions src/fields/mnt6_753Fq.nr
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
//! * G2 curve equation: y^2 = x^3 + Ax + B, where
//! * A = Fq3(0, 0, a)
//! * B = Fq3(b * NON_RESIDUE, 0, 0)
//! * NON_RESIDUE = 11 is the cubic non-residue used to construct the
//! * NON_RESIDUE = 11 is the cubic non-residue used to conpub struct the
//! extension field Fq3
use crate::BigNumParamsTrait;
use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct MNT6_753_Fq_Params {}
pub struct MNT6_753_Fq_Params {}
impl RuntimeBigNumParamsTrait<7> for MNT6_753_Fq_Params {
fn modulus_bits() -> u32 {
753
Expand Down
4 changes: 2 additions & 2 deletions src/fields/mnt6_753Fr.nr
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
//! * G2 curve equation: y^2 = x^3 + Ax + B, where
//! * A = Fq3(0, 0, a)
//! * B = Fq3(b * NON_RESIDUE, 0, 0)
//! * NON_RESIDUE = 11 is the cubic non-residue used to construct the
//! * NON_RESIDUE = 11 is the cubic non-residue used to conpub struct the
//! extension field Fq3
use crate::BigNumParamsTrait;
use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct MNT6_753_Fr_Params {}
pub struct MNT6_753_Fr_Params {}
impl RuntimeBigNumParamsTrait<7> for MNT6_753_Fr_Params {
fn modulus_bits() -> u32 {
753
Expand Down
74 changes: 34 additions & 40 deletions src/fields/mod.nr
Original file line number Diff line number Diff line change
@@ -1,75 +1,69 @@
mod bn254Fq;
mod bls12_377Fq;
mod bls12_377Fr;
mod bls12_381Fr;
mod bls12_381Fq;
mod ed25519Fq;
mod ed25519Fr;
mod mnt4_753Fq;
mod mnt4_753Fr;
mod mnt6_753Fq;
mod mnt6_753Fr;
mod pallasFq;
mod pallasFr;
mod secp256k1Fq;
mod secp256k1Fr;
mod secp256r1Fq;
mod secp256r1Fr;
mod secp384r1Fq;
mod secp384r1Fr;
mod vestaFq;
mod vestaFr;
mod U256;
mod U384;
mod U512;
mod U768;
mod U1024;
mod U2048;
mod U4096;
mod U8192;
pub mod bn254Fq;
pub mod bls12_377Fq;
pub mod bls12_377Fr;
pub mod bls12_381Fr;
pub mod bls12_381Fq;
pub mod ed25519Fq;
pub mod ed25519Fr;
pub mod mnt4_753Fq;
pub mod mnt4_753Fr;
pub mod mnt6_753Fq;
pub mod mnt6_753Fr;
pub mod pallasFq;
pub mod pallasFr;
pub mod secp256k1Fq;
pub mod secp256k1Fr;
pub mod secp256r1Fq;
pub mod secp256r1Fr;
pub mod secp384r1Fq;
pub mod secp384r1Fr;
pub mod vestaFq;
pub mod vestaFr;
pub mod U256;
pub mod U384;
pub mod U512;
pub mod U768;
pub mod U1024;
pub mod U2048;
pub mod U4096;
pub mod U8192;

use crate::BigNum;
pub use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::fields::bn254Fq::BNParams;

/**
* @brief Parameter definitions for generic fields of varying bit lengths
* (these can be used when defining modular fields where the
* modulus is a witness value and cannot be predefined
* e.g. 2048-bit RSA)
**/
struct Params512 {}
pub struct Params512 {}
impl RuntimeBigNumParamsTrait<5> for Params512 {
fn modulus_bits() -> u32 {
512
}
}
struct Params768 {}
pub struct Params768 {}
impl RuntimeBigNumParamsTrait<7> for Params768 {
fn modulus_bits() -> u32 {
768
}
}
struct Params1024 {}
pub struct Params1024 {}
impl RuntimeBigNumParamsTrait<9> for Params1024 {
fn modulus_bits() -> u32 {
1024
}
}
struct Params2048 {}
pub struct Params2048 {}
impl RuntimeBigNumParamsTrait<18> for Params2048 {
fn modulus_bits() -> u32 {
2048
}
}
struct Params4096 {}
pub struct Params4096 {}
impl RuntimeBigNumParamsTrait<35> for Params4096 {
fn modulus_bits() -> u32 {
4096
}
}

// example typedef when using a defined bignum instance
type Fq = BigNum<3, BNParams>;

2 changes: 1 addition & 1 deletion src/fields/pallasFq.nr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct Pallas_Fq_Params {}
pub struct Pallas_Fq_Params {}
impl RuntimeBigNumParamsTrait<3> for Pallas_Fq_Params {
fn modulus_bits() -> u32 {
255
Expand Down
2 changes: 1 addition & 1 deletion src/fields/pallasFr.nr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct Pallas_Fr_Params {}
pub struct Pallas_Fr_Params {}
impl RuntimeBigNumParamsTrait<3> for Pallas_Fr_Params {
fn modulus_bits() -> u32 {
255
Expand Down
2 changes: 1 addition & 1 deletion src/fields/secp256k1Fq.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::runtime_bignum::BigNumInstance;
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait;
use crate::utils::u60_representation::U60Repr;

struct Secp256k1_Fq_Params {}
pub struct Secp256k1_Fq_Params {}
impl RuntimeBigNumParamsTrait<3> for Secp256k1_Fq_Params {
fn modulus_bits() -> u32 {
256
Expand Down
Loading

0 comments on commit fc53098

Please sign in to comment.