diff --git a/myzkp/src/modules/bn128.rs b/myzkp/src/modules/bn128.rs index 248a170..2022d17 100644 --- a/myzkp/src/modules/bn128.rs +++ b/myzkp/src/modules/bn128.rs @@ -2,14 +2,12 @@ use crate::modules::ring::Ring; use lazy_static::lazy_static; use num_bigint::BigInt; use num_bigint::ToBigInt; -use num_traits::FromPrimitive; use num_traits::{One, Zero}; use paste::paste; use std::str::FromStr; -use crate::modules::curve::{miller, EllipticCurve, EllipticCurvePoint}; +use crate::modules::curve::{get_lambda, miller, EllipticCurve, EllipticCurvePoint}; use crate::modules::efield::{ExtendedFieldElement, IrreduciblePoly}; -use crate::modules::field::Field; use crate::modules::field::{FiniteFieldElement, ModulusValue}; use crate::modules::polynomial::Polynomial; use crate::{define_myzkp_curve_type, define_myzkp_modulus_type}; @@ -20,8 +18,8 @@ define_myzkp_modulus_type!( ); define_myzkp_curve_type!(BN128Curve, "0", "3"); -type Fq = FiniteFieldElement; -type G1Point = EllipticCurvePoint; +pub type Fq = FiniteFieldElement; +pub type G1Point = EllipticCurvePoint; // Define Fq2 as a quadratic extension field #[derive(Debug, Clone, PartialEq, Hash)] @@ -38,8 +36,8 @@ impl IrreduciblePoly for Fq2Poly { &MODULUS_Fq2 } } -type Fq2 = ExtendedFieldElement; -type G2Point = EllipticCurvePoint; +pub type Fq2 = ExtendedFieldElement; +pub type G2Point = EllipticCurvePoint; // Define Fq2 as a quadratic extension field #[derive(Debug, Clone, PartialEq, Hash)] @@ -73,7 +71,7 @@ impl IrreduciblePoly for Fq12Poly { type Fq12 = ExtendedFieldElement; type G12Point = EllipticCurvePoint; -pub fn cast_G1_to_G12(g: G1Point) -> G12Point { +pub fn cast_g1_to_g12(g: G1Point) -> G12Point { if g.is_point_at_infinity() { return G12Point::point_at_infinity(); } @@ -88,7 +86,7 @@ pub fn cast_G1_to_G12(g: G1Point) -> G12Point { ) } -pub fn twist_G2_to_G12(g: G2Point) -> G12Point { +pub fn twist_g2_to_g12(g: G2Point) -> G12Point { if g.is_point_at_infinity() { return G12Point::point_at_infinity(); } @@ -137,82 +135,36 @@ pub fn twist_G2_to_G12(g: G2Point) -> G12Point { ); } -pub fn linefunc( - p: &EllipticCurvePoint, - q: &EllipticCurvePoint, - t: &EllipticCurvePoint, -) -> F { - let x1 = p.x.as_ref().unwrap(); - let y1 = p.y.as_ref().unwrap(); - let x2 = q.x.as_ref().unwrap(); - let y2 = q.y.as_ref().unwrap(); - let xt = t.x.as_ref().unwrap(); - let yt = t.y.as_ref().unwrap(); - - if x1 != x2 { - let m = (y2.sub_ref(&y1)) / (x2.sub_ref(&x1)); - return (m.mul_ref(&xt.sub_ref(&x1))).sub_ref(&yt.sub_ref(&y1)); - } else if y1 == y2 { - let m = ((x1.pow(2)).mul_ref(&F::from_value(3))) / (y1.mul_ref(&F::from_value(2))); - return (m.mul_ref(&xt.sub_ref(&x1))).sub_ref(&yt.sub_ref(&y1)); - } else { - return xt.sub_ref(x1); - } -} - -pub fn vanila_miller( - p: &EllipticCurvePoint, - q: &EllipticCurvePoint, - m: &BigInt, -) -> F { - if p == q { - return F::one(); - } - - let mut r = q.clone(); - let mut f = F::one(); - - let ate_loop_count = BigInt::from_str("29793968203157093288").unwrap(); - let log_ate_loop_count = 63; - let field_modulus = BigInt::from_str( - "21888242871839275222246405745257275088696311157297823662689037894645226208583", - ) - .unwrap(); - - for i in (0..=log_ate_loop_count).rev() { - f = f.mul_ref(&f) * linefunc(&r, &r, &p); - r = r.double(); - if ate_loop_count.bit(i) { - f = f.mul_ref(&linefunc(&r, &q, &p)); - r = r.add_ref(&q); - } - } - - // Assert: r == multiply(&q, &ate_loop_count) +pub fn optimal_ate_pairing(p_g1: &G1Point, q_g2: &G2Point) -> Fq12 { + // https://eprint.iacr.org/2010/354.pdf + let p: G12Point = cast_g1_to_g12(p_g1.clone()); + let q: G12Point = twist_g2_to_g12(q_g2.clone()); + let m = BN128Modulus::modulus(); - let q1 = EllipticCurvePoint::::new( - q.x.clone().unwrap().pow(m.clone()), - q.y.clone().unwrap().pow(m.clone()), - ); + let mut f = Fq12::one(); + if p != q { + let ate_loop_count = BigInt::from_str("29793968203157093288").unwrap(); - let nq2 = EllipticCurvePoint::::new( - q1.x.clone().unwrap().pow(m.clone()), - -q1.y.clone().unwrap().pow(m.clone()), - ); + let out = miller(&q, &p, ate_loop_count); + f = out.0; + let mut r = out.1; + // Assert: r == multiply(&q, &ate_loop_count) - f = f.mul_ref(&linefunc(&r, &q1, &p)); - r = r.add_ref(&q1); - f = f.mul_ref(&linefunc(&r, &nq2, &p)); + let q1 = G12Point::new( + q.x.clone().unwrap().pow(m.clone()), + q.y.clone().unwrap().pow(m.clone()), + ); - f -} + let nq2 = G12Point::new( + q1.x.clone().unwrap().pow(m.clone()), + -q1.y.clone().unwrap().pow(m.clone()), + ); -pub fn optimal_ate_pairing(p: G1Point, q: G2Point) -> Fq12 { - let p_prime: G12Point = cast_G1_to_G12(p); - let q_prime: G12Point = twist_G2_to_G12(q); - let m = BN128Modulus::modulus(); + f = f.mul_ref(&get_lambda(&r, &q1, &p)); + r = r.add_ref(&q1); + f = f.mul_ref(&get_lambda(&r, &nq2, &p)); + } - let f = vanila_miller(&p_prime, &q_prime, &m); let exp = (m.pow(12) - BigInt::one()) / (BN128::order()); f.pow(exp) } @@ -358,7 +310,7 @@ mod tests { #[test] fn test_g12() { let g2 = BN128::generator_g2(); - let g12 = twist_G2_to_G12(g2); + let g12 = twist_g2_to_g12(g2); let g12_9 = g12.clone() * 9; assert_eq!( g12_9.clone().y.unwrap().pow(2) - g12_9.clone().x.unwrap().pow(3), @@ -379,21 +331,21 @@ mod tests { fn test_pairing() { let g1 = BN128::generator_g1(); let g2 = BN128::generator_g2(); - let p1 = optimal_ate_pairing(g1.clone(), g2.clone()); - let pn1 = optimal_ate_pairing(-g1.clone(), g2.clone()); + let p1 = optimal_ate_pairing(&g1.clone(), &g2.clone()); + let pn1 = optimal_ate_pairing(&-g1.clone(), &g2.clone()); assert_eq!(p1.clone() * pn1.clone(), Fq12::one()); - let np1 = optimal_ate_pairing(g1.clone(), -g2.clone()); + let np1 = optimal_ate_pairing(&g1.clone(), &-g2.clone()); assert_eq!(p1.clone() * np1.clone(), Fq12::one()); assert_eq!(pn1.clone(), np1.clone()); - let p2 = optimal_ate_pairing(g1.clone() * 2, g2.clone()); + let p2 = optimal_ate_pairing(&(g1.clone() * 2), &g2.clone()); assert_eq!(p1.clone() * p1.clone(), p2); assert!(p1 != p2); assert!(p1 != np1); assert!(p2 != np1); - let po2 = optimal_ate_pairing(g1.clone(), g2.clone() * 2); + let po2 = optimal_ate_pairing(&g1.clone(), &(g2.clone() * 2)); assert_eq!(p1.clone() * p1.clone(), po2); - let p3 = optimal_ate_pairing(g1.clone() * 37, g2.clone() * 27); - let po3 = optimal_ate_pairing(g1.clone() * 999, g2.clone()); + let p3 = optimal_ate_pairing(&(g1.clone() * 37), &(g2.clone() * 27)); + let po3 = optimal_ate_pairing(&(g1.clone() * 999), &(g2.clone())); assert_eq!(p3, po3); } } diff --git a/myzkp/src/modules/curve.rs b/myzkp/src/modules/curve.rs index 5460d4c..040561f 100644 --- a/myzkp/src/modules/curve.rs +++ b/myzkp/src/modules/curve.rs @@ -53,7 +53,6 @@ impl EllipticCurvePoint { pub fn line_slope(&self, other: &Self) -> F { let a = F::from_value(E::get_a()); - // let b = E::get_b(); let x1 = self.x.as_ref().unwrap(); let y1 = self.y.as_ref().unwrap(); @@ -84,49 +83,6 @@ impl EllipticCurvePoint { } pub fn add_ref(&self, other: &Self) -> Self { - /* - if self.is_point_at_infinity() { - return other; - } - if other.is_point_at_infinity() { - return self; - } - - let m = self.line_slope(other.clone()); - - // If x coordinates are the same - if self.x == other.x { - // Check if they are inverses of each other - if self.y != other.y { - // TODO: check self.y = -other.y - return EllipticCurvePoint::point_at_infinity(); - } else { - // P = Q, handle point doubling - let x1 = self.x.clone().unwrap(); - let y1 = self.y.clone().unwrap(); - - // let m = ((x1.clone() * x1.clone()).mul_scalar(3_i64) + self.curve.a.clone()) - // / (y1.clone().mul_scalar(2_i64)); - - let x3 = m.clone() * m.clone() - x1.clone() - x1.clone(); - let y3 = m * (x1 - x3.clone()) - y1; - - return EllipticCurvePoint::new(x3, y3); - } - } else { - // P != Q, handle regular addition - let x1 = self.x.clone().unwrap(); - let y1 = self.y.clone().unwrap(); - let x2 = other.x.clone().unwrap(); - // let y2 = other.y.clone().unwrap(); - - // let m = (y2.clone() - y1.clone()) / (x2.clone() - x1.clone()); - let x3 = m.clone() * m.clone() - x1.clone() - x2.clone(); - let y3 = m * (x1 - x3.clone()) - y1; - - return EllipticCurvePoint::new(x3, y3); - }*/ - if self.is_point_at_infinity() { return other.clone(); } @@ -249,15 +205,15 @@ pub fn miller( p: &EllipticCurvePoint, q: &EllipticCurvePoint, m: BigInt, -) -> F { +) -> (F, EllipticCurvePoint) { if p == q { - return F::one(); + return (F::one(), p.clone()); } let mut f = F::one(); let mut t = p.clone(); - for i in (1..m.bits()).rev() { + for i in (0..(m.bits() - 1)).rev() { f = (f.mul_ref(&f)) * (get_lambda(&t, &t, &q)); t = t.add_ref(&t); if m.bit(i) { @@ -266,7 +222,7 @@ pub fn miller( } } - f + (f, t) } pub fn weil_pairing( @@ -276,10 +232,10 @@ pub fn weil_pairing( s: Option<&EllipticCurvePoint>, ) -> F { let s_value = s.unwrap(); - let fp_qs = miller(&p, &q.add_ref(&s_value), m.clone()); - let fp_s = miller(&p, &s_value, m.clone()); - let fq_ps = miller(&q, &p.add_ref(&(s_value.clone().neg())), m.clone()); - let fq_s = miller(&q, &(-s_value.clone()), m.clone()); + let (fp_qs, _) = miller(&p, &q.add_ref(&s_value), m.clone()); + let (fp_s, _) = miller(&p, &s_value, m.clone()); + let (fq_ps, _) = miller(&q, &p.add_ref(&(s_value.clone().neg())), m.clone()); + let (fq_s, _) = miller(&q, &(-s_value.clone()), m.clone()); return (fp_qs / fp_s) / (fq_ps / fq_s); } @@ -292,8 +248,8 @@ pub fn general_tate_pairing( s: Option<&EllipticCurvePoint>, ) -> F { let s_value = s.unwrap(); - let fp_qs = miller(&p, &q.add_ref(&s_value), ell.clone()); - let fp_s = miller(&p, &s_value, ell.clone()); + let (fp_qs, _) = miller(&p, &q.add_ref(&s_value), ell.clone()); + let (fp_s, _) = miller(&p, &s_value, ell.clone()); let f = fp_qs.div_ref(&fp_s); return f.pow((modulus - BigInt::one()) / ell); @@ -305,7 +261,7 @@ pub fn tate_pairing( ell: BigInt, modulus: BigInt, ) -> F { - let fp_q = miller(&p, &q, ell.clone()); + let (fp_q, _) = miller(&p, &q, ell.clone()); return fp_q.pow((modulus - BigInt::one()) / ell); } @@ -359,8 +315,8 @@ mod tests { ); let order = 5.to_bigint().unwrap(); - let fp_qs = miller(&p, &(q.add_ref(&s)), order.clone()); - let fp_s = miller(&p, &s, order.clone()); + let (fp_qs, _) = miller(&p, &(q.add_ref(&s)), order.clone()); + let (fp_s, _) = miller(&p, &s, order.clone()); assert_eq!(fp_qs.sanitize().value, 103_i32.to_bigint().unwrap()); assert_eq!(fp_s.sanitize().value, 219_i32.to_bigint().unwrap()); assert_eq!( @@ -368,8 +324,8 @@ mod tests { 473_i32.to_bigint().unwrap() ); - let fq_ps = miller(&q, &p.add_ref(&s.clone().neg()), order.clone()); - let fq_s = miller(&q, &(-s.clone()), order.clone()); + let (fq_ps, _) = miller(&q, &p.add_ref(&s.clone().neg()), order.clone()); + let (fq_s, _) = miller(&q, &(-s.clone()), order.clone()); assert_eq!(fq_ps.sanitize().value, 284_i32.to_bigint().unwrap()); assert_eq!(fq_s.sanitize().value, 204_i32.to_bigint().unwrap()); assert_eq!((fq_ps / fq_s).sanitize().value, 88_i32.to_bigint().unwrap()); diff --git a/myzkp/src/modules/educational_protocols/mod.rs b/myzkp/src/modules/educational_protocols/mod.rs index bdc2eec..5032c28 100644 --- a/myzkp/src/modules/educational_protocols/mod.rs +++ b/myzkp/src/modules/educational_protocols/mod.rs @@ -1,6 +1,6 @@ pub mod dl; pub mod kea; pub mod naive; -//pub mod nizk; +pub mod nizk; pub mod sz; pub mod zk; diff --git a/myzkp/src/modules/educational_protocols/nizk.rs b/myzkp/src/modules/educational_protocols/nizk.rs index 7ae4599..a5b41e8 100644 --- a/myzkp/src/modules/educational_protocols/nizk.rs +++ b/myzkp/src/modules/educational_protocols/nizk.rs @@ -1,49 +1,57 @@ -use crate::modules::curve::{weil_pairing, EllipticCurve, EllipticCurvePoint}; -use crate::modules::field::Field; +use num_bigint::{BigInt, RandBigInt}; +use num_traits::One; +use num_traits::Zero; +use std::str::FromStr; + +use crate::modules::bn128::{optimal_ate_pairing, Fq, G1Point, G2Point}; use crate::modules::polynomial::Polynomial; -use num_bigint::BigInt; +use crate::modules::ring::Ring; -pub struct ProofKey { - alpha: Vec>, - alpha_prime: Vec>, +pub struct ProofKey { + alpha: Vec, + alpha_prime: Vec, } -pub struct VerificationKey { - g_r: EllipticCurvePoint, - g_t_s: EllipticCurvePoint, +pub struct VerificationKey { + g_r: G2Point, + g_t_s: G2Point, } -pub struct Proof { - u_prime: EllipticCurvePoint, - v_prime: EllipticCurvePoint, - w_prime: EllipticCurvePoint, +pub struct Proof { + u_prime: G1Point, + v_prime: G1Point, + w_prime: G1Point, } -pub struct TrustedSetup { - proof_key: ProofKey, - verification_key: VerificationKey, +pub struct TrustedSetup { + proof_key: ProofKey, + verification_key: VerificationKey, } -impl TrustedSetup { - pub fn generate( - g: &EllipticCurvePoint, - t: &Polynomial, - n: usize, - s: &F, - r: &F, - ) -> Self { +impl TrustedSetup { + pub fn generate(g1: &G1Point, g2: &G2Point, t: &Polynomial, n: usize) -> Self { + let mut rng = rand::thread_rng(); + let s = Fq::from_value(rng.gen_bigint_range( + &BigInt::zero(), + &BigInt::from_str("18446744073709551616").unwrap(), // 2^64 + )); + let r = Fq::from_value(rng.gen_bigint_range( + &BigInt::zero(), + &BigInt::from_str("18446744073709551616").unwrap(), // 2^64 + )); + let mut alpha = Vec::with_capacity(n); let mut alpha_prime = Vec::with_capacity(n); - let mut s_power = F::one(); + let mut s_power = Fq::one(); for _ in 0..1 + n { - alpha.push(g.clone() * s_power.clone().get_value()); - alpha_prime.push(g.clone() * (s_power.clone() * r.clone()).get_value()); + alpha.push(g1.clone() * s_power.clone().get_value()); + alpha_prime.push(g1.clone() * (s_power.clone() * r.clone()).get_value()); s_power = s_power * s.clone(); } - let g_r = g.clone() * r.clone().get_value(); - let g_t_s = g.clone() * t.eval(s).get_value(); + let g_r = g2.clone() * r.clone().get_value(); + let g_t_s = g2.clone() * t.eval(&s).get_value(); TrustedSetup { proof_key: ProofKey { alpha, alpha_prime }, @@ -52,19 +60,24 @@ impl TrustedSetup { } } -pub struct Prover { - pub p: Polynomial, - pub h: Polynomial, - pub g: EllipticCurvePoint, +pub struct Prover { + pub p: Polynomial, + pub h: Polynomial, } -impl Prover { - pub fn new(p: Polynomial, t: Polynomial, g: EllipticCurvePoint) -> Self { +impl Prover { + pub fn new(p: Polynomial, t: Polynomial) -> Self { let h = p.clone() / t; - Prover { p, h, g } + Prover { p, h } } - pub fn generate_proof(&self, proof_key: &ProofKey, delta: &F) -> Proof { + pub fn generate_proof(&self, proof_key: &ProofKey) -> Proof { + let mut rng = rand::thread_rng(); + let delta = Fq::from_value(rng.gen_bigint_range( + &BigInt::zero(), + &BigInt::from_str("18446744073709551616").unwrap(), // 2^64 + )); + let g_p = self.p.eval_with_powers_on_curve(&proof_key.alpha); let g_h = self.h.eval_with_powers_on_curve(&proof_key.alpha); let g_p_prime = self.p.eval_with_powers_on_curve(&proof_key.alpha_prime); @@ -77,155 +90,66 @@ impl Prover { } } -pub struct Verifier { - g: EllipticCurvePoint, +pub struct Verifier { + pub g1: G1Point, + pub g2: G2Point, } -impl Verifier { - pub fn new(g: EllipticCurvePoint) -> Self { - Verifier { g } +impl Verifier { + pub fn new(g1: G1Point, g2: G2Point) -> Self { + Verifier { g1, g2 } } - pub fn verify( - &self, - proof: &Proof, - vk: &VerificationKey, - curve_order: BigInt, - s: EllipticCurvePoint, - ) -> bool { + pub fn verify(&self, proof: &Proof, vk: &VerificationKey) -> bool { // Check e(u', g^r) = e(w', g) - let pairing1 = weil_pairing( - proof.u_prime.clone(), - vk.g_r.clone(), - BigInt::from(curve_order.clone()), - Some(self.g.clone()), - ); - let pairing2 = weil_pairing( - proof.w_prime.clone(), - self.g.clone(), - BigInt::from(curve_order.clone()), - Some(self.g.clone()), - ); + let pairing1 = optimal_ate_pairing(&proof.u_prime, &vk.g_r); + let pairing2 = optimal_ate_pairing(&proof.w_prime, &self.g2); let check1 = pairing1 == pairing2; - println!("^^^^ {} {} {}", pairing1, pairing2, check1); - - println!( - "{}", - proof.u_prime.clone() == self.g.clone() * BigInt::from(24) - ); - - println!( - "{}", - proof.v_prime.clone() == self.g.clone() * BigInt::from(4) - ); - - println!("{}", vk.g_t_s.clone() == self.g.clone() * BigInt::from(6)); - // Check e(u', g^t) = e(v', g) - let pairing3 = weil_pairing( - proof.u_prime.clone(), - self.g.clone(), - BigInt::from(curve_order.clone()), - Some(s.clone()), - ); - let pairing4 = weil_pairing( - proof.v_prime.clone(), - vk.g_t_s.clone(), - BigInt::from(curve_order.clone()), - Some(s.clone()), - ); + let pairing3 = optimal_ate_pairing(&proof.u_prime, &self.g2); + let pairing4 = optimal_ate_pairing(&proof.v_prime, &vk.g_t_s); let check2 = pairing3 == pairing4; - println!("^^^^ {} {} {}", pairing3, pairing4, check2); - check1 && check2 } } -pub fn non_interactive_zkp_protocol( - prover: &Prover, - verifier: &Verifier, - setup: &TrustedSetup, - delta: &F, - curve_order: BigInt, - ms: EllipticCurvePoint, +pub fn non_interactive_zkp_protocol( + prover: &Prover, + verifier: &Verifier, + setup: &TrustedSetup, ) -> bool { - let proof = prover.generate_proof(&setup.proof_key, delta); - verifier.verify(&proof, &setup.verification_key, curve_order, ms) + let proof = prover.generate_proof(&setup.proof_key); + verifier.verify(&proof, &setup.verification_key) } #[cfg(test)] mod tests { use super::*; - use std::str::FromStr; - - use crate::modules::field::ModulusValue; - use crate::modules::ring::Ring; - use crate::{ - define_myzkp_curve_type, define_myzkp_modulus_type, - modules::field::{FiniteFieldElement, ModEIP197}, - }; + use crate::modules::bn128::BN128; #[test] fn test_non_interactive_zkp() { - define_myzkp_modulus_type!(Mod631, "631"); - define_myzkp_curve_type!(BLS12to381, "1", "4"); - type F = FiniteFieldElement; - type E = CurveA30B34; - - // Set up the generator point - let g = EllipticCurvePoint::::new(F::from_value(36), F::from_value(60)); + let g1 = BN128::generator_g1(); + let g2 = BN128::generator_g2(); // Set up the polynomials - let p = - Polynomial::from_monomials(&[F::from_value(-1), F::from_value(-2), F::from_value(-3)]); - let t = Polynomial::from_monomials(&[F::from_value(-1), F::from_value(-2)]); + let p = Polynomial::from_monomials(&[ + Fq::from_value(-1), + Fq::from_value(-2), + Fq::from_value(-3), + ]); + let t = Polynomial::from_monomials(&[Fq::from_value(-1), Fq::from_value(-2)]); - // Generate trusted setup - let s = F::from_value(2); - let r = F::from_value(1); //F::from_value(456); - let setup = TrustedSetup::generate(&g, &t, 3, &s, &r); + let setup = TrustedSetup::generate(&g1, &g2, &t, 3); // Create prover and verifier - let prover = Prover::new(p, t.clone(), g.clone()); - let verifier = Verifier::new(g.clone()); - - let ms = EllipticCurvePoint::::new(F::from_value(0_i64), F::from_value(36_i64)); + let prover = Prover::new(p, t.clone()); + let verifier = Verifier::new(g1.clone(), g2.clone()); // Run the protocol - let delta = F::from_value(23); - let order = BigInt::from_str("5").unwrap(); - let result = non_interactive_zkp_protocol(&prover, &verifier, &setup, &delta, order, ms); - - let proof = prover.generate_proof(&setup.proof_key, &delta); - /* - println!( - "v_prime={}, {}", - proof.v_prime.clone(), - proof.v_prime == g.clone() * prover.h.eval(&s).get_value() - ); - - println!( - "p(s)={} h(s)={} t(s)={}", - prover.p.eval(&s).get_value(), - prover.h.eval(&s).get_value(), - t.eval(&s).get_value() - ); - */ - println!( - "@@ {}", - //proof.u_prime.clone() * r.get_value(), - //proof.w_prime.clone(), - proof.u_prime.clone() * r.get_value() == proof.w_prime - ); - println!( - "@@ {}", - //proof.u_prime.clone(), - //proof.v_prime.clone() * t.eval(&s).get_value(), - proof.u_prime.clone() == proof.v_prime * t.eval(&s).get_value() - ); - + let result = non_interactive_zkp_protocol(&prover, &verifier, &setup); assert!(result); } } diff --git a/myzkp/src/modules/efield.rs b/myzkp/src/modules/efield.rs index a48d045..a89f67c 100644 --- a/myzkp/src/modules/efield.rs +++ b/myzkp/src/modules/efield.rs @@ -11,7 +11,6 @@ use std::ops::{Add, Div, Mul, Neg, Sub}; use crate::modules::field::{Field, FiniteFieldElement, ModulusValue}; use crate::modules::polynomial::Polynomial; use crate::modules::ring::Ring; -use crate::modules::utils::extended_euclidean; pub trait IrreduciblePoly: Debug + Clone + Hash { fn modulus() -> &'static Polynomial;