@@ -31,7 +31,7 @@ use ed25519::signature::Verifier;
3131use sha2:: Digest ;
3232use ed25519:: signature:: { Signature , Verifier } ;
3333use std:: sync:: Arc ;
34- use ton_types:: { BuilderData , error, GasConsumer , ExceptionCode , UInt256 } ;
34+ use ton_types:: { BuilderData , Cell , error, GasConsumer , ExceptionCode , UInt256 } ;
3535
3636use crusty3_zk:: { groth16:: { verify_proof, prepare_verifying_key, Parameters , verify_groth16_proof_from_byteblob} ,
3737 bls:: { Bls12 , Fr }
@@ -83,15 +83,34 @@ pub(super) fn execute_sha256u(engine: &mut Engine) -> Status {
8383 }
8484}
8585
86+ pub fn obtain_cells_data ( cl : Cell ) -> Result < Vec < u8 > , Failure > {
87+ let mut byte_blob = Vec :: new ( ) ;
88+ let mut queue = vec ! ( cl. clone( ) ) ;
89+ while let Some ( cell) = queue. pop ( ) {
90+ let this_reference_data = cell. data ( ) ;
91+
92+ byte_blob. extend ( this_reference_data[ 0 ..this_reference_data. len ( ) -1 ] . iter ( ) . copied ( ) ) ;
93+
94+ let count = cell. references_count ( ) ;
95+ for i in 0 ..count {
96+ queue. push ( cell. reference ( i) ?) ;
97+ }
98+ }
99+
100+ Ok ( byte_blob)
101+ }
102+
86103pub ( super ) fn execute_vergrth16 ( engine : & mut Engine ) -> Failure {
87104 engine. load_instruction ( Instruction :: new ( "VERGRTH16" ) )
88105 . and_then ( |ctx| fetch_stack ( ctx, 1 ) )
89106 . and_then ( |ctx| {
90107 let builder = BuilderData :: from ( ctx. engine . cmd . var ( 0 ) . as_cell ( ) ?) ;
91108 let cell_proof_data_length = builder. length_in_bits ( ) ;
92- //let data = builder.data();
109+
93110 let cell_proof = ctx. engine . finalize_cell ( builder) ?;
94- let cell_proof_data = cell_proof. data ( ) ;
111+
112+ let mut cell_proof_data = obtain_cells_data ( cell_proof) . unwrap ( ) ;
113+
95114 if cell_proof_data_length % 8 == 0 {
96115
97116 let result = verify_groth16_proof_from_byteblob :: < Bls12 > ( & cell_proof_data[ ..] ) . unwrap ( ) ;
0 commit comments