Struct snarkvm_circuit::Scalar
pub struct Scalar<E>where
E: Environment,{ /* private fields */ }
Implementations§
§impl<E> Scalar<E>where
E: Environment,
impl<E> Scalar<E>where E: Environment,
pub fn from_field_lossy(field: Field<E>) -> Scalar<E>
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,
impl<E> Add<&Scalar<E>> for &Scalar<E>where E: Environment,
§impl<E> Add<&Scalar<E>> for Scalar<E>where
E: Environment,
impl<E> Add<&Scalar<E>> for Scalar<E>where E: Environment,
§impl<E> Add<Scalar<E>> for &Scalar<E>where
E: Environment,
impl<E> Add<Scalar<E>> for &Scalar<E>where E: Environment,
§impl<E> Add<Scalar<E>> for Scalar<E>where
E: Environment,
impl<E> Add<Scalar<E>> for Scalar<E>where E: Environment,
§impl<E> AddAssign<&Scalar<E>> for Scalar<E>where
E: Environment,
impl<E> AddAssign<&Scalar<E>> for Scalar<E>where E: Environment,
§fn add_assign(&mut self, other: &Scalar<E>)
fn add_assign(&mut self, other: &Scalar<E>)
+=
operation. Read more§impl<E> AddAssign<Scalar<E>> for Scalar<E>where
E: Environment,
impl<E> AddAssign<Scalar<E>> for Scalar<E>where E: Environment,
§fn add_assign(&mut self, other: Scalar<E>)
fn add_assign(&mut self, other: Scalar<E>)
+=
operation. Read more§impl<E> Clone for Scalar<E>where
E: Clone + Environment,
impl<E> Clone for Scalar<E>where E: Clone + Environment,
§impl<E> Compare<Scalar<E>> for Scalar<E>where
E: Environment,
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
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
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
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
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,
impl<E> Debug for Scalar<E>where E: Environment,
§impl<E> Display for Scalar<E>where
E: Environment,
impl<E> Display for Scalar<E>where E: Environment,
§impl<E> Eject for Scalar<E>where
E: Environment,
impl<E> Eject for Scalar<E>where E: Environment,
§fn eject_mode(&self) -> Mode
fn eject_mode(&self) -> Mode
Ejects the mode of the scalar.
§fn eject_value(&self) -> <Scalar<E> as Eject>::Primitive
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)
fn eject(&self) -> (Mode, Self::Primitive)
source§fn is_constant(&self) -> bool
fn is_constant(&self) -> bool
true
if the circuit is a constant.source§fn is_private(&self) -> bool
fn is_private(&self) -> bool
true
if the circuit is a private.§impl<E> Equal<Scalar<E>> for Scalar<E>where
E: Environment,
impl<E> Equal<Scalar<E>> for Scalar<E>where E: Environment,
§impl<E> From<&Scalar<E>> for LinearCombination<<E as Environment>::BaseField>where
E: Environment,
impl<E> From<&Scalar<E>> for LinearCombination<<E as Environment>::BaseField>where E: Environment,
§fn from(scalar: &Scalar<E>) -> LinearCombination<<E as Environment>::BaseField>
fn from(scalar: &Scalar<E>) -> LinearCombination<<E as Environment>::BaseField>
§impl<E> From<Scalar<E>> for LinearCombination<<E as Environment>::BaseField>where
E: Environment,
impl<E> From<Scalar<E>> for LinearCombination<<E as Environment>::BaseField>where E: Environment,
§fn from(scalar: Scalar<E>) -> LinearCombination<<E as Environment>::BaseField>
fn from(scalar: Scalar<E>) -> LinearCombination<<E as Environment>::BaseField>
§impl<E> FromBits for Scalar<E>where
E: Environment,
impl<E> FromBits for Scalar<E>where E: Environment,
§fn from_bits_le(bits_le: &[<Scalar<E> as FromBits>::Boolean]) -> Scalar<E>
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 thanE::ScalarField::size_in_bits()
, the excess bits are enforced to be0
s. - If
bits_le
is shorter thanE::ScalarField::size_in_bits()
, it is padded with0
s up to scalar field size.
§fn from_bits_be(bits_be: &[<Scalar<E> as FromBits>::Boolean]) -> Scalar<E>
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,
impl<E> FromField for Scalar<E>where E: Environment,
§fn from_field(field: <Scalar<E> as FromField>::Field) -> Scalar<E>
fn from_field(field: <Scalar<E> as FromField>::Field) -> Scalar<E>
Casts a scalar from a base field element.
This method guarantees the following:
- If the field element is larger than the scalar field modulus, then the operation will fail.
- 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 betweensize_in_data_bits < bits.len() < size_in_bits
.
type Field = Field<E>
§impl<E> FromStr for Scalar<E>where
E: Environment,
impl<E> FromStr for Scalar<E>where E: Environment,
§impl<E> Inject for Scalar<E>where
E: Environment,
impl<E> Inject for Scalar<E>where E: Environment,
§impl<E> Mul<&Group<E>> for &Scalar<E>where
E: Environment,
impl<E> Mul<&Group<E>> for &Scalar<E>where E: Environment,
§impl<E> Mul<&Group<E>> for Scalar<E>where
E: Environment,
impl<E> Mul<&Group<E>> for Scalar<E>where E: Environment,
§impl<E> Mul<&Scalar<E>> for &Group<E>where
E: Environment,
impl<E> Mul<&Scalar<E>> for &Group<E>where E: Environment,
§impl<E> Mul<&Scalar<E>> for Group<E>where
E: Environment,
impl<E> Mul<&Scalar<E>> for Group<E>where E: Environment,
§impl<E> Mul<Group<E>> for &Scalar<E>where
E: Environment,
impl<E> Mul<Group<E>> for &Scalar<E>where E: Environment,
§impl<E> Mul<Group<E>> for Scalar<E>where
E: Environment,
impl<E> Mul<Group<E>> for Scalar<E>where E: Environment,
§impl<E> Mul<Scalar<E>> for &Group<E>where
E: Environment,
impl<E> Mul<Scalar<E>> for &Group<E>where E: Environment,
§impl<E> Mul<Scalar<E>> for Group<E>where
E: Environment,
impl<E> Mul<Scalar<E>> for Group<E>where E: Environment,
§impl<E> MulAssign<&Scalar<E>> for Group<E>where
E: Environment,
impl<E> MulAssign<&Scalar<E>> for Group<E>where E: Environment,
§fn mul_assign(&mut self, other: &Scalar<E>)
fn mul_assign(&mut self, other: &Scalar<E>)
*=
operation. Read more§impl<E> MulAssign<Scalar<E>> for Group<E>where
E: Environment,
impl<E> MulAssign<Scalar<E>> for Group<E>where E: Environment,
§fn mul_assign(&mut self, other: Scalar<E>)
fn mul_assign(&mut self, other: Scalar<E>)
*=
operation. Read more§impl<E> One for Scalar<E>where
E: Environment,
impl<E> One for Scalar<E>where E: Environment,
§impl<E> OutputMode<dyn Add<Scalar<E>, Output = Scalar<E>>> for Scalar<E>where
E: Environment,
impl<E> OutputMode<dyn Add<Scalar<E>, Output = Scalar<E>>> for Scalar<E>where E: Environment,
§impl<E> Parser for Scalar<E>where
E: Environment,
impl<E> Parser for Scalar<E>where E: Environment,
§impl<E> Ternary for Scalar<E>where
E: Environment,
impl<E> Ternary for Scalar<E>where E: Environment,
§impl<E> ToBits for &Scalar<E>where
E: Environment,
impl<E> ToBits for &Scalar<E>where E: Environment,
§fn to_bits_le(&self) -> Vec<<&Scalar<E> as ToBits>::Boolean, Global>
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>
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,
impl<E> ToBits for Scalar<E>where E: Environment,
§fn to_bits_le(&self) -> Vec<<Scalar<E> as ToBits>::Boolean, Global>
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>
fn to_bits_be(&self) -> Vec<<Scalar<E> as ToBits>::Boolean, Global>
Outputs the big-endian bit representation of self
without leading zeros.