Browse Source

migrate codebase to arkworks and change curve to bls12-377

master
Mara Mihali 2 years ago
parent
commit
b085c670be
7 changed files with 17 additions and 5 deletions
  1. +2
    -0
      examples/cubic.rs
  2. +6
    -1
      src/group.rs
  3. +1
    -1
      src/lib.rs
  4. +2
    -0
      src/nizk/bullet.rs
  5. +2
    -0
      src/nizk/mod.rs
  6. +3
    -3
      src/r1csinstance.rs
  7. +1
    -0
      src/sumcheck.rs

+ 2
- 0
examples/cubic.rs

@ -8,6 +8,8 @@
//! `(Z3 + 5) * 1 - I0 = 0` //! `(Z3 + 5) * 1 - I0 = 0`
//! //!
//! [here]: https://medium.com/@VitalikButerin/quadratic-arithmetic-programs-from-zero-to-hero-f6d558cea649 //! [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 ark_std::{One, UniformRand, Zero};
use libspartan::{InputsAssignment, Instance, SNARKGens, VarsAssignment, SNARK}; use libspartan::{InputsAssignment, Instance, SNARKGens, VarsAssignment, SNARK};
use merlin::Transcript; use merlin::Transcript;

+ 6
- 1
src/group.rs

@ -7,7 +7,12 @@ use lazy_static::lazy_static;
use num_bigint::BigInt; use num_bigint::BigInt;
use crate::errors::ProofVerifyError; 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::borrow::Borrow;
use core::ops::{Mul, MulAssign}; use core::ops::{Mul, MulAssign};
use ark_ec::{ProjectiveCurve, AffineCurve}; use ark_ec::{ProjectiveCurve, AffineCurve};

+ 1
- 1
src/lib.rs

@ -1,6 +1,7 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
#![deny(missing_docs)] #![deny(missing_docs)]
#![feature(test)]
#![allow(clippy::assertions_on_result_states)] #![allow(clippy::assertions_on_result_states)]
extern crate ark_std; extern crate ark_std;
@ -120,7 +121,6 @@ pub type VarsAssignment = Assignment;
/// `InputsAssignment` holds an assignment of values to variables in an `Instance` /// `InputsAssignment` holds an assignment of values to variables in an `Instance`
pub type InputsAssignment = Assignment; pub type InputsAssignment = Assignment;
/// `Instance` holds the description of R1CS matrices
/// `Instance` holds the description of R1CS matrices and a hash of the matrices /// `Instance` holds the description of R1CS matrices and a hash of the matrices
#[derive(Debug)] #[derive(Debug)]
pub struct Instance { pub struct Instance {

+ 2
- 0
src/nizk/bullet.rs

@ -3,6 +3,8 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![allow(clippy::type_complexity)] #![allow(clippy::type_complexity)]
#![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_arguments)]
use crate::math::Math;
use super::super::errors::ProofVerifyError; use super::super::errors::ProofVerifyError;
use super::super::group::{ use super::super::group::{
CompressGroupElement, CompressedGroup, DecompressGroupElement, GroupElement, CompressGroupElement, CompressedGroup, DecompressGroupElement, GroupElement,

+ 2
- 0
src/nizk/mod.rs

@ -1,4 +1,6 @@
#![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_arguments)]
use crate::math::Math;
use super::commitments::{Commitments, MultiCommitGens}; use super::commitments::{Commitments, MultiCommitGens};
use super::errors::ProofVerifyError; use super::errors::ProofVerifyError;
use super::group::{ use super::group::{

+ 3
- 3
src/r1csinstance.rs

@ -147,9 +147,9 @@ impl R1CSInstance {
} }
pub fn get_digest(&self) -> Vec<u8> { pub fn get_digest(&self) -> Vec<u8> {
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( pub fn produce_synthetic_r1cs(

+ 1
- 0
src/sumcheck.rs

@ -829,6 +829,7 @@ impl ZKSumcheckInstanceProof {
// add two claims to transcript // add two claims to transcript
comm_claim_per_round.append_to_transcript(b"comm_claim_per_round", transcript); comm_claim_per_round.append_to_transcript(b"comm_claim_per_round", transcript);
comm_eval.append_to_transcript(b"comm_eval", transcript); comm_eval.append_to_transcript(b"comm_eval", transcript);
// produce two weights // produce two weights
let w = transcript.challenge_vector(b"combine_two_claims_to_one", 2); let w = transcript.challenge_vector(b"combine_two_claims_to_one", 2);

Loading…
Cancel
Save