-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new types to validate input assumptions (#43)
* feat: add new types `ProperUint` and `ProperCrtUint` To guard around assumptions about big integer representations * fix: remove unused `FixedAssignedCRTInteger` * feat: use new types for bigint and field chips New types now guard for different assumptions on non-native bigint arithmetic. Distinguish between: - Overflow CRT integers - Proper BigUint with native part derived from limbs - Field elements where inequality < modulus is checked Also add type to help guard for inequality check in ec_add_unequal_strict Rust traits did not play so nicely with references, so I had to switch many functions to move inputs instead of borrow by reference. However to avoid writing `clone` everywhere, we allow conversion `From` reference to the new type via cloning. * feat: use `ProperUint` for `big_less_than` * feat(ecc): add fns for assign private witness points that constrain point to lie on curve * fix: unnecessary lifetimes * chore: remove clones
- Loading branch information
1 parent
01a8ac9
commit 8e9032c
Showing
39 changed files
with
1,958 additions
and
1,645 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
use super::OverflowInteger; | ||
use super::ProperUint; | ||
use halo2_base::{gates::RangeInstructions, utils::ScalarField, AssignedValue, Context}; | ||
|
||
// given OverflowInteger<F>'s `a` and `b` of the same shape, | ||
// returns whether `a < b` | ||
pub fn assign<F: ScalarField>( | ||
range: &impl RangeInstructions<F>, | ||
ctx: &mut Context<F>, | ||
a: &OverflowInteger<F>, | ||
b: &OverflowInteger<F>, | ||
a: impl Into<ProperUint<F>>, | ||
b: impl Into<ProperUint<F>>, | ||
limb_bits: usize, | ||
limb_base: F, | ||
) -> AssignedValue<F> { | ||
// a < b iff a - b has underflow | ||
let (_, underflow) = super::sub::assign::<F>(range, ctx, a, b, limb_bits, limb_base); | ||
let (_, underflow) = super::sub::assign(range, ctx, a, b, limb_bits, limb_base); | ||
underflow | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.