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

Changes from Orchard circuit review #568

Merged
merged 2 commits into from
May 5, 2022
Merged

Changes from Orchard circuit review #568

merged 2 commits into from
May 5, 2022

Conversation

str4d
Copy link
Contributor

@str4d str4d commented May 2, 2022

Part of zcash/orchard#83.

We introduce a new `RangeConstrained` newtype wrapper for tracking the
number of bits to which some type has been constrained.
@str4d str4d added this to the Release 5.0.0 milestone May 2, 2022
Comment on lines +117 to +118
/// This API only exists to ease with integrating this type into existing circuits,
/// and will likely be removed in future.
Copy link
Contributor

Choose a reason for hiding this comment

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

Unsure if it's appropriate here to set #[doc(hidden)] if it's intended to be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My plan is to finish going through the circuit and finding all the ways we want to construct this type, and then see how we can better integrate it into the existing APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to come back to this in a second PR going over the halo2_gadgets circuit impls.

@str4d
Copy link
Contributor Author

str4d commented May 4, 2022

I plan to merge this in sync with zcash/orchard#318 and then open a second PR for my halo2_gadgets review.

@@ -59,6 +78,62 @@ pub trait UtilitiesInstructions<F: FieldExt> {
}
}

/// A type representing a range-constrained field element.
#[derive(Clone, Copy, Debug)]
pub struct RangeConstrained<F: Field, T: FieldValue<F>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be something like

struct RangeConstrained<F: Field, NUM_BITS: usize>(AssignedCell<Bits<NUM_BITS>, F)

Where Bits<NUM_BITS: usize>: Into<Assigned<F>>.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Something like in c4cebc6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would not work for the way the MessagePiece::from_subpieces API works, as we can't yet have an iterator that is generic over a type parameter. And we can't do type-system concatenation until Rust implements const generics expressions, so we'd instead need to use something like generic_array. It might work if we also rework the Sinsemilla APIs, but that will have to wait until after halo2_gadgets 0.1.0 (so won't ever be used by the Orchard circuit).

@str4d str4d merged commit b2e2b9b into main May 5, 2022
@str4d str4d deleted the circuit-review branch May 5, 2022 15:03
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.

3 participants