-
Notifications
You must be signed in to change notification settings - Fork 523
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
Conversation
We introduce a new `RangeConstrained` newtype wrapper for tracking the number of bits to which some type has been constrained.
/// This API only exists to ease with integrating this type into existing circuits, | ||
/// and will likely be removed in future. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
I plan to merge this in sync with zcash/orchard#318 and then open a second PR for my |
@@ -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>> { |
There was a problem hiding this comment.
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>>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like in c4cebc6.
There was a problem hiding this comment.
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).
Part of zcash/orchard#83.