@@ -25,11 +25,20 @@ use crate::{
2525 } ,
2626 types:: { Exception , Status }
2727} ;
28+
29+ use crusty3_zk:: create_random_proof;
2830use ed25519:: signature:: Verifier ;
2931use std:: borrow:: Cow ;
3032use ton_block:: GlobalCapabilities ;
33+ use sha2:: Digest ;
34+ use ed25519:: signature:: { Signature , Verifier } ;
35+ use std:: sync:: Arc ;
3136use ton_types:: { BuilderData , error, GasConsumer , ExceptionCode , UInt256 } ;
3237
38+ use crusty3_zk:: { groth16:: { verify_proof, prepare_verifying_key, Parameters } ,
39+ bls:: { Bls12 , Fr }
40+ } ;
41+
3342const PUBLIC_KEY_BITS : usize = PUBLIC_KEY_BYTES * 8 ;
3443const SIGNATURE_BITS : usize = SIGNATURE_BYTES * 8 ;
3544const PUBLIC_KEY_BYTES : usize = ed25519_dalek:: PUBLIC_KEY_LENGTH ;
@@ -80,6 +89,34 @@ pub(super) fn execute_sha256u(engine: &mut Engine) -> Status {
8089 }
8190}
8291
92+ pub ( super ) fn execute_vergrth16 ( engine : & mut Engine ) -> Failure {
93+ engine. load_instruction ( Instruction :: new ( "VERGRTH16" ) )
94+ . and_then ( |ctx| fetch_stack ( ctx, 1 ) )
95+ . and_then ( |ctx| {
96+ let builder = BuilderData :: from ( ctx. engine . cmd . var ( 0 ) . as_cell ( ) ?) ;
97+ let cell_proof_data_length = builder. length_in_bits ( ) ;
98+ //let data = builder.data();
99+ let cell_proof = ctx. engine . finalize_cell ( builder) ?;
100+ let cell_proof_data = cell_proof. data ( ) ;
101+ if cell_proof_data_length % 8 == 0 {
102+
103+ let de_params = Parameters :: read ( & cell_proof_data[ ..] , true ) . unwrap ( ) ;
104+
105+ let pvk = prepare_verifying_key :: < Bls12 > ( & de_params. vk ) ;
106+
107+ //let de_proof = Proof::read(&v[..]).unwrap();
108+
109+ //let result = verify_proof();
110+ let result = true ;
111+ ctx. engine . cc . stack . push ( boolean ! ( result) ) ;
112+ Ok ( ctx)
113+ } else {
114+ err ! ( ExceptionCode :: CellUnderflow )
115+ }
116+ } )
117+ . err ( )
118+ }
119+
83120enum DataForSignature {
84121 Hash ( BuilderData ) ,
85122 Slice ( Vec < u8 > )
0 commit comments