Struct snarkvm_circuit::Scalar

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

Implementations§

§

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

pub fn from_field_lossy(field: Field<E>) -> Scalar<E>

Casts a scalar from a base field, with lossy truncation.

This method is commonly-used by hash-to-scalar algorithms, where the hash output does not need to preserve the full base field.

Trait Implementations§

§

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

§

type Output = Scalar<E>

The resulting type after applying the + operator.
§

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

Performs the + operation. Read more
§

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

§

type Output = Scalar<E>

The resulting type after applying the + operator.
§

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

Performs the + operation. Read more
§

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

§

type Output = Scalar<E>

The resulting type after applying the + operator.
§

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

Performs the + operation. Read more
§

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

§

type Output = Scalar<E>

The resulting type after applying the + operator.
§

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

Performs the + operation. Read more
§

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

§

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

Performs the += operation. Read more
§

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

§

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

Performs the += operation. Read more
§

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

§

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
§

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

§

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

Returns true if self is less than other.

§

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

Returns true if self is greater than other.

§

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.

§

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>

§

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

§

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

Formats the value using the given formatter. Read more
§

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

§

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

Formats the value using the given formatter. Read more
§

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

§

fn eject_mode(&self) -> Mode

Ejects the mode of the scalar.

§

fn eject_value(&self) -> <Scalar<E> as Eject>::Primitive

Ejects the scalar circuit as a console scalar.

§

type Primitive = Scalar<<E as Environment>::Network>

source§

fn eject(&self) -> (Mode, Self::Primitive)

Ejects the mode and primitive value of the circuit type.
source§

fn is_constant(&self) -> bool

Returns true if the circuit is a constant.
source§

fn is_public(&self) -> bool

Returns true if the circuit is a public.
source§

fn is_private(&self) -> bool

Returns true if the circuit is a private.
§

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

§

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

Returns true if self and other are equal.

§

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>

§

impl<E> From<&Scalar<E>> for LinearCombination<<E as Environment>::BaseField>where E: Environment,

§

fn from(scalar: &Scalar<E>) -> LinearCombination<<E as Environment>::BaseField>

Converts to this type from the input type.
§

impl<E> From<Scalar<E>> for LinearCombination<<E as Environment>::BaseField>where E: Environment,

§

fn from(scalar: Scalar<E>) -> LinearCombination<<E as Environment>::BaseField>

Converts to this type from the input type.
§

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

§

fn from_bits_le(bits_le: &[<Scalar<E> as FromBits>::Boolean]) -> Scalar<E>

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

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

fn from_bits_be(bits_be: &[<Scalar<E> as FromBits>::Boolean]) -> Scalar<E>

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

§

type Boolean = Boolean<E>

§

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

§

fn from_field(field: <Scalar<E> as FromField>::Field) -> Scalar<E>

Casts a scalar from a base field element.

This method guarantees the following:

  1. If the field element is larger than the scalar field modulus, then the operation will fail.
  2. If the field element is smaller than the scalar field modulus, then the operation will succeed. - This is particularly useful for the case where a user called, Scalar::from_field(scalar.to_field()), and the scalar bit representation is between size_in_data_bits < bits.len() < size_in_bits.
§

type Field = Field<E>

§

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

§

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

Parses a string into a scalar circuit.

§

type Err = Error

The associated error which can be returned from parsing.
§

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

§

fn new(mode: Mode, scalar: <Scalar<E> as Inject>::Primitive) -> Scalar<E>

Initializes a scalar circuit from a console scalar.

§

type Primitive = Scalar<<E as Environment>::Network>

source§

fn constant(value: Self::Primitive) -> Selfwhere Self: Sized,

Initializes a constant of the given primitive value.
§

impl<E> Metrics<dyn Add<Scalar<E>, Output = Scalar<E>>> for Scalar<E>where E: Environment,

§

type Case = (Mode, Mode)

§

fn count( case: &<Scalar<E> as Metrics<dyn Add<Scalar<E>, Output = Scalar<E>>>>::Case ) -> Count

Returns the number of constants, public inputs, private inputs, and constraints.
§

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

§

type Output = Group<E>

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

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

§

type Output = Group<E>

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

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

§

type Output = Group<E>

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

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

§

type Output = Group<E>

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

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

§

type Output = Group<E>

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

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

§

type Output = Group<E>

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

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

§

type Output = Group<E>

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

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

§

type Output = Group<E>

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

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

§

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

Performs the *= operation. Read more
§

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

§

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

Performs the *= operation. Read more
§

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

§

type Boolean = Boolean<E>

§

fn one() -> Scalar<E>

Returns a new one constant.
§

fn is_one(&self) -> <Scalar<E> as One>::Boolean

Returns true if self is one.
§

impl<E> OutputMode<dyn Add<Scalar<E>, Output = Scalar<E>>> for Scalar<E>where E: Environment,

§

type Case = (Mode, Mode)

§

fn output_mode( case: &<Scalar<E> as OutputMode<dyn Add<Scalar<E>, Output = Scalar<E>>>>::Case ) -> Mode

Returns the mode of the output.
§

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

§

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

Parses a string into a scalar circuit.

§

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

§

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>

§

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

§

fn to_bits_le(&self) -> Vec<<&Scalar<E> as ToBits>::Boolean, Global>

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

§

fn to_bits_be(&self) -> Vec<<&Scalar<E> as ToBits>::Boolean, Global>

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

§

type Boolean = Boolean<E>

§

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

§

fn to_bits_le(&self) -> Vec<<Scalar<E> as ToBits>::Boolean, Global>

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

§

fn to_bits_be(&self) -> Vec<<Scalar<E> as ToBits>::Boolean, Global>

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

§

type Boolean = Boolean<E>

§

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

§

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

Casts a scalar field element into a base field element.

§

type Field = Field<E>

§

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

§

fn to_fields(&self) -> Vec<<Scalar<E> as ToFields>::Field, Global>

Casts a string into a list of base fields.

§

type Field = Field<E>

§

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

§

fn type_name() -> &'static str

Returns the type name of the circuit as a string.

§

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

§

type Boolean = Boolean<E>

§

fn zero() -> Scalar<E>

Returns a new zero constant.
§

fn is_zero(&self) -> <Scalar<E> as Zero>::Boolean

Returns true if self is zero.
§

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

§

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

Auto Trait Implementations§

§

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

§

impl<E> !Send for Scalar<E>

§

impl<E> !Sync for Scalar<E>

§

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

§

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

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

§

type Output = T

Should always be Self
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<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V