Skip to content

Commit 6a6ee75

Browse files
committed
input validation circuit linked to ckt G1Projective::deserialize_checked only
1 parent 3ee485f commit 6a6ee75

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

g16ckt/src/gadgets/groth16.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,14 +547,18 @@ pub fn simple_circuit_substitute_for_groth16_verify_compressed_raw<
547547
let out_hash = blake3_hash(circuit, input.public);
548548
let hash_fr = convert_hash_to_bigint_wires(out_hash);
549549

550-
let proof = input.proof.deserialize_checked(circuit, input.proof_type);
550+
let compressed_a: [WireId; 32 * 8] = input.proof.0[0..32 * 8].try_into().unwrap();
551+
let compressed_b: [WireId; 64 * 8] = input.proof.0[32 * 8..96 * 8].try_into().unwrap();
552+
let compressed_c: [WireId; 32 * 8] = input.proof.0[96 * 8..].try_into().unwrap();
553+
554+
let a_decomp = G1Projective::deserialize_checked(circuit, compressed_a, input.proof_type);
551555

552556
// hash_fr and proof can not be zero
553557
// proof.valid should be true
554558
let mut wire_bits = vec![];
555-
let mut proof_a = proof.a.to_wires_vec();
556-
let mut proof_b = proof.b.to_wires_vec();
557-
let mut proof_c = proof.c.to_wires_vec();
559+
let mut proof_a = a_decomp.to_wires_vec();
560+
let mut proof_b = compressed_b.to_vec();
561+
let mut proof_c = compressed_c.to_vec();
558562
wire_bits.append(&mut proof_a);
559563
wire_bits.append(&mut proof_b);
560564
wire_bits.append(&mut proof_c);
@@ -578,7 +582,7 @@ pub fn simple_circuit_substitute_for_groth16_verify_compressed_raw<
578582
let res = circuit.issue_wire();
579583
circuit.add_gate(crate::Gate {
580584
wire_a: acc,
581-
wire_b: proof.valid,
585+
wire_b: a_decomp.is_valid,
582586
wire_c: res,
583587
gate_type: crate::GateType::And,
584588
});

0 commit comments

Comments
 (0)