Skip to content

Commit 6f3acd7

Browse files
Ilias Khairullinilyar
authored andcommitted
Groth16 encrypted input mode introduced
1 parent d11488e commit 6f3acd7

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
@@ -35,9 +35,9 @@ use ed25519::signature::{Signature, Verifier};
3535
use std::sync::Arc;
3636
use ton_types::{BuilderData, Cell, error, GasConsumer, ExceptionCode, UInt256};
3737

38-
use crusty3_zk::{groth16::{verify_proof, prepare_verifying_key, Parameters, verify_groth16_proof_from_byteblob},
39-
bls::{Bls12, Fr}
40-
};
38+
use crusty3_zk::{groth16::{verify_proof, prepare_verifying_key, Parameters, verify_groth16_proof_from_byteblob, verify_encrypted_input_groth16_proof_from_byteblob},
39+
bls::{Bls12, Fr},
40+
};
4141

4242
const PUBLIC_KEY_BITS: usize = PUBLIC_KEY_BYTES * 8;
4343
const SIGNATURE_BITS: usize = SIGNATURE_BYTES * 8;
@@ -115,11 +115,16 @@ pub(super) fn execute_vergrth16(engine: &mut Engine) -> Failure {
115115

116116
let cell_proof = ctx.engine.finalize_cell(builder)?;
117117

118-
let mut cell_proof_data = obtain_cells_data(cell_proof).unwrap();
119-
120-
if cell_proof_data_length % 8 == 0 {
121-
122-
let result = verify_groth16_proof_from_byteblob::<Bls12>(&cell_proof_data[..]).unwrap();
118+
let mut cell_proof_data = obtain_cells_data(cell_proof).unwrap();if cell_proof_data_length % 8 == 0 {
119+
let mut result = false;
120+
if cell_proof_data[0] == 0 {
121+
result = verify_groth16_proof_from_byteblob::<Bls12>(&cell_proof_data[1..]).unwrap();
122+
} else if cell_proof_data[0] == 1 {
123+
result = verify_encrypted_input_groth16_proof_from_byteblob::<Bls12>(&cell_proof_data[1..]).unwrap();
124+
}
125+
else {
126+
return err!(ExceptionCode::InvalidOpcode);
127+
}
123128

124129
ctx.engine.cc.stack.push(boolean!(result));
125130
Ok(ctx)

0 commit comments

Comments
 (0)