Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check bug #40

Merged
merged 8 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions src/chips/merkle_sum_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,13 @@ impl<const MST_WIDTH: usize, const N_ASSETS: usize> MerkleSumTreeChip<MST_WIDTH,
lt_config,
};

meta.create_gate(
"verifies that `check` from current config equal to is_lt from LtChip",
|meta| {
let q_enable = meta.query_selector(lt_selector);
meta.create_gate("is_lt is 1", |meta| {
let q_enable = meta.query_selector(lt_selector);

let check = meta.query_advice(advice[2], Rotation::cur());

vec![q_enable * (config.lt_config.is_lt(meta, None) - check)]
},
);
vec![
q_enable * (config.lt_config.is_lt(meta, None) - Expression::Constant(Fp::from(1))),
]
});

config
}
Expand Down Expand Up @@ -433,17 +430,8 @@ impl<const MST_WIDTH: usize, const N_ASSETS: usize> MerkleSumTreeChip<MST_WIDTH,
i,
)?;

// set check to be equal to 1
region.assign_advice(
|| "check",
//"Column c" from the spec
self.config.advice[2],
i,
|| Value::known(Fp::from(1)),
)?;

// enable lt seletor
self.config.lt_selector.enable(&mut region, 0)?;
// enable lt seletor
self.config.lt_selector.enable(&mut region, 0)?;

total_assets_cell
.value()
Expand Down
12 changes: 1 addition & 11 deletions src/circuits/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,22 +446,12 @@ mod test {
assert_eq!(
invalid_prover.verify(),
Err(vec![VerifyFailure::ConstraintNotSatisfied {
constraint: (
(
8,
"verifies that `check` from current config equal to is_lt from LtChip"
)
.into(),
0,
""
)
.into(),
constraint: ((8, "is_lt is 1").into(), 0, "").into(),
location: FailureLocation::InRegion {
region: (30, "enforce sum to be less than total assets").into(),
offset: 0
},
cell_values: vec![
(((Any::advice(), 2).into(), 0).into(), "1".to_string()),
// The zero means that is not less than
(((Any::advice(), 44).into(), 0).into(), "0".to_string())
]
Expand Down