Content-Length: 386056 | pFad | http://github.com/a16z/jolt/pull/431/commits/ab84dca92ee41b1d286f6b16cca966db76451924

89 WIP: HyperKZG verifier circuit by imikushin · Pull Request #431 · a16z/jolt · GitHub
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

WIP: HyperKZG verifier circuit #431

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
610cac0
HyperKZG verifier circuit: get started
imikushin Jul 12, 2024
39c14de
WIP: HyperKZGVerifierGadget
imikushin Jul 25, 2024
d948df5
WIP: PairingGadget
imikushin Jul 28, 2024
2143514
WIP: PairingGadget: it compiles!
imikushin Jul 29, 2024
9931385
WIP: PairingGadget: test circuit compiles and runs (extremely slowly)
imikushin Jul 29, 2024
d2f7171
print out the number of constraints as they get synthesized
imikushin Jul 29, 2024
925c4ec
ignore the heavy test
imikushin Jul 29, 2024
a73c445
WIP: DelayedPairingCircuit
imikushin Aug 2, 2024
2f495c0
WIP: DelayedPairingCircuit
imikushin Aug 3, 2024
8e6b3d4
WIP: LoadedSNARK
imikushin Aug 3, 2024
5fa5e48
WIP: LoadedSNARK
imikushin Aug 3, 2024
f1ed212
WIP: LoadedSNARK trait
imikushin Aug 3, 2024
f1e7f39
WIP: LoadedSNARK trait
imikushin Aug 4, 2024
3f4313e
OffloadedSNARK trait
imikushin Aug 4, 2024
ab84dca
WIP: implement OffloadedSNARK trait for a demo circuit
imikushin Aug 4, 2024
3bd319f
Offloaded circuit successfully verifies
imikushin Aug 5, 2024
18b9886
Offloaded SNARK takes shape
imikushin Aug 7, 2024
6a5aa97
OffloadedSNARK: move to module `snark`
imikushin Aug 7, 2024
2020be1
OffloadedSNARK: cleanup
imikushin Aug 7, 2024
b940345
OffloadedSNARK: OffloadedMSM gadget
imikushin Aug 8, 2024
8d305c8
OffloadedSNARK: OffloadedMSM gadget works
imikushin Aug 9, 2024
517c865
WIP: HyperKZG gadget
imikushin Aug 10, 2024
9579c31
WIP: HyperKZG gadget
imikushin Aug 11, 2024
b045294
MockSponge
imikushin Aug 11, 2024
b64d33a
Fix point assignment
imikushin Aug 11, 2024
715349b
Return public input vector based on expected result
imikushin Aug 11, 2024
ee33022
WIP: HyperKZG gadget
imikushin Aug 14, 2024
e6b81ae
WIP: HyperKZG gadget
imikushin Aug 14, 2024
f988dde
WIP: HyperKZG gadget: adjust type parameters in OffloadedDataCircuit
imikushin Aug 14, 2024
23b474f
WIP: HyperKZG gadget: factor out MSMGadget trait
imikushin Aug 14, 2024
395c891
WIP: HyperKZG gadget: prep to use OffloadedMSMGadget
imikushin Aug 14, 2024
b475d84
WIP: HyperKZG verifier test: migrate to OffloadedSNARK
imikushin Aug 14, 2024
3433150
WIP: HyperKZG verifier: the only thing left is the pairing
imikushin Aug 15, 2024
f421225
WIP: HyperKZG verifier: remove some debugging statements
imikushin Aug 15, 2024
31e87a4
WIP: HyperKZG verifier: add G2 elements to OffloadSNARKVerifyingKey
imikushin Aug 16, 2024
4ab444d
WIP: HyperKZG verifier: make pairings work
imikushin Aug 18, 2024
b7e983a
WIP: HyperKZG verifier: offload pairings data
imikushin Aug 19, 2024
70a65c3
HyperKZG verifier works with offloaded data
imikushin Aug 20, 2024
678b04d
Remove unneeded code
imikushin Aug 20, 2024
ae0e9cf
Cleanup warnings
imikushin Aug 21, 2024
2cedc18
Merge branch 'main' into hyperkzg-circuit
imikushin Aug 21, 2024
486cd61
Merge branch 'main' into hyperkzg-circuit
imikushin Aug 21, 2024
6565391
Cleanup lints
imikushin Aug 21, 2024
2904552
Remove commented out code
imikushin Aug 21, 2024
c9aa0e9
Port transcript changes
imikushin Aug 21, 2024
8bb1a29
Port transcript changes: make it work
imikushin Aug 21, 2024
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
Prev Previous commit
Next Next commit
WIP: implement OffloadedSNARK trait for a demo circuit
  • Loading branch information
imikushin committed Aug 4, 2024
commit ab84dca92ee41b1d286f6b16cca966db76451924
64 changes: 57 additions & 7 deletions jolt-core/src/circuits/groups/curves/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::circuits::pairing::PairingGadget;

Check failure on line 1 in jolt-core/src/circuits/groups/curves/mod.rs

View workflow job for this annotation

GitHub Actions / Onchain Verifier Tests

unused import: `crate::circuits::pairing::PairingGadget`

Check failure on line 1 in jolt-core/src/circuits/groups/curves/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `crate::circuits::pairing::PairingGadget`

Check failure on line 1 in jolt-core/src/circuits/groups/curves/mod.rs

View workflow job for this annotation

GitHub Actions / test

