Basic 'use' syntax for importing custom predicates (#286)
* Basic 'use' syntax for importing custom predicates * Add extra test for unknown batches * Fix unused import * Enforce that imports must match number of predicates in a batch
This commit is contained in:
parent
f7bb6af219
commit
21ab3c2d0d
6 changed files with 499 additions and 136 deletions
|
|
@ -28,9 +28,10 @@
|
|||
use std::{
|
||||
cmp::{Ord, Ordering},
|
||||
fmt,
|
||||
fmt::Write,
|
||||
};
|
||||
|
||||
use hex::{FromHex, FromHexError};
|
||||
use hex::{FromHex, FromHexError, ToHex};
|
||||
use plonky2::{
|
||||
field::types::{Field, PrimeField64},
|
||||
hash::poseidon::PoseidonHash,
|
||||
|
|
@ -143,6 +144,32 @@ pub struct Hash(
|
|||
pub [F; HASH_SIZE],
|
||||
);
|
||||
|
||||
impl ToHex for Hash {
|
||||
fn encode_hex<T: std::iter::FromIterator<char>>(&self) -> T {
|
||||
self.0
|
||||
.iter()
|
||||
.rev()
|
||||
.fold(String::with_capacity(64), |mut s, limb| {
|
||||
write!(s, "{:016x}", limb.0).unwrap();
|
||||
s
|
||||
})
|
||||
.chars()
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn encode_hex_upper<T: std::iter::FromIterator<char>>(&self) -> T {
|
||||
self.0
|
||||
.iter()
|
||||
.rev()
|
||||
.fold(String::with_capacity(64), |mut s, limb| {
|
||||
write!(s, "{:016X}", limb.0).unwrap();
|
||||
s
|
||||
})
|
||||
.chars()
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hash_value(input: &RawValue) -> Hash {
|
||||
hash_fields(&input.0)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue