pub struct MultiSet(pub Vec<BlsScalar>);Expand description
MultiSet is struct containing vectors of scalars, which individually represents either a wire value or an index of a Plonkup table
Tuple Fields§
§0: Vec<BlsScalar>Implementations§
Source§impl MultiSet
impl MultiSet
Sourcepub fn from_slice(bytes: &[u8]) -> Result<MultiSet, Error>
pub fn from_slice(bytes: &[u8]) -> Result<MultiSet, Error>
Generate a MultiSet struct from a slice of bytes.
Sourcepub fn to_var_bytes(&self) -> Vec<u8> ⓘ
pub fn to_var_bytes(&self) -> Vec<u8> ⓘ
Given a MultiSet, return it in it’s bytes representation
element by element.
Sourcepub fn pad(&mut self, n: u32)
pub fn pad(&mut self, n: u32)
Extends the length of the multiset to n elements The n will be the size of the arithmetic circuit. This will extend the vectors to the size
Sourcepub fn last(&self) -> Option<&BlsScalar>
pub fn last(&self) -> Option<&BlsScalar>
Fetches last element in MultiSet. Returns None if there are no elements in the MultiSet.
Sourcepub fn position(&self, element: &BlsScalar) -> Option<usize>
pub fn position(&self, element: &BlsScalar) -> Option<usize>
Returns the position of the element in the Multiset. Returns None if the element is not found.
Sourcepub fn sorted_concat(&self, f: &MultiSet) -> Result<MultiSet, Error>
pub fn sorted_concat(&self, f: &MultiSet) -> Result<MultiSet, Error>
Concatenates and sorts two Multisets together. From the Plonkup paper, if we have t: {1,2,4,3} and f: {2,3,4,1}. We first check if all elements of f exist in t Then we combine the multisets together and sort their elements together. The final MultiSet will look as follows, s: {1,1,2,2,3,3,4,4}
Sourcepub fn contains_all(&self, other: &MultiSet) -> bool
pub fn contains_all(&self, other: &MultiSet) -> bool
Checks whether one mutltiset is a subset of another. This function will be used to check if the all elements in set f, from the paper, are contained inside t.
Sourcepub fn halve(&self) -> (MultiSet, MultiSet)
pub fn halve(&self) -> (MultiSet, MultiSet)
Splits a multiset into halves as specified by the paper The last element of the first half should be the same as the first element of the second half. Since a multiset can never have an even cardinality, we always split it in the way described above.
Sourcepub fn halve_alternating(&self) -> (MultiSet, MultiSet)
pub fn halve_alternating(&self) -> (MultiSet, MultiSet)
Splits a multiset into alternating halves of the same length as specified in the Plonkup paper. A multiset must have even cardinality to be split in this manner.
Sourcepub fn compress_three_arity(
multisets: [&MultiSet; 3],
alpha: BlsScalar,
) -> MultiSet
pub fn compress_three_arity( multisets: [&MultiSet; 3], alpha: BlsScalar, ) -> MultiSet
Turn three multisets into a single multiset using a random challenge, Alpha. Alpha is dervived by hashing the transcript. The function iterates over the given sets and mutiplies by alpha: a + (b * alpha) + (c * alpha^2)
Sourcepub fn compress_four_arity(
multisets: [&MultiSet; 4],
alpha: BlsScalar,
) -> MultiSet
pub fn compress_four_arity( multisets: [&MultiSet; 4], alpha: BlsScalar, ) -> MultiSet
Turn four multisets into a single multiset using a random challenge, Alpha. Alpha is dervived by hashing the transcript. The function iterates over the given sets and mutiplies by alpha: a + (b * alpha) + (c * alpha^2) + (d * alpha^3)
Trait Implementations§
impl Eq for MultiSet
impl StructuralPartialEq for MultiSet
Auto Trait Implementations§
impl Freeze for MultiSet
impl RefUnwindSafe for MultiSet
impl Send for MultiSet
impl Sync for MultiSet
impl Unpin for MultiSet
impl UnwindSafe for MultiSet
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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