pub struct ModDivideHint;Expand description
ModDivide hint implementation.
Computes the modular quotient slope = dividend * divisor^{-1} (mod modulus) together with
the integer quotient witnessing the reduction slope * divisor = dividend + quotient * modulus. Both outputs are set to zero when divisor is not invertible modulo modulus
(e.g. divisor == 0 or gcd(divisor, modulus) > 1).
Implementations§
Source§impl ModDivideHint
impl ModDivideHint
pub const fn new() -> Self
Sourcepub fn call(
builder: &CircuitBuilder,
dividend: &[Wire],
divisor: &[Wire],
modulus: &[Wire],
) -> (Vec<Wire>, Vec<Wire>)
pub fn call( builder: &CircuitBuilder, dividend: &[Wire], divisor: &[Wire], modulus: &[Wire], ) -> (Vec<Wire>, Vec<Wire>)
Modular division.
Computes dividend / divisor (mod modulus) = dividend * divisor^{-1} (mod modulus).
Returns a pair (quotient, slope) where slope is the modular quotient and quotient
is the non-negative integer satisfying slope * divisor = dividend + quotient * modulus.
Both are set to zero when divisor is not invertible modulo modulus (e.g. divisor == 0).
This is a hint - a deterministic computation that happens only on the prover side.
The result should be additionally constrained by using bignum circuits to check that
slope * divisor = dividend + quotient * modulus.
Trait Implementations§
Source§impl Default for ModDivideHint
impl Default for ModDivideHint
Source§impl Hint for ModDivideHint
impl Hint for ModDivideHint
Auto Trait Implementations§
impl Freeze for ModDivideHint
impl RefUnwindSafe for ModDivideHint
impl Send for ModDivideHint
impl Sync for ModDivideHint
impl Unpin for ModDivideHint
impl UnsafeUnpin for ModDivideHint
impl UnwindSafe for ModDivideHint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more