MultiSet

Struct MultiSet 

Source
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

Source

pub fn new() -> MultiSet

Creates an empty vector with a multiset wrapper around it

Source

pub fn from_slice(bytes: &[u8]) -> Result<MultiSet, Error>

Generate a MultiSet struct from a slice of bytes.

Source

pub fn to_var_bytes(&self) -> Vec<u8>

Given a MultiSet, return it in it’s bytes representation element by element.

Source

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

Source

pub fn push(&mut self, value: BlsScalar)

Pushes chosen value onto the end of the Multiset

Source

pub fn last(&self) -> Option<&BlsScalar>

Fetches last element in MultiSet. Returns None if there are no elements in the MultiSet.

Source

pub fn len(&self) -> usize

Returns the cardinality of the multiset

Source

pub fn is_empty(&self) -> bool

Returns whether or not the multiset is empty.

Source

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.

Source

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}

Source

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.

Source

pub fn contains(&self, entry: &BlsScalar) -> bool

Checks if an element is in the MultiSet

Source

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.

Source

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.

Source

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)

Source

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§

Source§

impl Add for MultiSet

Source§

type Output = MultiSet

The resulting type after applying the + operator.
Source§

fn add(self, other: MultiSet) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for MultiSet

Source§

fn clone(&self) -> MultiSet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MultiSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MultiSet

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<&[Scalar]> for MultiSet

Source§

fn from(slice: &[BlsScalar]) -> MultiSet

Converts to this type from the input type.
Source§

impl Mul for MultiSet

Source§

type Output = MultiSet

The resulting type after applying the * operator.
Source§

fn mul(self, other: MultiSet) -> Self::Output

Performs the * operation. Read more
Source§

impl PartialEq for MultiSet

Source§

fn eq(&self, other: &MultiSet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for MultiSet

Source§

impl StructuralPartialEq for MultiSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.