pub struct Scalar<E>where
    E: Environment,{ /* private fields */ }

Implementations§

source§

impl<E> Scalar<E>where E: Environment,

source

pub const SIZE_IN_BITS: usize = <E::Scalar>::SIZE_IN_BITS

The scalar size in bits.

source

pub const SIZE_IN_BYTES: usize = (<E::Scalar>::SIZE_IN_BITS + 7) / 8

The scalar size in bytes.

source

pub const SIZE_IN_DATA_BITS: usize = <E::Scalar>::SIZE_IN_DATA_BITS

The scalar capacity for data bits.

source

pub const fn new(scalar: <E as Environment>::Scalar) -> Scalar<E>

Initializes a new scalar.

Trait Implementations§

source§

impl<E> Add<&Scalar<E>> for Scalar<E>where E: Environment,

source§

fn add(self, other: &Scalar<E>) -> <Scalar<E> as Add<&Scalar<E>>>::Output

Returns the sum of self and other.

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

impl<E> Add<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn add(self, other: Scalar<E>) -> <Scalar<E> as Add<Scalar<E>>>::Output

Returns the sum of self and other.

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

impl<E> AddAssign<&Scalar<E>> for Scalar<E>where E: Environment,

source§

fn add_assign(&mut self, other: &Scalar<E>)

Adds other to self.

source§

impl<E> AddAssign<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn add_assign(&mut self, other: Scalar<E>)

Adds other to self.

source§

impl<E> Clone for Scalar<E>where E: Clone + Environment, <E as Environment>::Scalar: Clone,

source§

fn clone(&self) -> Scalar<E>

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<E> Compare<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn is_less_than( &self, other: &Scalar<E> ) -> <Scalar<E> as Compare<Scalar<E>>>::Output

Returns true if self is less than other.

source§

fn is_greater_than( &self, other: &Scalar<E> ) -> <Scalar<E> as Compare<Scalar<E>>>::Output

Returns true if self is greater than other.

source§

fn is_less_than_or_equal( &self, other: &Scalar<E> ) -> <Scalar<E> as Compare<Scalar<E>>>::Output

Returns true if self is less than or equal to other.

source§

fn is_greater_than_or_equal( &self, other: &Scalar<E> ) -> <Scalar<E> as Compare<Scalar<E>>>::Output

Returns true if self is greater than or equal to other.

§

type Output = Boolean<E>

source§

impl<E> Debug for Scalar<E>where E: Environment,

source§

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

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

impl<E> Deref for Scalar<E>where E: Environment,

§

type Target = <E as Environment>::Scalar

The resulting type after dereferencing.
source§

fn deref(&self) -> &<Scalar<E> as Deref>::Target

Dereferences the value.
source§

impl<'de, E> Deserialize<'de> for Scalar<E>where E: Environment,

source§

fn deserialize<D>( deserializer: D ) -> Result<Scalar<E>, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,

Deserializes the scalar from a string or bytes.

source§

impl<E> Display for Scalar<E>where E: Environment,

source§

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

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

impl<E> Distribution<Scalar<E>> for Standardwhere E: Environment,

source§

fn sample<R>(&self, rng: &mut R) -> Scalar<E>where R: Rng + ?Sized,

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<E> Div<&Scalar<E>> for Scalar<E>where E: Environment,

source§

fn div(self, other: &Scalar<E>) -> <Scalar<E> as Div<&Scalar<E>>>::Output

Returns the quotient of self and other.

§

type Output = Scalar<E>

The resulting type after applying the / operator.
source§

impl<E> Div<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn div(self, other: Scalar<E>) -> <Scalar<E> as Div<Scalar<E>>>::Output

Returns the quotient of self and other.

§

type Output = Scalar<E>

The resulting type after applying the / operator.
source§

impl<E> DivAssign<&Scalar<E>> for Scalar<E>where E: Environment,

source§

fn div_assign(&mut self, other: &Scalar<E>)

Divides self by other.

source§

impl<E> DivAssign<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn div_assign(&mut self, other: Scalar<E>)

Divides self by other.

source§

impl<E> Double for Scalar<E>where E: Environment,

source§

fn double(&self) -> <Scalar<E> as Double>::Output

Returns the double of self.

§

type Output = Scalar<E>

source§

impl<E> Equal<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn is_equal(&self, other: &Scalar<E>) -> <Scalar<E> as Equal<Scalar<E>>>::Output

Returns true if self and other are equal.

source§

fn is_not_equal( &self, other: &Scalar<E> ) -> <Scalar<E> as Equal<Scalar<E>>>::Output

Returns true if self and other are not equal.

§

type Output = Boolean<E>

source§

impl<E> FromBits for Scalar<E>where E: Environment,

source§

fn from_bits_le(bits_le: &[bool]) -> Result<Scalar<E>, Error>

Initializes a new scalar from a list of little-endian bits.

  • If bits_le is longer than E::Scalar::size_in_bits(), the excess bits are enforced to be 0s.
  • If bits_le is shorter than E::Scalar::size_in_bits(), it is padded with 0s up to scalar size.
source§

fn from_bits_be(bits_be: &[bool]) -> Result<Scalar<E>, Error>

Initializes a new scalar from a list of big-endian bits without leading zeros.

source§

impl<E> FromBytes for Scalar<E>where E: Environment,

source§

fn read_le<R>(reader: R) -> Result<Scalar<E>, Error>where R: Read,

Reads the scalar from a buffer.

§

fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>where Self: Sized,

Returns Self from a byte array in little-endian order.
source§

impl<E> FromStr for Scalar<E>where E: Environment,

source§

fn from_str(string: &str) -> Result<Scalar<E>, Error>

Parses a string into a scalar.

§

type Err = Error

The associated error which can be returned from parsing.
source§

impl<E> Hash for Scalar<E>where E: Hash + Environment, <E as Environment>::Scalar: Hash,

source§

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

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<E> Inverse for Scalar<E>where E: Environment,

source§

fn inverse(&self) -> Result<<Scalar<E> as Inverse>::Output, Error>

Returns the inverse of self.

§

type Output = Scalar<E>

source§

impl<E> Mul<&Group<E>> for Scalar<E>where E: Environment,

source§

fn mul(self, other: &Group<E>) -> <Scalar<E> as Mul<&Group<E>>>::Output

Returns the product of self and other.

§

type Output = Group<E>

The resulting type after applying the * operator.
source§

impl<E> Mul<&Scalar<E>> for Group<E>where E: Environment,

source§

fn mul(self, other: &Scalar<E>) -> <Group<E> as Mul<&Scalar<E>>>::Output

Returns the product of self and other.

§

type Output = Group<E>

The resulting type after applying the * operator.
source§

impl<E> Mul<&Scalar<E>> for Scalar<E>where E: Environment,

source§

fn mul(self, other: &Scalar<E>) -> <Scalar<E> as Mul<&Scalar<E>>>::Output

Returns the product of self and other.

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

impl<E> Mul<Group<E>> for Scalar<E>where E: Environment,

source§

fn mul(self, other: Group<E>) -> <Scalar<E> as Mul<Group<E>>>::Output

Returns the product of self and other.

§

type Output = Group<E>

The resulting type after applying the * operator.
source§

impl<E> Mul<Scalar<E>> for Group<E>where E: Environment,

source§

fn mul(self, other: Scalar<E>) -> <Group<E> as Mul<Scalar<E>>>::Output

Returns the product of self and other.

§

type Output = Group<E>

The resulting type after applying the * operator.
source§

impl<E> Mul<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn mul(self, other: Scalar<E>) -> <Scalar<E> as Mul<Scalar<E>>>::Output

Returns the product of self and other.

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

impl<E> MulAssign<&Scalar<E>> for Group<E>where E: Environment,

