Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to v0.4.0 #30

Merged
merged 23 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

### Bug fixes

## v0.4.0

- Change dependency to version `0.4.0` of other arkwork-rs crates.

## v0.3.0

- Change dependency to version `0.3.0` of other arkworks-rs crates.
Expand Down
35 changes: 18 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ark-gm17"
version = "0.3.0"
version = "0.4.0"
authors = [ "arkworks contributors" ]
description = "An implementation of the Groth-Maller 2017 zkSNARK proof system"
homepage = "https://arkworks.rs"
Expand All @@ -10,34 +10,35 @@ keywords = [ "zero-knowledge", "cryptography", "zkSNARK", "SNARK", "Groth-Maller
categories = [ "cryptography" ]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT/Apache-2.0"
edition = "2018"
edition = "2021"

################################# Dependencies ################################

[dependencies]
ark-ff = { version = "^0.3.0", default-features = false }
ark-ec = { version = "^0.3.0", default-features = false }
ark-serialize = { version = "^0.3.0", default-features = false, features = [ "derive" ] }
ark-poly = { version = "^0.3.0", default-features = false }
ark-std = { version = "^0.3.0", default-features = false }
ark-relations = { version = "^0.3.0", default-features = false }
ark-crypto-primitives = { version = "^0.3.0", default-features = false }
ark-r1cs-std = { version = "^0.3.0", default-features = false, optional = true }
ark-ff = { version = "^0.4.0", default-features = false }
ark-ec = { version = "^0.4.0", default-features = false }
ark-serialize = { version = "^0.4.0", default-features = false, features = [ "derive" ] }
ark-poly = { version = "^0.4.0", default-features = false }
ark-std = { version = "^0.4.0", default-features = false }
ark-relations = { version = "^0.4.0", default-features = false }
ark-crypto-primitives = { version = "^0.4.0", features = ["snark"], default-features = false }
ark-r1cs-std = { version = "^0.4.0", default-features = false, optional = true }

tracing = { version = "0.1", default-features = false, features = [ "attributes" ], optional = true }
derivative = { version = "2.0", features = ["use_core"], optional = true }

rayon = { version = "1", optional = true }
num-traits = "0.2.16"

[dev-dependencies]
csv = { version = "1" }
ark-bls12-381 = { version = "^0.3.0", default-features = false, features = ["curve"] }
ark-bls12-377 = { version = "^0.3.0", default-features = false, features = ["curve"] }
ark-cp6-782 = { version = "^0.3.0", default-features = false }
ark-mnt4-298 = { version = "^0.3.0", default-features = false, features = ["r1cs", "curve"] }
ark-mnt6-298 = { version = "^0.3.0", default-features = false, features = ["r1cs"] }
ark-mnt4-753 = { version = "^0.3.0", default-features = false, features = ["r1cs", "curve"] }
ark-mnt6-753 = { version = "^0.3.0", default-features = false, features = ["r1cs"] }
ark-bls12-381 = { version = "^0.4.0", default-features = false, features = ["curve"] }
ark-bls12-377 = { version = "^0.4.0", default-features = false, features = ["curve"] }
ark-cp6-782 = { version = "^0.4.0", default-features = false }
ark-mnt4-298 = { version = "^0.4.0", default-features = false, features = ["r1cs", "curve"] }
ark-mnt6-298 = { version = "^0.4.0", default-features = false, features = ["r1cs"] }
ark-mnt4-753 = { version = "^0.4.0", default-features = false, features = ["r1cs", "curve"] }
ark-mnt6-753 = { version = "^0.4.0", default-features = false, features = ["r1cs"] }

[features]
default = ["parallel"]
Expand Down
71 changes: 14 additions & 57 deletions src/data_structures.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
use ark_ec::PairingEngine;
use ark_ff::bytes::ToBytes;
use ark_serialize::*;
use ark_std::{
io::{self, Result as IoResult},
vec::Vec,
};
use ark_ec::pairing::Pairing;
use ark_serialize::{CanonicalSerialize, *};
use ark_std::vec::Vec;

/// A proof in the GM17 SNARK.
#[derive(PartialEq, Eq, Clone, Default, CanonicalSerialize, CanonicalDeserialize)]
pub struct Proof<E: PairingEngine> {
pub struct Proof<E: Pairing> {
#[doc(hidden)]
pub a: E::G1Affine,
#[doc(hidden)]
Expand All @@ -17,18 +13,9 @@ pub struct Proof<E: PairingEngine> {
pub c: E::G1Affine,
}

impl<E: PairingEngine> ToBytes for Proof<E> {
#[inline]
fn write<W: Write>(&self, mut writer: W) -> io::Result<()> {
self.a.write(&mut writer)?;
self.b.write(&mut writer)?;
self.c.write(&mut writer)
}
}

/// A verification key in the GM17 SNARK.
#[derive(Eq, PartialEq, Clone, CanonicalSerialize, CanonicalDeserialize)]
pub struct VerifyingKey<E: PairingEngine> {
pub struct VerifyingKey<E: Pairing> {
#[doc(hidden)]
pub h_g2: E::G2Affine,
#[doc(hidden)]
Expand All @@ -43,21 +30,7 @@ pub struct VerifyingKey<E: PairingEngine> {
pub query: Vec<E::G1Affine>,
}

impl<E: PairingEngine> ToBytes for VerifyingKey<E> {
fn write<W: Write>(&self, mut writer: W) -> IoResult<()> {
self.h_g2.write(&mut writer)?;
self.g_alpha_g1.write(&mut writer)?;
self.h_beta_g2.write(&mut writer)?;
self.g_gamma_g1.write(&mut writer)?;
self.h_gamma_g2.write(&mut writer)?;
for q in &self.query {
q.write(&mut writer)?;
}
Ok(())
}
}

impl<E: PairingEngine> Default for VerifyingKey<E> {
impl<E: Pairing> Default for VerifyingKey<E> {
fn default() -> Self {
Self {
h_g2: E::G2Affine::default(),
Expand All @@ -72,16 +45,16 @@ impl<E: PairingEngine> Default for VerifyingKey<E> {

/// Preprocessed verification key parameters that enable faster verification
/// at the expense of larger size in memory.
#[derive(PartialEq, Eq, Clone)]
pub struct PreparedVerifyingKey<E: PairingEngine> {
#[derive(PartialEq, Eq, Clone, CanonicalDeserialize, CanonicalSerialize)]
pub struct PreparedVerifyingKey<E: Pairing> {
#[doc(hidden)]
pub vk: VerifyingKey<E>,
#[doc(hidden)]
pub g_alpha: E::G1Affine,
#[doc(hidden)]
pub h_beta: E::G2Affine,
#[doc(hidden)]
pub g_alpha_h_beta_ml: E::Fqk,
pub g_alpha_h_beta_ml: E::TargetField,
#[doc(hidden)]
pub g_gamma_pc: E::G1Prepared,
#[doc(hidden)]
Expand All @@ -92,13 +65,13 @@ pub struct PreparedVerifyingKey<E: PairingEngine> {
pub query: Vec<E::G1Affine>,
}

impl<E: PairingEngine> Default for PreparedVerifyingKey<E> {
impl<E: Pairing> Default for PreparedVerifyingKey<E> {
fn default() -> Self {
Self {
vk: VerifyingKey::default(),
g_alpha: E::G1Affine::default(),
h_beta: E::G2Affine::default(),
g_alpha_h_beta_ml: E::Fqk::default(),
g_alpha_h_beta_ml: E::TargetField::default(),
g_gamma_pc: E::G1Prepared::default(),
h_gamma_pc: E::G2Prepared::default(),
h_pc: E::G2Prepared::default(),
Expand All @@ -107,37 +80,21 @@ impl<E: PairingEngine> Default for PreparedVerifyingKey<E> {
}
}

impl<E: PairingEngine> From<PreparedVerifyingKey<E>> for VerifyingKey<E> {
impl<E: Pairing> From<PreparedVerifyingKey<E>> for VerifyingKey<E> {
fn from(other: PreparedVerifyingKey<E>) -> Self {
other.vk
}
}

impl<E: PairingEngine> From<VerifyingKey<E>> for PreparedVerifyingKey<E> {
impl<E: Pairing> From<VerifyingKey<E>> for PreparedVerifyingKey<E> {
fn from(other: VerifyingKey<E>) -> Self {
crate::prepare_verifying_key(&other)
}
}

impl<E: PairingEngine> ToBytes for PreparedVerifyingKey<E> {
fn write<W: Write>(&self, mut writer: W) -> IoResult<()> {
self.vk.write(&mut writer)?;
self.g_alpha.write(&mut writer)?;
self.h_beta.write(&mut writer)?;
self.g_alpha_h_beta_ml.write(&mut writer)?;
self.g_gamma_pc.write(&mut writer)?;
self.h_gamma_pc.write(&mut writer)?;
self.h_pc.write(&mut writer)?;
for q in &self.query {
q.write(&mut writer)?;
}
Ok(())
}
}

/// Full public (prover and verifier) parameters for the GM17 zkSNARK.
#[derive(PartialEq, Eq, Clone, CanonicalSerialize, CanonicalDeserialize)]
pub struct ProvingKey<E: PairingEngine> {
pub struct ProvingKey<E: Pairing> {
#[doc(hidden)]
pub vk: VerifyingKey<E>,
#[doc(hidden)]
Expand Down
Loading
Loading