Struct vsss_rs::Gf256

source ·
#[repr(transparent)]
pub struct Gf256(pub u8);
Expand description

Represents the finite field GF(2^8) with 256 elements.

Tuple Fields§

§0: u8

Implementations§

source§

impl Gf256

source

pub fn pow(&self, exp: u8) -> Self

Raise the element to the power of exp.

source

pub fn split_array<B: AsRef<[u8]>>( threshold: usize, limit: usize, secret: B, rng: impl RngCore + CryptoRng ) -> VsssResult<Vec<Vec<u8>>>

Split a byte array into shares.

source

pub fn split_array_with_participant_generator<P: ParticipantNumberGenerator<Self>, B: AsRef<[u8]>>( threshold: usize, limit: usize, secret: B, rng: impl RngCore + CryptoRng, participant_generator: P ) -> VsssResult<Vec<Vec<u8>>>

Split a byte array into shares using the participant number generator.

source

pub fn combine_array<B: AsRef<[Vec<u8>]>>(shares: B) -> VsssResult<Vec<u8>>

Combine shares into a byte array.

Trait Implementations§

source§

impl Add<&Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Gf256) -> Gf256

Performs the + operation. Read more
source§

impl Add<&Gf256> for Gf256

§

type Output = Gf256

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Gf256) -> Gf256

Performs the + operation. Read more
source§

impl Add<Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the + operator.
source§

fn add(self, rhs: Gf256) -> Gf256

Performs the + operation. Read more
source§

impl Add for Gf256

§

type Output = Gf256

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
source§

impl AddAssign<&Gf256> for Gf256

source§

fn add_assign(&mut self, rhs: &Gf256)

Performs the += operation. Read more
source§

impl AddAssign for Gf256

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl Binary for Gf256

source§

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

Formats the value using the given formatter.
source§

impl BitAnd<&Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &Gf256) -> Gf256

Performs the & operation. Read more
source§

impl BitAnd<&Gf256> for Gf256

§

type Output = Gf256

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &Gf256) -> Gf256

Performs the & operation. Read more
source§

impl BitAnd<Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Gf256) -> Gf256

Performs the & operation. Read more
source§

impl BitAnd for Gf256

§

type Output = Gf256

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self

Performs the & operation. Read more
source§

impl BitAndAssign<&Gf256> for Gf256

source§

fn bitand_assign(&mut self, rhs: &Gf256)

Performs the &= operation. Read more
source§

impl BitAndAssign for Gf256

source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
source§

impl BitOr<&Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: &Gf256) -> Gf256

Performs the | operation. Read more
source§

impl BitOr<&Gf256> for Gf256

§

type Output = Gf256

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: &Gf256) -> Gf256

Performs the | operation. Read more
source§

impl BitOr<Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Gf256) -> Gf256

Performs the | operation. Read more
source§

impl BitOr for Gf256

§

type Output = Gf256

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
source§

impl BitOrAssign<&Gf256> for Gf256

source§

fn bitor_assign(&mut self, rhs: &Gf256)

Performs the |= operation. Read more
source§

impl BitOrAssign for Gf256

source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
source§

impl BitXor<&Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: &Gf256) -> Gf256

Performs the ^ operation. Read more
source§

impl BitXor<&Gf256> for Gf256

§

type Output = Gf256

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: &Gf256) -> Gf256

Performs the ^ operation. Read more
source§

impl BitXor<Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Gf256) -> Gf256

Performs the ^ operation. Read more
source§

impl BitXor for Gf256

§

type Output = Gf256

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Self) -> Self

Performs the ^ operation. Read more
source§

impl BitXorAssign<&Gf256> for Gf256

source§

fn bitxor_assign(&mut self, rhs: &Gf256)

Performs the ^= operation. Read more
source§

impl BitXorAssign for Gf256

source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
source§

impl Clone for Gf256

source§

fn clone(&self) -> Gf256

Returns a copy 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 ConditionallySelectable for Gf256

source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
source§

impl ConstantTimeEq for Gf256

source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
source§

impl Debug for Gf256

source§

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

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

impl Default for Gf256

source§

fn default() -> Gf256

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

impl Display for Gf256

source§

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

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

impl Div<&Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the / operator.
source§

fn div(self, rhs: &Gf256) -> Gf256

Performs the / operation. Read more
source§

impl Div<&Gf256> for Gf256

§

type Output = Gf256

The resulting type after applying the / operator.
source§

fn div(self, rhs: &Gf256) -> Gf256

Performs the / operation. Read more
source§

impl Div<Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the / operator.
source§

fn div(self, rhs: Gf256) -> Gf256

Performs the / operation. Read more
source§

impl Div for Gf256

§

type Output = Gf256

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
source§

impl DivAssign<&Gf256> for Gf256

source§

fn div_assign(&mut self, rhs: &Gf256)

Performs the /= operation. Read more
source§

impl DivAssign for Gf256

source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
source§

impl Field for Gf256

source§

const ZERO: Self = _

The zero element of the field, the additive identity.
source§

const ONE: Self = _

The one element of the field, the multiplicative identity.
source§

fn random(rng: impl RngCore) -> Self

Returns an element chosen uniformly at random using a user-provided RNG.
source§

fn square(&self) -> Self

Squares this element.
source§

fn double(&self) -> Self

Doubles this element.
source§

fn invert(&self) -> CtOption<Self>

Computes the multiplicative inverse of this element, failing if the element is zero.
source§

fn sqrt_ratio(num: &Self, div: &Self) -> (Choice, Self)

Computes: Read more
source§

fn is_zero(&self) -> Choice

Returns true iff this element is zero.
source§

fn is_zero_vartime(&self) -> bool

Returns true iff this element is zero. Read more
source§

fn cube(&self) -> Self

Cubes this element.
source§

fn sqrt_alt(&self) -> (Choice, Self)

Equivalent to Self::sqrt_ratio(self, one()). Read more
source§

fn sqrt(&self) -> CtOption<Self>

Returns the square root of the field element, if it is quadratic residue. Read more
source§

fn pow<S>(&self, exp: S) -> Self
where S: AsRef<[u64]>,

Exponentiates self by exp, where exp is a little-endian order integer exponent. Read more
source§

fn pow_vartime<S>(&self, exp: S) -> Self
where S: AsRef<[u64]>,

Exponentiates self by exp, where exp is a little-endian order integer exponent. Read more
source§

impl From<Gf256> for u128

source§

fn from(val: Gf256) -> u128

Converts to this type from the input type.
source§

impl From<Gf256> for u16

source§

fn from(val: Gf256) -> u16

Converts to this type from the input type.
source§

impl From<Gf256> for u32

source§

fn from(val: Gf256) -> u32

Converts to this type from the input type.
source§

impl From<Gf256> for u64

source§

fn from(val: Gf256) -> u64

Converts to this type from the input type.
source§

impl From<Gf256> for u8

source§

fn from(val: Gf256) -> u8

Converts to this type from the input type.
source§

impl From<u128> for Gf256

source§

fn from(val: u128) -> Self

Converts to this type from the input type.
source§

impl From<u16> for Gf256

source§

fn from(val: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for Gf256

source§

fn from(val: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for Gf256

source§

fn from(val: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for Gf256

source§

fn from(val: u8) -> Self

Converts to this type from the input type.
source§

impl Hash for Gf256

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl LowerHex for Gf256

source§

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

Formats the value using the given formatter.
source§

impl Mul<&Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Gf256) -> Gf256

Performs the * operation. Read more
source§

impl Mul<&Gf256> for Gf256

§

type Output = Gf256

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Gf256) -> Gf256

Performs the * operation. Read more
source§

impl Mul<Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Gf256) -> Gf256

Performs the * operation. Read more
source§

impl Mul for Gf256

§

type Output = Gf256

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
source§

impl MulAssign<&Gf256> for Gf256

source§

fn mul_assign(&mut self, rhs: &Gf256)

Performs the *= operation. Read more
source§

impl MulAssign for Gf256

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl Neg for Gf256

§

type Output = Gf256

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl Ord for Gf256

source§

fn cmp(&self, other: &Gf256) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Gf256

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Gf256

source§

fn partial_cmp(&self, other: &Gf256) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PrimeField for Gf256

§

type Repr = [u8; 1]

The prime field can be converted back and forth into this binary representation.
source§

fn from_repr(repr: Self::Repr) -> CtOption<Self>

Attempts to convert a byte representation of a field element into an element of this prime field, failing if the input is not canonical (is not smaller than the field’s modulus). Read more
source§

fn to_repr(&self) -> Self::Repr

Converts an element of the prime field into the standard byte representation for this field. Read more
source§

fn is_odd(&self) -> Choice

Returns true iff this element is odd.
source§

const MODULUS: &'static str = ""

Modulus of the field written as a string for debugging purposes. Read more
source§

const NUM_BITS: u32 = 8u32

How many bits are needed to represent an element of this field.
source§

const CAPACITY: u32 = 7u32

How many bits of information can be reliably stored in the field element. Read more
source§

const TWO_INV: Self = _

Inverse of $2$ in the field.
source§

const MULTIPLICATIVE_GENERATOR: Self = _

A fixed multiplicative generator of modulus - 1 order. This element must also be a quadratic nonresidue. Read more
source§

const S: u32 = 3u32

An integer s satisfying the equation 2^s * t = modulus - 1 with t odd. Read more
source§

const ROOT_OF_UNITY: Self = _

The 2^s root of unity. Read more
source§

const ROOT_OF_UNITY_INV: Self = _

source§

const DELTA: Self = _

Generator of the t-order multiplicative subgroup. Read more
source§

fn from_str_vartime(s: &str) -> Option<Self>

Interpret a string of numbers as a (congruent) prime field element. Does not accept unnecessary leading zeroes or a blank string. Read more
source§

fn from_u128(v: u128) -> Self

Obtains a field element congruent to the integer v. Read more
source§

fn from_repr_vartime(repr: Self::Repr) -> Option<Self>

Attempts to convert a byte representation of a field element into an element of this prime field, failing if the input is not canonical (is not smaller than the field’s modulus). Read more
source§

fn is_even(&self) -> Choice

Returns true iff this element is even.
source§

impl<T: Borrow<Gf256>> Product<T> for Gf256

source§

fn product<I: Iterator<Item = T>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by multiplying the items.
source§

impl Sub<&Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Gf256) -> Gf256

Performs the - operation. Read more
source§

impl Sub<&Gf256> for Gf256

§

type Output = Gf256

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Gf256) -> Gf256

Performs the - operation. Read more
source§

impl Sub<Gf256> for &Gf256

§

type Output = Gf256

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Gf256) -> Gf256

Performs the - operation. Read more
source§

impl Sub for Gf256

§

type Output = Gf256

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
source§

impl SubAssign<&Gf256> for Gf256

source§

fn sub_assign(&mut self, rhs: &Gf256)

Performs the -= operation. Read more
source§

impl SubAssign for Gf256

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl<T: Borrow<Gf256>> Sum<T> for Gf256

source§

fn sum<I: Iterator<Item = T>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl UpperHex for Gf256

source§

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

Formats the value using the given formatter.
source§

impl Copy for Gf256

source§

impl Eq for Gf256

source§

impl StructuralPartialEq for Gf256

Auto Trait Implementations§

§

impl Freeze for Gf256

§

impl RefUnwindSafe for Gf256

§

impl Send for Gf256

§

impl Sync for Gf256

§

impl Unpin for Gf256

§

impl UnwindSafe for Gf256

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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.
source§

impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
where T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>,

source§

impl<T, Rhs, Output> GroupOpsOwned<Rhs, Output> for T
where T: for<'r> GroupOps<&'r Rhs, Output>,

source§

impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T
where T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,

source§

impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T
where T: for<'r> ScalarMul<&'r Rhs, Output>,