mirror of
https://github.com/arnaucube/Nova.git
synced 2026-01-09 23:51:29 +01:00
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install
|
- name: Install
|
||||||
run: rustup default nightly
|
run: rustup default stable
|
||||||
- name: Install rustfmt Components
|
- name: Install rustfmt Components
|
||||||
run: rustup component add rustfmt
|
run: rustup component add rustfmt
|
||||||
- name: Install clippy
|
- name: Install clippy
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ keywords = ["zkSNARKs", "cryptography", "proofs"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bellperson = { version = "0.20", default-features = false }
|
bellperson = { version = "0.20", default-features = false }
|
||||||
ff = { version = "0.11.0", features = ["derive"] }
|
ff = "0.11.0"
|
||||||
merlin = "2.0.0"
|
merlin = "2.0.0"
|
||||||
rand = "0.8.4"
|
rand = "0.8.4"
|
||||||
digest = "0.8.1"
|
digest = "0.8.1"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
tab_spaces = 2
|
tab_spaces = 2
|
||||||
newline_style = "Unix"
|
newline_style = "Unix"
|
||||||
use_try_shorthand = true
|
use_try_shorthand = true
|
||||||
imports_granularity = "crate"
|
|
||||||
@@ -559,37 +559,14 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
mod fp {
|
|
||||||
use ff::PrimeField;
|
|
||||||
|
|
||||||
#[derive(PrimeField)]
|
|
||||||
#[PrimeFieldModulus = "28948022309329048855892746252171976963363056481941560715954676764349967630337"]
|
|
||||||
#[PrimeFieldGenerator = "5"]
|
|
||||||
#[PrimeFieldReprEndianness = "little"]
|
|
||||||
pub struct Fp([u64; 4]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
mod fq {
|
|
||||||
use ff::PrimeField;
|
|
||||||
|
|
||||||
#[derive(PrimeField)]
|
|
||||||
#[PrimeFieldModulus = "28948022309329048855892746252171976963363056481941647379679742748393362948097"]
|
|
||||||
#[PrimeFieldGenerator = "5"]
|
|
||||||
#[PrimeFieldReprEndianness = "little"]
|
|
||||||
pub struct Fq([u64; 4]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ecc_ops() {
|
fn test_ecc_ops() {
|
||||||
use super::{fp::Fp, fq::Fq};
|
type Fp = pasta_curves::pallas::Base;
|
||||||
|
type Fq = pasta_curves::pallas::Scalar;
|
||||||
|
|
||||||
// perform some curve arithmetic
|
// perform some curve arithmetic
|
||||||
let a = Point::<Fp, Fq>::random_vartime();
|
let a = Point::<Fp, Fq>::random_vartime();
|
||||||
@@ -601,35 +578,35 @@ mod tests {
|
|||||||
|
|
||||||
// perform the same computation by translating to pasta_curve types
|
// perform the same computation by translating to pasta_curve types
|
||||||
let a_pasta = EpAffine::from_xy(
|
let a_pasta = EpAffine::from_xy(
|
||||||
pasta_curves::Fp::from_repr(a.x.to_repr().0).unwrap(),
|
pasta_curves::Fp::from_repr(a.x.to_repr()).unwrap(),
|
||||||
pasta_curves::Fp::from_repr(a.y.to_repr().0).unwrap(),
|
pasta_curves::Fp::from_repr(a.y.to_repr()).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let b_pasta = EpAffine::from_xy(
|
let b_pasta = EpAffine::from_xy(
|
||||||
pasta_curves::Fp::from_repr(b.x.to_repr().0).unwrap(),
|
pasta_curves::Fp::from_repr(b.x.to_repr()).unwrap(),
|
||||||
pasta_curves::Fp::from_repr(b.y.to_repr().0).unwrap(),
|
pasta_curves::Fp::from_repr(b.y.to_repr()).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let c_pasta = (a_pasta + b_pasta).to_affine();
|
let c_pasta = (a_pasta + b_pasta).to_affine();
|
||||||
let d_pasta = (a_pasta + a_pasta).to_affine();
|
let d_pasta = (a_pasta + a_pasta).to_affine();
|
||||||
let e_pasta = a_pasta
|
let e_pasta = a_pasta
|
||||||
.mul(pasta_curves::Fq::from_repr(s.to_repr().0).unwrap())
|
.mul(pasta_curves::Fq::from_repr(s.to_repr()).unwrap())
|
||||||
.to_affine();
|
.to_affine();
|
||||||
|
|
||||||
// transform c, d, and e into pasta_curve types
|
// transform c, d, and e into pasta_curve types
|
||||||
let c_pasta_2 = EpAffine::from_xy(
|
let c_pasta_2 = EpAffine::from_xy(
|
||||||
pasta_curves::Fp::from_repr(c.x.to_repr().0).unwrap(),
|
pasta_curves::Fp::from_repr(c.x.to_repr()).unwrap(),
|
||||||
pasta_curves::Fp::from_repr(c.y.to_repr().0).unwrap(),
|
pasta_curves::Fp::from_repr(c.y.to_repr()).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let d_pasta_2 = EpAffine::from_xy(
|
let d_pasta_2 = EpAffine::from_xy(
|
||||||
pasta_curves::Fp::from_repr(d.x.to_repr().0).unwrap(),
|
pasta_curves::Fp::from_repr(d.x.to_repr()).unwrap(),
|
||||||
pasta_curves::Fp::from_repr(d.y.to_repr().0).unwrap(),
|
pasta_curves::Fp::from_repr(d.y.to_repr()).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let e_pasta_2 = EpAffine::from_xy(
|
let e_pasta_2 = EpAffine::from_xy(
|
||||||
pasta_curves::Fp::from_repr(e.x.to_repr().0).unwrap(),
|
pasta_curves::Fp::from_repr(e.x.to_repr()).unwrap(),
|
||||||
pasta_curves::Fp::from_repr(e.y.to_repr().0).unwrap(),
|
pasta_curves::Fp::from_repr(e.y.to_repr()).unwrap(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user