unused import: `crate::circuits::pairing::PairingGadget`

pub mod short_weierstrass;

Expand All @@ -7,13 +7,14 @@
use super::*;
use crate::circuits::groups::curves::short_weierstrass::bn254::G1Var;
use crate::circuits::groups::curves::short_weierstrass::{AffineVar, ProjectiveVar};
use crate::circuits::{OffloadedSNARK, OffloadedSNARKError, OffloadedSNARKVerifyingKey};
use ark_bls12_381::Bls12_381;
use ark_bn254::{Bn254, Fq, Fr};
use ark_crypto_primitives::snark::{CircuitSpecificSetupSNARK, SNARK};
use ark_crypto_primitives::sponge::Absorb;
use ark_ec::bn::G1Projective;
use ark_ec::pairing::Pairing;
use ark_ec::short_weierstrass::{Projective, SWCurveConfig};
use ark_ec::short_weierstrass::{Affine, Projective, SWCurveConfig};
use ark_ec::{CurveGroup, Group};
use ark_ff::{PrimeField, ToConstraintField};
use ark_groth16::Groth16;
Expand All @@ -23,13 +24,14 @@
use ark_r1cs_std::ToConstraintFieldGadget;
use ark_relations::ns;
use ark_relations::r1cs::{ConstraintSynthesizer, ConstraintSystemRef, SynthesisError};
use ark_serialize::CanonicalSerialize;
use ark_serialize::{CanonicalSerialize, SerializationError};
use ark_std::marker::PhantomData;
use ark_std::rand::Rng;
use ark_std::rc::Rc;
use ark_std::sync::RwLock;
use ark_std::{end_timer, start_timer, test_rng, UniformRand};
use itertools::Itertools;
use rand_core::{RngCore, SeedableRng};
use std::sync::{Arc, RwLock};
use rand_core::{CryptoRng, RngCore, SeedableRng};

struct DelayedPairingCircuit<E, G1Var>
where
Expand All @@ -43,7 +45,8 @@
d: Option<E::ScalarField>,

// public inputs
r_g1: Arc<RwLock<Option<E::G1>>>,
r_g1: Rc<RwLock<Option<E::G1>>>,
g1s: Rc<RwLock<Option<Vec<E::G1>>>>,
}

impl<E, G1Var> ConstraintSynthesizer<E::ScalarField> for DelayedPairingCircuit<E, G1Var>
Expand Down Expand Up @@ -105,15 +108,60 @@
}
}

struct DelayedPairingCircuitSNARK<E, P, S, G1Var>
where
E: Pairing,
P: SWCurveConfig<BaseField: PrimeField>,
S: SNARK<E::ScalarField>,
G1Var: CurveVar<E::G1, E::ScalarField>,
{
_params: PhantomData<(E, P, S, G1Var)>,
}

impl<E, P, S, G1Var> OffloadedSNARK<E, P, S> for DelayedPairingCircuitSNARK<E, P, S, G1Var>
where
E: Pairing<G1Affine = Affine<P>, BaseField = P::BaseField, ScalarField = P::ScalarField>,
P: SWCurveConfig<BaseField: PrimeField>,
S: SNARK<E::ScalarField>,
G1Var: CurveVar<E::G1, E::ScalarField> + ToConstraintFieldGadget<E::ScalarField>,
{
type Circuit = DelayedPairingCircuit<E, G1Var>;

fn prove<R: RngCore + CryptoRng>(
circuit_pk: &S::ProvingKey,
circuit: Self::Circuit,
rng: &mut R,
) -> Result<S::Proof, OffloadedSNARKError<E, S>> {
// TODO place the G1 elements into the public input

let proof = S::prove(circuit_pk, circuit, rng)
.map_err(|e| OffloadedSNARKError::SNARKError(e))?;

Ok(proof)
}

fn g2_elements(
vk: &OffloadedSNARKVerifyingKey<E, S>,
public_input: &[<E as Pairing>::ScalarField],
proof: &S::Proof,
) -> Result<Vec<Vec<E::G2>>, SerializationError> {
// TODO get the G2 elements from the verifying key
Ok(vec![])
}
}

#[test]
fn test_delayed_pairing_circuit() {
type DemoCircuit = DelayedPairingCircuit<Bn254, G1Var>;

type DemoCircuitSNARK = DelayedPairingCircuitSNARK<Bn254, Bn254, Groth16<Bn254>, G1Var>;

let circuit = DemoCircuit {
_params: PhantomData,
w_g1: [None; 3],
d: None,
r_g1: Arc::new(RwLock::new(None)),
r_g1: Rc::new(RwLock::new(None)),
g1s: Rc::new(Default::default()),
};

// This is not cryptographically safe, use
Expand All @@ -128,12 +176,14 @@
let pvk = Groth16::<Bn254>::process_vk(&vk).unwrap();
end_timer!(process_vk_timer);

let r_g1_lock = Arc::new(RwLock::new(None));
let r_g1_lock = Rc::new(RwLock::new(None));
let g1s = Rc::new(RwLock::new(None));
let c_init_values = DemoCircuit {
_params: PhantomData,
w_g1: [Some(rng.gen()); 3],
d: Some(rng.gen()),
r_g1: r_g1_lock.clone(),
g1s: g1s.clone(),
};

let prove_timer = start_timer!(|| "Groth16::prove");
Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/a16z/jolt/pull/431/commits/ab84dca92ee41b1d286f6b16cca966db76451924

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy