Skip to content

feat: implement provably extract LIMIT/OFFSET circuits (Part2)#300

Open
Insun35 wants to merge 7 commits into
feat/provably-extract-limit-offsetfrom
feat/implement-extraction-circuits
Open

feat: implement provably extract LIMIT/OFFSET circuits (Part2)#300
Insun35 wants to merge 7 commits into
feat/provably-extract-limit-offsetfrom
feat/implement-extraction-circuits

Conversation

@Insun35

@Insun35 Insun35 commented Aug 12, 2024

Copy link
Copy Markdown
Contributor

Address issue #181

Refer to the results extraction circuits spec.

This PR should be merged after #288

@Insun35 Insun35 force-pushed the feat/implement-extraction-circuits branch 2 times, most recently from 438f966 to cb09bb0 Compare August 14, 2024 06:52
@Insun35 Insun35 marked this pull request as ready for review August 14, 2024 06:59
@Insun35 Insun35 force-pushed the feat/implement-extraction-circuits branch 2 times, most recently from 1c424f7 to 04aacfb Compare August 14, 2024 14:12
@Insun35 Insun35 force-pushed the feat/implement-extraction-circuits branch from 04aacfb to 7999666 Compare August 16, 2024 09:46
child_proof2.max_counter_target(),
subtree_proof.max_counter_target(),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we missing the constraints to enforce that offset_range_min and offset_range_max are the same across all the proofs?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also the ones that all index_ids are the same?

b: &mut CBuilder,
subtree_proof: &PublicInputs<Target>,
included_chid_proof: &PublicInputs<Target>,
excluded_child_proof: &PublicInputs<Target>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should correspond to Publicinputs of the results tree construction circuits

subtree_proof.accumulator_target(),
included_chid_proof.accumulator_target(),
]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as full node: equality constrains on index_ids, offset_range_min and offset_range_max seems to be missing

}

/// Subtree proof number = 1, child proof number = 2
pub(crate) const NUM_VERIFIED_PROOFS: usize = 3;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 2, since the excluded_child proof does not refer to a circuit of this set, but instead to the results tree construction set. Might be better to actually implement this trait in the APIs PR

b: &mut CBuilder,
subtree_proof: &PublicInputs<Target>,
included_chid_proof: &PublicInputs<Target>,
sibling_proof: &PublicInputs<Target>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here subtree_proof and sibling_proof should refer to the results tree construction circuits

}

/// Subtree proof number = 1, child proof number = 2
pub(crate) const NUM_VERIFIED_PROOFS: usize = 3;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 1, but as for partial node circuit, might be better to implement this in the APIs PR

);
// assert max_left + 1 == p.min_counter
let left_plus_one = b.add(max_left, one);
b.connect(left_plus_one, subtree_proof.min_counter_target());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be more efficient to do b.connect(max_left, min_minus_one)?

// range specified by the query
// max_left < p.offset_range_max
let is_less = less_than(b, max_left, subtree_proof.offset_range_min_target(), 32);
b.connect(is_less.target, ttrue.target);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_less should be true only if left_child_exists is true, I will also update the specs

// range specified by the query
// min_right > p.offset_range_min
let is_greater = greater_than(b, min_right, subtree_proof.offset_range_max_target(), 32);
b.connect(is_greater.target, ttrue.target);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly as above, is_greater should be true only if right_child_exists is true; will update the specs too

&zero_u256.to_targets(),
&zero_u256.to_targets(),
&zero_u256.to_targets(),
&[one; 2],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these correspond to index_ids? So we might need to add those as witness inputs to the circuit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants