@@ -33,7 +33,7 @@ use ton_block::GlobalCapabilities;
33
33
use sha2:: Digest ;
34
34
use ed25519:: signature:: { Signature , Verifier } ;
35
35
use std:: sync:: Arc ;
36
- use ton_types:: { BuilderData , error, GasConsumer , ExceptionCode , UInt256 } ;
36
+ use ton_types:: { BuilderData , Cell , error, GasConsumer , ExceptionCode , UInt256 } ;
37
37
38
38
use crusty3_zk:: { groth16:: { verify_proof, prepare_verifying_key, Parameters , verify_groth16_proof_from_byteblob} ,
39
39
bls:: { Bls12 , Fr }
@@ -89,15 +89,34 @@ pub(super) fn execute_sha256u(engine: &mut Engine) -> Status {
89
89
}
90
90
}
91
91
92
+ pub fn obtain_cells_data ( cl : Cell ) -> Result < Vec < u8 > , Failure > {
93
+ let mut byte_blob = Vec :: new ( ) ;
94
+ let mut queue = vec ! ( cl. clone( ) ) ;
95
+ while let Some ( cell) = queue. pop ( ) {
96
+ let this_reference_data = cell. data ( ) ;
97
+
98
+ byte_blob. extend ( this_reference_data[ 0 ..this_reference_data. len ( ) -1 ] . iter ( ) . copied ( ) ) ;
99
+
100
+ let count = cell. references_count ( ) ;
101
+ for i in 0 ..count {
102
+ queue. push ( cell. reference ( i) ?) ;
103
+ }
104
+ }
105
+
106
+ Ok ( byte_blob)
107
+ }
108
+
92
109
pub ( super ) fn execute_vergrth16 ( engine : & mut Engine ) -> Failure {
93
110
engine. load_instruction ( Instruction :: new ( "VERGRTH16" ) )
94
111
. and_then ( |ctx| fetch_stack ( ctx, 1 ) )
95
112
. and_then ( |ctx| {
96
113
let builder = BuilderData :: from ( ctx. engine . cmd . var ( 0 ) . as_cell ( ) ?) ;
97
114
let cell_proof_data_length = builder. length_in_bits ( ) ;
98
- //let data = builder.data();
115
+
99
116
let cell_proof = ctx. engine . finalize_cell ( builder) ?;
100
- let cell_proof_data = cell_proof. data ( ) ;
117
+
118
+ let mut cell_proof_data = obtain_cells_data ( cell_proof) . unwrap ( ) ;
119
+
101
120
if cell_proof_data_length % 8 == 0 {
102
121
103
122
let result = verify_groth16_proof_from_byteblob :: < Bls12 > ( & cell_proof_data[ ..] ) . unwrap ( ) ;
0 commit comments