Use predicate hash in statements instead of the literal predicate

Resolve #448 

Previously a predicate was 6 elements.  Now it grows to 8 elements; and the hash is 4 elements.

Some parts of the circuit require only require equality checks with the predicate: that works with the predicate hash.  Other parts require inspecting or working with particular elements in the predicate, those need the preimage of the predicate hash.
Both `StatementTarget` and `StatementTmplTarget` have been updated to include the predicate hash and optionally the predicate.  When the predicate is included, constraints are automatically generated for `pred_hash = hash(pred)`.  We only include the predicate when needed.
This commit is contained in:
Eduard S. 2026-01-19 11:02:11 +01:00 committed by GitHub
parent 2eb1daeb92
commit 0fca00cc93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 319 additions and 159 deletions

View file

@ -169,6 +169,12 @@ pub struct Hash(
pub [F; HASH_SIZE],
);
impl From<Hash> for HashOut {
fn from(hash: Hash) -> HashOut {
HashOut { elements: hash.0 }
}
}
impl ToHex for Hash {
fn encode_hex<T: std::iter::FromIterator<char>>(&self) -> T {
self.0