@@ -31,7 +31,7 @@ use ed25519::signature::Verifier;
31
31
use sha2:: Digest ;
32
32
use ed25519:: signature:: { Signature , Verifier } ;
33
33
use std:: sync:: Arc ;
34
- use ton_types:: { BuilderData , error, GasConsumer , ExceptionCode , UInt256 } ;
34
+ use ton_types:: { BuilderData , Cell , error, GasConsumer , ExceptionCode , UInt256 } ;
35
35
36
36
use crusty3_zk:: { groth16:: { verify_proof, prepare_verifying_key, Parameters , verify_groth16_proof_from_byteblob} ,
37
37
bls:: { Bls12 , Fr }
@@ -83,15 +83,34 @@ pub(super) fn execute_sha256u(engine: &mut Engine) -> Status {
83
83
}
84
84
}
85
85
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
+
86
103
pub ( super ) fn execute_vergrth16 ( engine : & mut Engine ) -> Failure {
87
104
engine. load_instruction ( Instruction :: new ( "VERGRTH16" ) )
88
105
. and_then ( |ctx| fetch_stack ( ctx, 1 ) )
89
106
. and_then ( |ctx| {
90
107
let builder = BuilderData :: from ( ctx. engine . cmd . var ( 0 ) . as_cell ( ) ?) ;
91
108
let cell_proof_data_length = builder. length_in_bits ( ) ;
92
- //let data = builder.data();
109
+
93
110
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
+
95
114
if cell_proof_data_length % 8 == 0 {
96
115
97
116
let result = verify_groth16_proof_from_byteblob :: < Bls12 > ( & cell_proof_data[ ..] ) . unwrap ( ) ;
0 commit comments