22/// the Decider from decider.rs file will be more efficient.
33/// More details can be found at the documentation page:
44/// https://privacy-scaling-explorations.github.io/sonobe-docs/design/nova-decider-onchain.html
5- use ark_bn254:: Bn254 ;
6- use ark_groth16:: Groth16 ;
75use ark_serialize:: { CanonicalDeserialize , CanonicalSerialize } ;
86use ark_snark:: SNARK ;
97use ark_std:: {
@@ -14,17 +12,12 @@ use core::marker::PhantomData;
1412
1513pub use super :: decider_eth_circuit:: DeciderEthCircuit ;
1614use super :: decider_eth_circuit:: DeciderNovaGadget ;
17- use super :: { CommittedInstance , Nova } ;
15+ use super :: Nova ;
1816use crate :: folding:: circuits:: decider:: DeciderEnabledNIFS ;
1917use crate :: folding:: traits:: { InputizeNonNative , WitnessOps } ;
2018use crate :: frontend:: FCircuit ;
21- use crate :: utils:: eth:: ToEth ;
2219use crate :: {
23- commitment:: {
24- kzg:: { Proof as KZGProof , KZG } ,
25- pedersen:: Params as PedersenParams ,
26- CommitmentScheme ,
27- } ,
20+ commitment:: { kzg:: Proof as KZGProof , pedersen:: Params as PedersenParams , CommitmentScheme } ,
2821 folding:: traits:: Dummy ,
2922} ;
3023use crate :: { Curve , Error } ;
4841 kzg_challenges : [ C :: ScalarField ; 2 ] ,
4942}
5043
44+ impl < C , CS , S > Proof < C , CS , S >
45+ where
46+ C : Curve ,
47+ CS : CommitmentScheme < C , ProverChallenge = C :: ScalarField , Challenge = C :: ScalarField > ,
48+ S : SNARK < C :: ScalarField > ,
49+ {
50+ pub fn snark_proof ( & self ) -> & S :: Proof {
51+ & self . snark_proof
52+ }
53+
54+ pub fn kzg_proofs ( & self ) -> & [ CS :: Proof ; 2 ] {
55+ & self . kzg_proofs
56+ }
57+
58+ pub fn cmT ( & self ) -> & C {
59+ & self . cmT
60+ }
61+
62+ pub fn r ( & self ) -> C :: ScalarField {
63+ self . r
64+ }
65+
66+ pub fn kzg_challenges ( & self ) -> [ C :: ScalarField ; 2 ] {
67+ self . kzg_challenges
68+ }
69+ }
70+
5171#[ derive( Debug , Clone , Eq , PartialEq , CanonicalSerialize , CanonicalDeserialize ) ]
5272pub struct VerifierParam < C1 , CS_VerifyingKey , S_VerifyingKey >
5373where
@@ -244,49 +264,19 @@ where
244264 }
245265}
246266
247- /// Prepares solidity calldata for calling the NovaDecider contract
248- #[ allow( clippy:: too_many_arguments) ]
249- pub fn prepare_calldata (
250- function_signature_check : [ u8 ; 4 ] ,
251- i : ark_bn254:: Fr ,
252- z_0 : Vec < ark_bn254:: Fr > ,
253- z_i : Vec < ark_bn254:: Fr > ,
254- running_instance : & CommittedInstance < ark_bn254:: G1Projective > ,
255- incoming_instance : & CommittedInstance < ark_bn254:: G1Projective > ,
256- proof : & Proof < ark_bn254:: G1Projective , KZG < Bn254 > , Groth16 < Bn254 > > ,
257- ) -> Result < Vec < u8 > , Error > {
258- Ok ( [
259- function_signature_check. to_eth ( ) ,
260- i. to_eth ( ) , // i
261- z_0. to_eth ( ) , // z_0
262- z_i. to_eth ( ) , // z_i
263- running_instance. cmW . to_eth ( ) ,
264- running_instance. cmE . to_eth ( ) ,
265- incoming_instance. cmW . to_eth ( ) ,
266- proof. cmT . to_eth ( ) , // cmT
267- proof. r . to_eth ( ) , // r
268- proof. snark_proof . to_eth ( ) , // pA, pB, pC
269- proof. kzg_challenges . to_eth ( ) , // challenge_W, challenge_E
270- proof. kzg_proofs [ 0 ] . eval . to_eth ( ) , // eval W
271- proof. kzg_proofs [ 1 ] . eval . to_eth ( ) , // eval E
272- proof. kzg_proofs [ 0 ] . proof . to_eth ( ) , // W kzg_proof
273- proof. kzg_proofs [ 1 ] . proof . to_eth ( ) , // E kzg_proof
274- ]
275- . concat ( ) )
276- }
277-
278267#[ cfg( test) ]
279268pub mod tests {
280- use ark_bn254:: { Fr , G1Projective as Projective } ;
281- use ark_grumpkin:: Projective as Projective2 ;
282- use std:: time:: Instant ;
283-
284269 use super :: * ;
270+ use crate :: commitment:: kzg:: KZG ;
285271 use crate :: commitment:: pedersen:: Pedersen ;
286272 use crate :: folding:: nova:: { PreprocessorParam , ProverParams as NovaProverParams } ;
287273 use crate :: folding:: traits:: CommittedInstanceOps ;
288274 use crate :: frontend:: utils:: CubicFCircuit ;
289275 use crate :: transcript:: poseidon:: poseidon_canonical_config;
276+ use ark_bn254:: { Bn254 , Fr , G1Projective as Projective } ;
277+ use ark_groth16:: Groth16 ;
278+ use ark_grumpkin:: Projective as Projective2 ;
279+ use std:: time:: Instant ;
290280
291281 #[ test]
292282 fn test_decider ( ) -> Result < ( ) , Error > {
0 commit comments