From b085c670bebb79b8da2b297f0609d497cc786348 Mon Sep 17 00:00:00 2001 From: Mara Mihali Date: Fri, 17 Jun 2022 12:28:11 +0100 Subject: [PATCH] migrate codebase to arkworks and change curve to bls12-377 --- examples/cubic.rs | 2 ++ src/group.rs | 7 ++++++- src/lib.rs | 2 +- src/nizk/bullet.rs | 2 ++ src/nizk/mod.rs | 2 ++ src/r1csinstance.rs | 6 +++--- src/sumcheck.rs | 1 + 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/examples/cubic.rs b/examples/cubic.rs index 462d1db..c633dd7 100644 --- a/examples/cubic.rs +++ b/examples/cubic.rs @@ -8,6 +8,8 @@ //! `(Z3 + 5) * 1 - I0 = 0` //! //! [here]: https://medium.com/@VitalikButerin/quadratic-arithmetic-programs-from-zero-to-hero-f6d558cea649 +use ark_bls12_377::Fr as Scalar; +use ark_ff::{BigInteger, PrimeField}; use ark_std::{One, UniformRand, Zero}; use libspartan::{InputsAssignment, Instance, SNARKGens, VarsAssignment, SNARK}; use merlin::Transcript; diff --git a/src/group.rs b/src/group.rs index f2cd96b..c55cc25 100644 --- a/src/group.rs +++ b/src/group.rs @@ -7,7 +7,12 @@ use lazy_static::lazy_static; use num_bigint::BigInt; use crate::errors::ProofVerifyError; -use super::scalar::{Scalar}; +use lazy_static::lazy_static; +use num_bigint::BigInt; + +use super::scalar::Scalar; +use ark_ec::{AffineCurve, ProjectiveCurve}; +use ark_serialize::*; use core::borrow::Borrow; use core::ops::{Mul, MulAssign}; use ark_ec::{ProjectiveCurve, AffineCurve}; diff --git a/src/lib.rs b/src/lib.rs index c43cbb9..af1904f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![allow(non_snake_case)] #![doc = include_str!("../README.md")] #![deny(missing_docs)] +#![feature(test)] #![allow(clippy::assertions_on_result_states)] extern crate ark_std; @@ -120,7 +121,6 @@ pub type VarsAssignment = Assignment; /// `InputsAssignment` holds an assignment of values to variables in an `Instance` pub type InputsAssignment = Assignment; -/// `Instance` holds the description of R1CS matrices /// `Instance` holds the description of R1CS matrices and a hash of the matrices #[derive(Debug)] pub struct Instance { diff --git a/src/nizk/bullet.rs b/src/nizk/bullet.rs index 7a2091e..d91c603 100644 --- a/src/nizk/bullet.rs +++ b/src/nizk/bullet.rs @@ -3,6 +3,8 @@ #![allow(non_snake_case)] #![allow(clippy::type_complexity)] #![allow(clippy::too_many_arguments)] +use crate::math::Math; + use super::super::errors::ProofVerifyError; use super::super::group::{ CompressGroupElement, CompressedGroup, DecompressGroupElement, GroupElement, diff --git a/src/nizk/mod.rs b/src/nizk/mod.rs index 48cc0d6..b7e2646 100644 --- a/src/nizk/mod.rs +++ b/src/nizk/mod.rs @@ -1,4 +1,6 @@ #![allow(clippy::too_many_arguments)] +use crate::math::Math; + use super::commitments::{Commitments, MultiCommitGens}; use super::errors::ProofVerifyError; use super::group::{ diff --git a/src/r1csinstance.rs b/src/r1csinstance.rs index 56bce34..3c31721 100644 --- a/src/r1csinstance.rs +++ b/src/r1csinstance.rs @@ -147,9 +147,9 @@ impl R1CSInstance { } pub fn get_digest(&self) -> Vec { - let mut encoder = ZlibEncoder::new(Vec::new(), Compression::default()); - bincode::serialize_into(&mut encoder, &self).unwrap(); - encoder.finish().unwrap() + let mut bytes = Vec::new(); + self.serialize(&mut bytes).unwrap(); + bytes } pub fn produce_synthetic_r1cs( diff --git a/src/sumcheck.rs b/src/sumcheck.rs index 560d735..e316ea2 100644 --- a/src/sumcheck.rs +++ b/src/sumcheck.rs @@ -829,6 +829,7 @@ impl ZKSumcheckInstanceProof { // add two claims to transcript comm_claim_per_round.append_to_transcript(b"comm_claim_per_round", transcript); comm_eval.append_to_transcript(b"comm_eval", transcript); + // produce two weights let w = transcript.challenge_vector(b"combine_two_claims_to_one", 2);