Skip to content

Commit

Permalink
change RlpCircuitBuilder to pub RlcCircuitBuilder (#23)
Browse files Browse the repository at this point in the history
* change RlpCircuitBuilder to pub RlcCircuitBuilder

* proof gen test added
  • Loading branch information
goforashutosh authored Nov 13, 2023
1 parent 2d3a933 commit c09477a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion axiom-eth/src/rlp/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ mod circuit_builder {
}

/// A wrapper around RlcCircuitBuilder where Gate is replaced by Range in the circuit
pub struct RlpCircuitBuilder<F: ScalarField, FnPhase1>(RlcCircuitBuilder<F, FnPhase1>)
pub struct RlpCircuitBuilder<F: ScalarField, FnPhase1>(pub RlcCircuitBuilder<F, FnPhase1>)
where
FnPhase1: FnSynthesize<F>;

Expand Down
50 changes: 50 additions & 0 deletions axiom-eth/src/rlp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,56 @@ mod rlp {
MockProver::run(k, &circuit, vec![]).unwrap().assert_satisfied();
}

#[test]
pub fn test_proofgen_rlp_field() {
let k = DEGREE;
let input_bytes: Vec<u8> =
Vec::from_hex("a012341234123412341234123412341234123412341234123412341234123412340000")
.unwrap();

let mut rng = StdRng::from_seed([0u8; 32]);
let params = ParamsKZG::<Bn256>::setup(k, &mut rng);
let circuit = rlp_string_circuit(RlcThreadBuilder::<Fr>::keygen(), input_bytes.clone(), 34);
circuit.config(k as usize, Some(6));

println!("vk gen started");
let vk = keygen_vk(&params, &circuit).unwrap();
println!("vk gen done");
let pk = keygen_pk(&params, vk, &circuit).unwrap();
println!("pk gen done");
println!();
println!("==============STARTING PROOF GEN===================");
let break_points = circuit.0.break_points.take();
drop(circuit);
let circuit = rlp_string_circuit(RlcThreadBuilder::<Fr>::prover(), input_bytes, 34);
*circuit.0.break_points.borrow_mut() = break_points;

let mut transcript = Blake2bWrite::<_, _, Challenge255<_>>::init(vec![]);
create_proof::<
KZGCommitmentScheme<Bn256>,
ProverSHPLONK<'_, Bn256>,
Challenge255<G1Affine>,
_,
Blake2bWrite<Vec<u8>, G1Affine, Challenge255<G1Affine>>,
_,
>(&params, &pk, &[circuit], &[&[]], rng, &mut transcript)
.unwrap();
let proof = transcript.finalize();
println!("proof gen done");
let verifier_params = params.verifier_params();
let strategy = SingleStrategy::new(verifier_params);
let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]);
verify_proof::<
KZGCommitmentScheme<Bn256>,
VerifierSHPLONK<'_, Bn256>,
Challenge255<G1Affine>,
Blake2bRead<&[u8], G1Affine, Challenge255<G1Affine>>,
SingleStrategy<'_, Bn256>,
>(verifier_params, pk.get_vk(), strategy, &[&[]], &mut transcript)
.unwrap();
println!("verify done");
}

#[test]
pub fn test_mock_rlp_short_field() {
let k = DEGREE;
Expand Down

0 comments on commit c09477a

Please sign in to comment.