... | ... | @@ -176,45 +176,7 @@ fn get_constraints( |
|
|
#### get_lookups
|
|
|
|
|
|
|
|
|
这里的四个lookup, 类型为LookupEntry::State和LookupEntry::Arithmetic, 具体可以参考Witness Core Row部分的说明。
|
|
|
这里的5个lookup, 类型为LookupEntry::State和LookupEntry::Arithmetic, 具体可以参考:
|
|
|
|
|
|
参考代码如下:
|
|
|
|
|
|
```rust
|
|
|
fn get_lookups(
|
|
|
&self,
|
|
|
config: &ExecutionConfig<F, NUM_STATE_HI_COL, NUM_STATE_LO_COL>,
|
|
|
meta: &mut ConstraintSystem<F>,
|
|
|
) -> Vec<(String, LookupEntry<F>)> {
|
|
|
let stack_lookup_0 = query_expression(meta, |meta| config.get_state_lookup(meta, 0));
|
|
|
let stack_lookup_1 = query_expression(meta, |meta| config.get_state_lookup(meta, 1));
|
|
|
let stack_lookup_2 = query_expression(meta, |meta| config.get_state_lookup(meta, 2));
|
|
|
let stack_lookup_3 = query_expression(meta, |meta| config.get_state_lookup(meta, 3));
|
|
|
let arithmetic = query_expression(meta, |meta| config.get_arithmetic_lookup(meta));
|
|
|
vec![
|
|
|
("stack pop a".into(), stack_lookup_0),
|
|
|
("stack pop b".into(), stack_lookup_1),
|
|
|
("stack pop n".into(), stack_lookup_2),
|
|
|
("stack push".into(), stack_lookup_3),
|
|
|
("arithmetic lookup".into(), arithmetic),
|
|
|
]
|
|
|
}
|
|
|
|
|
|
pub(crate) fn get_arithmetic_lookup(&self, meta: &mut VirtualCells<F>) -> LookupEntry<F> {
|
|
|
let (hi_0, lo_0, hi_1, lo_1, hi_2, lo_2, hi_3, lo_3, tag) = (
|
|
|
meta.query_advice(self.vers[0], Rotation(-2)),
|
|
|
meta.query_advice(self.vers[1], Rotation(-2)),
|
|
|
meta.query_advice(self.vers[2], Rotation(-2)),
|
|
|
meta.query_advice(self.vers[3], Rotation(-2)),
|
|
|
meta.query_advice(self.vers[4], Rotation(-2)),
|
|
|
meta.query_advice(self.vers[5], Rotation(-2)),
|
|
|
meta.query_advice(self.vers[6], Rotation(-2)),
|
|
|
meta.query_advice(self.vers[7], Rotation(-2)),
|
|
|
meta.query_advice(self.vers[8], Rotation(-2)),
|
|
|
);
|
|
|
LookupEntry::Arithmetic {
|
|
|
tag,
|
|
|
values: [hi_0, lo_0, hi_1, lo_1, hi_2, lo_2, hi_3, lo_3],
|
|
|
}
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |
|
|
- [5-state.markdown](../5-state.markdown)
|
|
|
- [8-arithmetic.markdown](../8-arithmetic.markdown) |