source§

fn mul_assign(&mut self, other: &Scalar<E>)

Multiplies self by other.

source§

impl<E> MulAssign<&Scalar<E>> for Scalar<E>where E: Environment,

source§

fn mul_assign(&mut self, other: &Scalar<E>)

Multiplies self by other.

source§

impl<E> MulAssign<Scalar<E>> for Group<E>where E: Environment,

source§

fn mul_assign(&mut self, other: Scalar<E>)

Multiplies self by other.

source§

impl<E> MulAssign<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn mul_assign(&mut self, other: Scalar<E>)

Multiplies self by other.

source§

impl<E> Neg for Scalar<E>where E: Environment,

source§

fn neg(self) -> <Scalar<E> as Neg>::Output

Returns the negation of self.

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

impl<E> One for Scalar<E>where E: Environment,

source§

fn one() -> Scalar<E>

Returns the 1 element of the scalar.

source§

fn is_one(&self) -> bool

Returns true if the element is one.

source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

impl<E> Ord for Scalar<E>where E: Environment,

source§

fn cmp(&self, other: &Scalar<E>) -> Ordering

Returns the lexicographic ordering of self and other.

1.21.0 · source§

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

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

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

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

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

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

impl<E> Parser for Scalar<E>where E: Environment,

source§

fn parse(string: &str) -> Result<(&str, Scalar<E>), Err<VerboseError<&str>>>

Parses a string into a scalar circuit.

source§

impl<E> PartialEq<Scalar<E>> for Scalar<E>where E: PartialEq<E> + Environment, <E as Environment>::Scalar: PartialEq<<E as Environment>::Scalar>,

source§

fn eq(&self, other: &Scalar<E>) -> 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<E> PartialOrd<Scalar<E>> for Scalar<E>where E: Environment,

source§

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

Returns the lexicographic ordering of self and other.

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<E> Pow<&Scalar<E>> for Scalar<E>where E: Environment,

source§

fn pow(self, other: &Scalar<E>) -> <Scalar<E> as Pow<&Scalar<E>>>::Output

Returns the power of self to the power of other.

§

type Output = Scalar<E>

The result after applying the operator.
source§

impl<E> Pow<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn pow(self, other: Scalar<E>) -> <Scalar<E> as Pow<Scalar<E>>>::Output

Returns the power of self to the power of other.

§

type Output = Scalar<E>

The result after applying the operator.
source§

impl<'a, E> Product<&'a Scalar<E>> for Scalar<E>where E: Environment,

source§

fn product<I>(iter: I) -> Scalar<E>where I: Iterator<Item = &'a Scalar<E>>,

Returns the product of self and other.

source§

impl<E> Product<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn product<I>(iter: I) -> Scalar<E>where I: Iterator<Item = Scalar<E>>,

Returns the product of self and other.

source§

impl<E> Serialize for Scalar<E>where E: Environment,

source§

fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,

Serializes the scalar into a string or as bytes.

source§

impl<E> SizeInBits for Scalar<E>where E: Environment,

source§

fn size_in_bits() -> usize

Returns the scalar size in bits.

source§

impl<E> SizeInBytes for Scalar<E>where E: Environment,

source§

fn size_in_bytes() -> usize

Returns the scalar size in bytes.

source§

impl<E> SizeInDataBits for Scalar<E>where E: Environment,

source§

fn size_in_data_bits() -> usize

Returns the scalar capacity for data bits.

source§

impl<E> Square for Scalar<E>where E: Environment,

source§

fn square(&self) -> <Scalar<E> as Square>::Output

Returns the square of self.

§

type Output = Scalar<E>

source§

impl<E> Sub<&Scalar<E>> for Scalar<E>where E: Environment,

source§

fn sub(self, other: &Scalar<E>) -> <Scalar<E> as Sub<&Scalar<E>>>::Output

Returns the difference of self and other.

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

