Implement HashOf statement and op (#217)
This commit is contained in:
parent
53ade6ea26
commit
8cc090c5e0
6 changed files with 139 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue