pub struct SubsetSum { /* private fields */ }Expand description
“Subset Sum” is the following “knowledge” problem:
- Given a list of non-negative integers and a target value, do you know a sublist which sums exactly to the target value?
The circuit has the full list and the target value as public inputs, and the selected sublist as a private input. It checks that that the sublist sums to the target value.
Implementations§
Source§impl SubsetSum
impl SubsetSum
Sourcepub fn construct_circuit(builder: &mut CircuitBuilder, len: usize) -> Self
pub fn construct_circuit(builder: &mut CircuitBuilder, len: usize) -> Self
This constructs the circuit in builder and stores some of the wires in
a SubsetSum struct, which is then returned.
The wires are stored so that they can be populated with values later.
Sourcepub fn populate_problem(
&self,
filler: &mut WitnessFiller<'_>,
values: &[u64],
target: u64,
)
pub fn populate_problem( &self, filler: &mut WitnessFiller<'_>, values: &[u64], target: u64, )
This populates the public wires which define the subset sum problem.
valuesis the list of integers availabletargetis the target value that a sublist should sum to
Sourcepub fn populate_solution(
&self,
filler: &mut WitnessFiller<'_>,
selection: &[bool],
)
pub fn populate_solution( &self, filler: &mut WitnessFiller<'_>, selection: &[bool], )
This populates the private wires which select a sublist which is claimed to sum to the target value.
selectionshould have the same length as the original list, and should containtruefor every number that should be included in the sublist
Auto Trait Implementations§
impl Freeze for SubsetSum
impl RefUnwindSafe for SubsetSum
impl Send for SubsetSum
impl Sync for SubsetSum
impl Unpin for SubsetSum
impl UnsafeUnpin for SubsetSum
impl UnwindSafe for SubsetSum
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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>
Converts
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>
Converts
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