From 1d54c3e703157e6c39d5cd4fef1b52b4b52e8911 Mon Sep 17 00:00:00 2001 From: Filip Krawczyk Date: Fri, 29 Dec 2023 13:12:44 +0100 Subject: [PATCH] Implement hash_blake_or_poseidon --- src/vector_commitment/vector_commitment.cairo | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/vector_commitment/vector_commitment.cairo b/src/vector_commitment/vector_commitment.cairo index 08b0a3b31..774dcd75c 100644 --- a/src/vector_commitment/vector_commitment.cairo +++ b/src/vector_commitment/vector_commitment.cairo @@ -3,6 +3,17 @@ use cairo_verifier::common::{ array_append::ArrayAppendTrait, blake2s::blake2s, }; +use poseidon::hades_permutation; + + +fn hash_blake_or_poseidon(x: felt252, y: felt252, is_verifier_friendly: bool) -> felt252 { + if is_verifier_friendly { + let (hash, _, _) = hades_permutation(x, y, 2); + hash + } else { + truncated_blake2s(x, y) + } +} fn truncated_blake2s(x: felt252, y: felt252) -> felt252 { let mut data = ArrayTrait::::new();