Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions pallets/vector/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,17 @@ impl Verifier {
output_hash: H256,
proof: Vec<u8>,
) -> Result<bool, VerificationError> {
// remove first 3 bits from input_hash and output_hash
let bits_mask = 0b00011111;
let mut input_swap = input_hash.to_fixed_bytes();
let input_hash_byte_swap = input_hash[0] & bits_mask;
input_swap[0] = input_hash_byte_swap;

let mut output_swap = output_hash.to_fixed_bytes();
let output_hash_byte_swap = output_hash[0] & bits_mask;
output_swap[0] = output_hash_byte_swap;
let input_bytes = input_hash.to_fixed_bytes();
let output_bytes = output_hash.to_fixed_bytes();

let decoded: (Vec<String>, Vec<Vec<String>>, Vec<String>) = decode_proof(proof)?;

let circom_proof = CircomProof::new(decoded.0, decoded.1, decoded.2);
let proof = circom_proof.proof()?;

let mut input = vec!["0".to_string(); 2];
input[0] = U256::from_big_endian(output_swap.as_slice()).to_string();
input[1] = U256::from_big_endian(input_swap.as_slice()).to_string();
input[0] = U256::from_big_endian(output_bytes.as_slice()).to_string();
input[1] = U256::from_big_endian(input_bytes.as_slice()).to_string();

let public_signals = PublicSignals::from(input);

Expand Down Expand Up @@ -501,7 +494,7 @@ mod tests {
],
[
"2320747355788118605608963241136772405889379999161258135797985959373766905799",
"7118041328407665643077665093375077236507031390654037220453830314560753892708"
"7118041338407665643077665093375077236507031390654037220453830314560753892708"
],
[
"1",
Expand Down