Split Params into base and developer-defined (#458)
I thought it would be nice to have a Predicate for the typed value so that the developer can work with predicates as values comfortably. Then I noticed that hashing a predicate required `Params` which would have been annoying for converting a `TypedValue::Predicate` to `RawValue` and this led to a small refactor over how `Params` work. We already had some fields in the `Params` struct that determine compatibility between encoded data. They can be seen as determining a kind of ABI compatibility. In general it's better if those parameters don't change so that different circuit configurations can still verify proofs from each other. So I decided to force those parameters to be constant in the code base and not allow the user of our library to change them. Many field element serialization/deserialization functions in our code depended on those parameters, and since now they are constant many functions get rid of the `Params` argument, which simplifies the code. This includes the serialization of a `Predicate` which was required to calculate its hash.
This commit is contained in:
parent
498e946612
commit
a7a30176a7
20 changed files with 376 additions and 468 deletions
|
|
@ -326,10 +326,10 @@ impl<'a> Lowerer<'a> {
|
|||
batches: Option<&PredicateBatches>,
|
||||
) -> Result<MWStatementTmpl, LoweringError> {
|
||||
// Enforce argument count limit for request statements
|
||||
if stmt.args.len() > self.params.max_statement_args {
|
||||
if stmt.args.len() > Params::max_statement_args() {
|
||||
return Err(LoweringError::TooManyStatementArgs {
|
||||
count: stmt.args.len(),
|
||||
max: self.params.max_statement_args,
|
||||
max: Params::max_statement_args(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -446,6 +446,7 @@ impl<'a> Lowerer<'a> {
|
|||
let result = frontend_ast_split::split_predicate_if_needed(pred, self.params)?;
|
||||
split_results.push(result);
|
||||
}
|
||||
|
||||
Ok(split_results)
|
||||
}
|
||||
}
|
||||
|
|
@ -676,7 +677,8 @@ mod tests {
|
|||
"#;
|
||||
|
||||
let params = Params::default();
|
||||
parse_validate_and_lower(input, ¶ms).unwrap();
|
||||
let result = parse_validate_and_lower(input, ¶ms);
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue