Skip to content

Commit 448184a

Browse files
Ilias Khairullinilyar
authored andcommitted
Groth16 encrypted input mode introduced
1 parent 1e5e63f commit 448184a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/executor/crypto.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ use ed25519::signature::{Signature, Verifier};
3333
use std::sync::Arc;
3434
use ton_types::{BuilderData, Cell, error, GasConsumer, ExceptionCode, UInt256};
3535

36-
use crusty3_zk::{groth16::{verify_proof, prepare_verifying_key, Parameters, verify_groth16_proof_from_byteblob},
37-
bls::{Bls12, Fr}
38-
};
36+
use crusty3_zk::{groth16::{verify_proof, prepare_verifying_key, Parameters, verify_groth16_proof_from_byteblob, verify_encrypted_input_groth16_proof_from_byteblob},
37+
bls::{Bls12, Fr},
38+
};
3939

4040
const PUBLIC_KEY_BITS: usize = PUBLIC_KEY_BYTES * 8;
4141
const SIGNATURE_BITS: usize = SIGNATURE_BYTES * 8;
@@ -109,11 +109,16 @@ pub(super) fn execute_vergrth16(engine: &mut Engine) -> Failure {
109109

110110
let cell_proof = ctx.engine.finalize_cell(builder)?;
111111

112-
let mut cell_proof_data = obtain_cells_data(cell_proof).unwrap();
113-
114-
if cell_proof_data_length % 8 == 0 {
115-
116-
let result = verify_groth16_proof_from_byteblob::<Bls12>(&cell_proof_data[..]).unwrap();
112+
let mut cell_proof_data = obtain_cells_data(cell_proof).unwrap();if cell_proof_data_length % 8 == 0 {
113+
let mut result = false;
114+
if cell_proof_data[0] == 0 {
115+
result = verify_groth16_proof_from_byteblob::<Bls12>(&cell_proof_data[1..]).unwrap();
116+
} else if cell_proof_data[0] == 1 {
117+
result = verify_encrypted_input_groth16_proof_from_byteblob::<Bls12>(&cell_proof_data[1..]).unwrap();
118+
}
119+
else {
120+
return err!(ExceptionCode::InvalidOpcode);
121+
}
117122

118123
ctx.engine.cc.stack.push(boolean!(result));
119124
Ok(ctx)

0 commit comments

Comments
 (0)