1- use super :: AssignedBlobDataExport ;
1+ #[ cfg( test) ]
2+ mod tests;
3+
4+ use super :: { AssignedBlobDataExport , BlobDataConfig } ;
25use crate :: { BatchData , RlcConfig } ;
36use eth_types:: { H256 , U256 } ;
7+ use ethers_core:: utils:: keccak256;
48use halo2_base:: { gates:: range:: RangeConfig , AssignedValue , Context } ;
59use halo2_ecc:: bigint:: CRTInteger ;
6- use halo2_proofs:: halo2curves:: bls12_381:: Scalar ;
710use halo2_proofs:: {
811 circuit:: { AssignedCell , Layouter , Value } ,
9- halo2curves:: bn256:: Fr ,
12+ halo2curves:: { bls12_381 :: Scalar , bn256:: Fr } ,
1013 plonk:: { ConstraintSystem , Error , Expression } ,
1114} ;
1215use snark_verifier_sdk:: LIMBS ;
@@ -15,16 +18,20 @@ use zkevm_circuits::{table::U8Table, util::Challenges};
1518pub const BLOB_WIDTH : usize = 4096 ;
1619
1720#[ derive( Debug , Clone ) ]
18- pub struct BlobConsistencyConfig < const N_SNARKS : usize > { }
21+ pub struct BlobConsistencyConfig < const N_SNARKS : usize > {
22+ data : BlobDataConfig < N_SNARKS > ,
23+ }
1924
2025impl < const N_SNARKS : usize > BlobConsistencyConfig < N_SNARKS > {
2126 pub fn construct (
22- _meta : & mut ConstraintSystem < Fr > ,
23- _challenges : & Challenges < Expression < Fr > > ,
24- _u8_table : U8Table ,
27+ meta : & mut ConstraintSystem < Fr > ,
28+ challenges : & Challenges < Expression < Fr > > ,
29+ u8_table : U8Table ,
2530 _: RangeConfig < Fr > ,
2631 ) -> Self {
27- unimplemented ! ( )
32+ Self {
33+ data : BlobDataConfig :: configure ( meta, challenges, u8_table) ,
34+ }
2835 }
2936
3037 pub fn assign_barycentric (
@@ -33,58 +40,83 @@ impl<const N_SNARKS: usize> BlobConsistencyConfig<N_SNARKS> {
3340 _bytes : & [ u8 ] ,
3441 _challenge : U256 ,
3542 ) -> AssignedBarycentricEvaluationConfig {
36- unimplemented ! ( )
43+ AssignedBarycentricEvaluationConfig :: default ( )
3744 }
3845
3946 pub fn assign_blob_data (
4047 & self ,
41- _layouter : & mut impl Layouter < Fr > ,
42- _challenge_value : Challenges < Value < Fr > > ,
43- _rlc_config : & RlcConfig ,
44- _blob_bytes : & [ u8 ] ,
48+ layouter : & mut impl Layouter < Fr > ,
49+ challenge_value : Challenges < Value < Fr > > ,
50+ rlc_config : & RlcConfig ,
51+ blob_bytes : & [ u8 ] ,
4552 ) -> Result < AssignedBlobDataExport , Error > {
46- unimplemented ! ( )
53+ let export = self
54+ . data
55+ . assign ( layouter, challenge_value, rlc_config, blob_bytes) ;
56+
57+ // rlc_config.lookup_keccak_rlcs(
58+ // region: &mut Region<Fr>,
59+ // input_rlcs: &AssignedCell<Fr, Fr>,
60+ // output_rlcs: &AssignedCell<Fr, Fr>,
61+ // data_len: &export.cooked_len,
62+ // offset: &mut usize,
63+ // )
64+
65+ export
66+
67+ // region: &mut Region<Fr>,
68+ // input_rlcs: &AssignedCell<Fr, Fr>,
69+ // output_rlcs: &AssignedCell<Fr, Fr>,
70+ // data_len: &AssignedCell<Fr, Fr>,
71+ // offset: &mut usize,
72+
73+ // config.rlc_config.mul(
74+ // &mut region,
75+ // &blob_data_exports.bytes_rlc,
76+ // &disable_encoding,
77+ // &mut rlc_config_offset,
78+ // )?,
4779 }
4880
4981 pub fn link (
5082 _layouter : & mut impl Layouter < Fr > ,
5183 _blob_crts_limbs : & [ [ AssignedCell < Fr , Fr > ; LIMBS ] ] ,
5284 _barycentric_crts : & [ CRTInteger < Fr > ] ,
5385 ) -> Result < ( ) , Error > {
54- unimplemented ! ( )
86+ Ok ( ( ) )
5587 }
5688}
5789
5890#[ derive( Debug , Clone , Copy , Default ) ]
5991pub struct BlobConsistencyWitness {
6092 blob_versioned_hash : H256 ,
61- challenge_digest : H256 ,
62- evaluation : Scalar ,
6393}
6494
6595impl BlobConsistencyWitness {
66- pub fn new < const N_SNARKS : usize > ( _bytes : & [ u8 ] , _batch_data : & BatchData < N_SNARKS > ) -> Self {
67- unimplemented ! ( )
96+ pub fn new < const N_SNARKS : usize > ( bytes : & [ u8 ] , _batch_data : & BatchData < N_SNARKS > ) -> Self {
97+ Self {
98+ blob_versioned_hash : keccak256 ( bytes) . into ( ) ,
99+ }
68100 }
69101
70102 pub fn id ( & self ) -> H256 {
71- unimplemented ! ( )
103+ self . blob_versioned_hash
72104 }
73105
74106 pub fn challenge_digest ( & self ) -> U256 {
75- unimplemented ! ( )
107+ Default :: default ( )
76108 }
77109
78110 pub fn challenge ( & self ) -> Scalar {
79- unimplemented ! ( )
111+ Default :: default ( )
80112 }
81113
82114 pub fn evaluation ( & self ) -> Scalar {
83- unimplemented ! ( )
115+ Default :: default ( )
84116 }
85117
86118 pub fn blob_data_proof ( & self ) -> [ H256 ; 2 ] {
87- unimplemented ! ( )
119+ Default :: default ( )
88120 }
89121}
90122
0 commit comments