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

Implement circuit asserting that points aren't at infinity and public key isn't the neg generator point #339

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
211d09e
Implement tests cases for bls12_381_components_proofs against ethereu…
NikolayKostadinov21 May 27, 2024
88614e5
Update bls_components and shell to run the tests in it - still wip, i…
NikolayKostadinov21 May 27, 2024
6ccdfd1
build(bls_components) Made little changes needed for bls_components t…
NikolayKostadinov21 May 28, 2024
0f2ed35
fix(run_bls12_381_component_proofs.sh) Fix the navigation in the root…
NikolayKostadinov21 May 28, 2024
bb7959a
fix: Use unchecked deserialization for G1 & G2
NikolayKostadinov21 May 28, 2024
f92897e
fix: Use unchecked deserialization for G1 & G2 in bls_components.rs
NikolayKostadinov21 May 28, 2024
6170454
miller loop putted outside main bls12381 component proof function
NikolayKostadinov21 May 31, 2024
53c140a
Add helper comments for verify_bls_at_infinity circuit
NikolayKostadinov21 May 31, 2024
d315a09
Implement tests cases for bls12_381_components_proofs against ethereu…
NikolayKostadinov21 May 27, 2024
414d68a
Update bls_components and shell to run the tests in it - still wip, i…
NikolayKostadinov21 May 27, 2024
16bd669
build(bls_components) Made little changes needed for bls_components t…
NikolayKostadinov21 May 28, 2024
a6818ee
fix(run_bls12_381_component_proofs.sh) Fix the navigation in the root…
NikolayKostadinov21 May 28, 2024
7e3adc4
fix: Use unchecked deserialization for G1 & G2
NikolayKostadinov21 May 28, 2024
de89491
fix: Use unchecked deserialization for G1 & G2 in bls_components.rs
NikolayKostadinov21 May 28, 2024
e4bef3c
miller loop putted outside main bls12381 component proof function
NikolayKostadinov21 May 31, 2024
a43c151
Add helper comments for verify_bls_at_infinity circuit
NikolayKostadinov21 May 31, 2024
8570b01
Rebase main over improve_integration_of_starky_safe
NikolayKostadinov21 May 31, 2024
899ef7a
Implement point at infinity assert after g1 and g2 points are checked
NikolayKostadinov21 May 31, 2024
5fa50ea
Remove redundant file from lib.rs
NikolayKostadinov21 May 31, 2024
9258786
Start test implementation against points at infinity
NikolayKostadinov21 May 31, 2024
ee22588
Add test for bls12_381 circuit
NikolayKostadinov21 Jun 3, 2024
c3cee46
Implement assert if g1 OR g2 point is at infinity
NikolayKostadinov21 Jun 3, 2024
006fa57
Implement circuit asserting g1 and g2 point aren't at infinity and pk…
NikolayKostadinov21 Jun 3, 2024
0ade2ab
Rebase over main
NikolayKostadinov21 Jun 3, 2024
f21c2dd
Refactor bls12_381 and bls12_381_components_proofs based on changes p…
NikolayKostadinov21 Jun 10, 2024
1c9f33b
Refactor test_bls12_381_circuit in VerifyIsNotAtInfinityCircuit
NikolayKostadinov21 Jun 10, 2024
467d8f4
Improve test_bls12_381_circuit
NikolayKostadinov21 Jun 10, 2024
7dde05c
Remove verification of proofs in `VerifyIsNotAtInfinityCircuit` since…
NikolayKostadinov21 Jun 10, 2024
7fceb12
Fix error in test_bls12_381_circuit
NikolayKostadinov21 Jun 10, 2024
a31af64
Refactor VerifyIsNotAtInfinityCircuit but tests are not failling as e…
NikolayKostadinov21 Jun 10, 2024
8155600
Refactor VerifyIsNotAtInfinityCircuit but test isn't successful
NikolayKostadinov21 Jun 11, 2024
9dddfa1
Finish VerifyIsNotAtInfinityCircuit and make tests pass successfully
NikolayKostadinov21 Jun 12, 2024
38e716e
Implement helper functions for tests for VerifyIsNotAtInfinityCircuit…
NikolayKostadinov21 Jun 12, 2024
b044674
Fix path in run_bls12_381_component_proofs script
NikolayKostadinov21 Jun 13, 2024
9d7f27b
Address PR comments
NikolayKostadinov21 Jun 17, 2024
ec0c87c
Revert "Address PR comments"
NikolayKostadinov21 Jun 17, 2024
5a5e491
Revert circom-pairing update
NikolayKostadinov21 Jun 17, 2024
afdc20b
Revert circom-pairing update
NikolayKostadinov21 Jun 17, 2024
23650de
Merge branch 'improve_integration_of_starky_safe' of github.com:metac…
NikolayKostadinov21 Jun 17, 2024
14c0e16
Update gitmodules
NikolayKostadinov21 Jun 24, 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
1 change: 1 addition & 0 deletions beacon-light-client/plonky2/.gitignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ gnark_plonky2_verifier/DendrETH
gnark_plonky2_verifier/circuit/srs_setup
gnark_plonky2_verifier/circuit/solidity_bytes.bin
gnark_plonky2_verifier/public_witness.bin
circuits_executables/
4 changes: 4 additions & 0 deletions beacon-light-client/plonky2/crates/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ edition.workspace = true
[dependencies]
circuit = { path = "../circuit" }
circuits = { path = "../circuits" }
redis = { version = "0.23", features = ["aio", "async-std-comp", "connection-manager", "json"] }
redis = { version = "0.23", features = [
"aio",
"async-std-comp",
"connection-manager",
"json",
] }
num = { version = "0.4.0", features = ["serde"] }
plonky2 = { git = "https://github.com/metacraft-labs/plonky2" }
starky = { git = "https://github.com/metacraft-labs/plonky2" }
plonky2-circuit-serializer = { git = "https://github.com/metacraft-labs/plonky2-circuit-serializer" }
starky_bls12_381 = { git = "https://github.com/metacraft-labs/starky_bls12_381" }
serde = "1.0.164"
serde_json = "1.0.96"
serde_yaml = "0.9.34"
anyhow = "1.0.71"
hex = "0.4.3"
redis-work-queue = "0.1.3"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::Result;
use circuit::SerdeCircuitTarget;
use circuit_executables::{
bls_components::{set_bls_witness, BlsComponents, BlsProofs, Input},
constants::SERIALIZED_CIRCUITS_DIR,
crud::{
common::{load_circuit_data_starky, load_common_circuit_data_starky, read_from_file},
Expand All @@ -12,8 +13,8 @@ use circuits::bls_verification::bls12_381_circuit::BlsCircuitTargets;
use futures_lite::future;

use plonky2::{
field::{goldilocks_field::GoldilocksField, types::Field},
iop::witness::{PartialWitness, WitnessWrite},
field::goldilocks_field::GoldilocksField,
iop::witness::PartialWitness,
plonk::{config::PoseidonGoldilocksConfig, proof::ProofWithPublicInputs},
util::serialization::Buffer,
};
Expand Down Expand Up @@ -41,44 +42,33 @@ async fn async_main() -> Result<()> {

let mut proof_storage = create_proof_storage(&matches).await;

let mut pw = PartialWitness::<GoldilocksField>::new();

pw.set_target_arr(
&targets.pubkey,
&hex::decode(pubkey)
.unwrap()
.iter()
.map(|x| GoldilocksField::from_canonical_usize(*x as usize))
.collect::<Vec<GoldilocksField>>(),
);
pw.set_target_arr(
&targets.sig,
&hex::decode(signature)
.unwrap()
.iter()
.map(|x| GoldilocksField::from_canonical_usize(*x as usize))
.collect::<Vec<GoldilocksField>>(),
);
pw.set_target_arr(
&targets.msg,
&hex::decode(msg)
.unwrap()
.iter()
.map(|x| GoldilocksField::from_canonical_usize(*x as usize))
.collect::<Vec<GoldilocksField>>(),
);

let (pp1, pp2) = get_pairing_precomp_proofs(&mut proof_storage).await;
let (ml1, ml2) = get_miller_loop_proofs(&mut proof_storage).await;
let (pairing_prec_proof1, pairing_prec_proof2) =
get_pairing_precomp_proofs(&mut proof_storage).await;
let (miller_loop_proof1, miller_loop_proof2) = get_miller_loop_proofs(&mut proof_storage).await;
let fp12_mul_proof = get_fp12_mul_proof(&mut proof_storage).await;
let final_exp_proof = get_final_exp_proof(&mut proof_storage).await;

pw.set_proof_with_pis_target(&targets.pt_pp1, &pp1);
pw.set_proof_with_pis_target(&targets.pt_pp2, &pp2);
pw.set_proof_with_pis_target(&targets.pt_ml1, &ml1);
pw.set_proof_with_pis_target(&targets.pt_ml2, &ml2);
pw.set_proof_with_pis_target(&targets.pt_fp12m, &fp12_mul_proof);
pw.set_proof_with_pis_target(&targets.pt_fe, &final_exp_proof);
let mut pw = PartialWitness::<GoldilocksField>::new();
set_bls_witness(
&mut pw,
&targets,
&BlsComponents {
input: Input {
pubkey: pubkey.to_string(),
signature: signature.to_string(),
message: msg.to_string(),
},
output: true,
},
&BlsProofs {
pairing_prec_proof1,
pairing_prec_proof2,
miller_loop_proof2,
miller_loop_proof1,
fp12_mul_proof,
final_exp_proof,
},
);

println!("Starting proof generation");

Expand Down
Loading