impl<E> Sub<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn sub(self, other: Scalar<E>) -> <Scalar<E> as Sub<Scalar<E>>>::Output

Returns the difference of self and other.

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

impl<E> SubAssign<&Scalar<E>> for Scalar<E>where E: Environment,

source§

fn sub_assign(&mut self, other: &Scalar<E>)

Subtracts other from self.

source§

impl<E> SubAssign<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn sub_assign(&mut self, other: Scalar<E>)

Subtracts other from self.

source§

impl<'a, E> Sum<&'a Scalar<E>> for Scalar<E>where E: Environment,

source§

fn sum<I>(iter: I) -> Scalar<E>where I: Iterator<Item = &'a Scalar<E>>,

Returns the sum of self and other.

source§

impl<E> Sum<Scalar<E>> for Scalar<E>where E: Environment,

source§

fn sum<I>(iter: I) -> Scalar<E>where I: Iterator<Item = Scalar<E>>,

Returns the sum of self and other.

source§

impl<E> Ternary for Scalar<E>where E: Environment,

source§

fn ternary( condition: &<Scalar<E> as Ternary>::Boolean, first: &Scalar<E>, second: &Scalar<E> ) -> <Scalar<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

§

type Boolean = Boolean<E>

§

type Output = Scalar<E>

source§

impl<E> ToBits for Scalar<E>where E: Environment,

source§

fn to_bits_le(&self) -> Vec<bool, Global>

Outputs the little-endian bit representation of self without trailing zeros.

source§

fn to_bits_be(&self) -> Vec<bool, Global>

Outputs the big-endian bit representation of self without leading zeros.

source§

impl<E> ToBytes for Scalar<E>where E: Environment,

source§

fn write_le<W>(&self, writer: W) -> Result<(), Error>where W: Write,

Writes the scalar to a buffer.

§

fn to_bytes_le(&self) -> Result<Vec<u8, Global>, Error>where Self: Sized,

Returns self as a byte array in little-endian order.
source§

impl<E> ToField for Scalar<E>where E: Environment,

source§

fn to_field(&self) -> Result<<Scalar<E> as ToField>::Field, Error>

Returns the scalar as a field element.

§

type Field = Field<E>

source§

impl<E> TypeName for Scalar<E>where E: Environment,

source§

fn type_name() -> &'static str

Returns the type name as a string.

source§

impl<E> Zero for Scalar<E>where E: Environment,

source§

fn zero() -> Scalar<E>

Returns the 0 element of the scalar.

source§

fn is_zero(&self) -> bool

Returns true if the element is zero.

source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<E> Copy for Scalar<E>where E: Copy + Environment, <E as Environment>::Scalar: Copy,

source§

impl<E> Eq for Scalar<E>where E: Eq + Environment, <E as Environment>::Scalar: Eq,

source§

impl<E> GroupTrait<Scalar<E>> for Group<E>where E: Environment,

source§

impl<E> ScalarTrait for Scalar<E>where E: Environment,

source§

impl<E> StructuralEq for Scalar<E>where E: Environment,

source§

impl<E> StructuralPartialEq for Scalar<E>where E: Environment,

Auto Trait Implementations§

§

impl<E> RefUnwindSafe for Scalar<E>where <E as Environment>::Scalar: RefUnwindSafe,

§

impl<E> Send for Scalar<E>

§

impl<E> Sync for Scalar<E>

§

impl<E> Unpin for Scalar<E>where <E as Environment>::Scalar: Unpin,

§

impl<E> UnwindSafe for Scalar<E>where <E as Environment>::Scalar: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<'de, T> DeserializeExt<'de> for Twhere T: DeserializeOwned,

§

fn take_from_value<D>( value: &mut Value, field: &str ) -> Result<T, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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 Twhere 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.
§

impl<T> Uniform for Twhere Standard: Distribution<T>,

§

fn rand<R>(rng: &mut R) -> Twhere R: Rng + ?Sized,

Samples a random value from a uniform distribution.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,