... | ... | @@ -99,49 +99,7 @@ cnt=1,vers[16]~vers[23]的位置用来存进栈顶的值stack_push。 |
|
|
|
|
|
### LookUp约束
|
|
|
|
|
|
这里的四个lookup, 其中3个为类型为LookupEntry::State,其余为 LookupEntry::Arithmetic, 具体可以参考:
|
|
|
|
|
|
#### get_lookups
|
|
|
|
|
|
TODO:使用md的 - ,列出四个Lookup都是啥。然后把这段其他的,包括参考代码,删了。
|
|
|
|
|
|
这里的四个lookup, 类型为LookupEntry::State和LookupEntry::Arithmetic, 具体可以参考Witness Core Row部分的说明。
|
|
|
|
|
|
参考代码如下:
|
|
|
|
|
|
```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 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 push".into(), stack_lookup_2),
|
|
|
("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) |