pub struct Values<'a, F> { /* private fields */ }Expand description
A view of the values assigned so far during prover-mode construction.
A view is passed to witness init closures, which read the values of
earlier vars with Var::value. This is how a prover supplies values
that are cheaper to verify than to compute with circuit operations, such
as inverses: compute the value natively, then constrain it with
assertions.
Closures receiving a view must not call back into the Context, for
example by creating new vars: doing so deadlocks.
§Example
use commonware_cryptography::zk::circuit::{build_with_values, Var};
use commonware_math::{
algebra::{Field, Ring},
test::F,
};
let (valued, _) = build_with_values(|ctx| {
let x = Var::witness(ctx, |_| F::from(3u64));
// The prover computes the inverse natively...
let inv = Var::witness(ctx, {
let x = x.clone();
move |v| x.value(v).inv()
});
// ...and the circuit checks it with a single multiplication.
(x * &inv).assert_eq(&Var::one());
Vec::new()
});
assert!(valued.is_satisfied());Trait Implementations§
Auto Trait Implementations§
impl<'a, F> Freeze for Values<'a, F>
impl<'a, F> RefUnwindSafe for Values<'a, F>where
&'a [F]: RefUnwindSafe,
impl<'a, F> Send for Values<'a, F>
impl<'a, F> Sync for Values<'a, F>
impl<'a, F> Unpin for Values<'a, F>
impl<'a, F> UnsafeUnpin for Values<'a, F>where
&'a [F]: UnsafeUnpin,
impl<'a, F> UnwindSafe for Values<'a, F>where
&'a [F]: UnwindSafe,
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
Mutably borrows from an owned value. Read more