Implement HashOf statement and op (#217)

This commit is contained in:
Ahmad Afuni 2025-05-06 19:14:53 +10:00 committed by GitHub
parent 53ade6ea26
commit 8cc090c5e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 139 additions and 6 deletions

View file

@ -58,7 +58,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use super::serialization::*;
use crate::middleware::{Params, ToFields};
use crate::middleware::{Params, ToFields, Value};
/// F is the native field we use everywhere. Currently it's Goldilocks from plonky2
pub type F = GoldilocksField;
@ -164,6 +164,10 @@ pub fn hash_fields(input: &[F]) -> Hash {
Hash(PoseidonHash::hash_no_pad(input).elements)
}
pub fn hash_values(input: &[Value]) -> Hash {
hash_fields(&input.iter().flat_map(|v| v.raw().0).collect::<Vec<_>>())
}
impl From<RawValue> for Hash {
fn from(v: RawValue) -> Self {
Hash(v.0)