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:
parent
2eb1daeb92
commit
0fca00cc93
7 changed files with 319 additions and 159 deletions
|
|
@ -809,7 +809,7 @@ impl Params {
|
|||
}
|
||||
|
||||
pub const fn predicate_size() -> usize {
|
||||
HASH_SIZE + 2
|
||||
8
|
||||
}
|
||||
|
||||
pub const fn operation_type_size() -> usize {
|
||||
|
|
@ -817,11 +817,11 @@ impl Params {
|
|||
}
|
||||
|
||||
pub fn statement_size(&self) -> usize {
|
||||
Self::predicate_size() + STATEMENT_ARG_F_LEN * self.max_statement_args
|
||||
HASH_SIZE + STATEMENT_ARG_F_LEN * self.max_statement_args
|
||||
}
|
||||
|
||||
pub const fn statement_tmpl_size(&self) -> usize {
|
||||
Self::predicate_size() + self.max_statement_args * Self::statement_tmpl_arg_size()
|
||||
HASH_SIZE + self.max_statement_args * Self::statement_tmpl_arg_size()
|
||||
}
|
||||
|
||||
pub fn custom_predicate_size(&self) -> usize {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue