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

Add Fixed-Size Unsigned Integer Interface to ECLAIR #141

Closed
4 tasks
bhgomes opened this issue Jun 28, 2022 · 0 comments · Fixed by #146
Closed
4 tasks

Add Fixed-Size Unsigned Integer Interface to ECLAIR #141

bhgomes opened this issue Jun 28, 2022 · 0 comments · Fixed by #146
Assignees
Labels
A-openzl Area: Development Related to OpenZL and ECLAIR C-tracking-issue Category: A tracking issue for a set of related issues P-high Priority: High
Milestone

Comments

@bhgomes
Copy link
Contributor

bhgomes commented Jun 28, 2022

For a given number of bits (less than 1/2 the proof-system field size), we should have an interface for operations that need to have bounds checking enabled. Build a new type that's something like the following:

/// 128-Bit Unsigned Integer
pub struct U128<T>(T);

impl<T> U128<T> {
    /// Builds a new [`U128`] over `value`, asserting that it does not exceed 128 bits.
    #[inline]
    pub fn new<COM>(value: T, compiler: &mut COM) -> Self 
    where
        COM: AssertWithinRange<T, 128>,
    {
        compiler.assert_within_range(value);
        Self(value)
    }
}

where the following trait implementations have a range check included for each operation:

  • Add<Self, COM>
  • AddAssign<COM>
  • Sub<Self, COM>
  • SubAssign<COM>

We can leave the multiplicative operations for the future (not needed for the next version of protocol). Once this interface is built out, we can expand to all integral types less than 128.

@bhgomes bhgomes added this to the v0.6.1 milestone Jun 28, 2022
@bhgomes bhgomes modified the milestones: v0.6.1, v0.6.0 Jun 28, 2022
@BoyuanFeng BoyuanFeng modified the milestones: v0.6.0, v0.5.3 Jun 30, 2022
@bhgomes bhgomes added C-tracking-issue Category: A tracking issue for a set of related issues A-openzl Area: Development Related to OpenZL and ECLAIR P-high Priority: High labels Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-openzl Area: Development Related to OpenZL and ECLAIR C-tracking-issue Category: A tracking issue for a set of related issues P-high Priority: High
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants