Struct generic_ec::Scalar

source ·
pub struct Scalar<E: Curve>(/* private fields */);
Expand description

Scalar modulo curve E group order

Scalar is an integer modulo curve E group order.

Implementations§

source§

impl<E: Curve> Scalar<E>

source

pub fn zero() -> Self

Returns scalar $S = 0$

use generic_ec::{Scalar, curves::Secp256k1};
use rand::rngs::OsRng;

let s = Scalar::<Secp256k1>::random(&mut OsRng);
assert_eq!(s * Scalar::zero(), Scalar::zero());
assert_eq!(s + Scalar::zero(), s);
source

pub fn one() -> Self

Returns scalar $S = 1$

use generic_ec::{Scalar, curves::Secp256k1};
use rand::rngs::OsRng;

let s = Scalar::<Secp256k1>::random(&mut OsRng);
assert_eq!(s * Scalar::one(), s);
source

pub fn invert(&self) -> Option<Self>

Returns scalar inverse $S^{-1}$

Inverse of scalar $S$ is a scalar $S^{-1}$ such as $S \cdot S^{-1} = 1$. Inverse doesn’t exist only for scalar $S = 0$, so function returns None if scalar is zero.

use generic_ec::{Scalar, curves::Secp256k1};
use rand::rngs::OsRng;

let s = Scalar::<Secp256k1>::random(&mut OsRng);
let s_inv = s.invert()?;
assert_eq!(s * s_inv, Scalar::one());
source

pub fn ct_invert(&self) -> CtOption<Self>

Returns scalar inverse $S^{-1}$ (constant time)

Same as Scalar::invert but performs constant-time check on whether it’s zero scalar

source

pub fn to_be_bytes(&self) -> EncodedScalar<E>

Encodes scalar as bytes in big-endian order

use generic_ec::{Scalar, curves::Secp256k1};
use rand::rngs::OsRng;

let s = Scalar::<Secp256k1>::random(&mut OsRng);
let bytes = s.to_be_bytes();
println!("Scalar hex representation: {}", hex::encode(bytes));
source

pub fn to_le_bytes(&self) -> EncodedScalar<E>

Encodes scalar as bytes in little-endian order

source

pub fn from_be_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, InvalidScalar>

Decodes scalar from its representation as bytes in big-endian order

Returns error if encoded integer is larger than group order.

use generic_ec::{Scalar, curves::Secp256k1};
use rand::rngs::OsRng;

let s = Scalar::<Secp256k1>::random(&mut OsRng);
let s_bytes = s.to_be_bytes();
let s_decoded = Scalar::from_be_bytes(&s_bytes)?;
assert_eq!(s, s_decoded);
source

pub fn from_le_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, InvalidScalar>

Decodes scalar from its representation as bytes in little-endian order

Returns error if encoded integer is larger than group order.

source

pub fn from_be_bytes_mod_order(bytes: impl AsRef<[u8]>) -> Self

Interprets provided bytes as integer $i$ in big-endian order, returns scalar $s = i \mod q$

source

pub fn from_le_bytes_mod_order(bytes: impl AsRef<[u8]>) -> Self

Interprets provided bytes as integer $i$ in little-endian order, returns scalar $s = i \mod q$

source

pub fn random<R: RngCore>(rng: &mut R) -> Self

Generates random non-zero scalar

Algorithm is based on rejection sampling: we sample a scalar, if it’s zero try again. It may be considered constant-time as zero scalar appears with $2^{-256}$ probability which is considered to be negligible.

§Panics

Panics if randomness source returned 100 zero scalars in a row. It happens with $2^{-25600}$ probability, which practically means that randomness source is broken.

source

pub fn serialized_len() -> usize

Returns size of bytes buffer that can fit serialized scalar

Trait Implementations§

source§

impl<E: Curve> Add<&NonZero<Scalar<E>>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &NonZero<Scalar<E>>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<&NonZero<Scalar<E>>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &NonZero<Scalar<E>>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<&Scalar<E>> for &NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<&Scalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<&Scalar<E>> for &SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<&Scalar<E>> for NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<&Scalar<E>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<&Scalar<E>> for SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<&SecretScalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &SecretScalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<&SecretScalar<E>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &SecretScalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<NonZero<Scalar<E>>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: NonZero<Scalar<E>>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<NonZero<Scalar<E>>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: NonZero<Scalar<E>>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<Scalar<E>> for &NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<Scalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<Scalar<E>> for &SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<Scalar<E>> for NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<Scalar<E>> for SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<SecretScalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: SecretScalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add<SecretScalar<E>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: SecretScalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> Add for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Scalar<E>) -> Self::Output

Performs the + operation. Read more
source§

impl<E: Curve> AddAssign<&Scalar<E>> for Scalar<E>

source§

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

Performs the += operation. Read more
source§

impl<E: Curve> AddAssign for Scalar<E>

source§

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

Performs the += operation. Read more
source§

impl<E: Curve> AsRef<Scalar<E>> for Scalar<E>

source§

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

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<E: Curve> AsRef<Scalar<E>> for SecretScalar<E>

source§

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

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<E: Clone + Curve> Clone for Scalar<E>
where E::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: Curve> ConditionallySelectable for Scalar<E>

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<E: Curve> ConstantTimeEq for Scalar<E>

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<E: Curve> Debug for Scalar<E>

source§

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

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

impl<E: Default + Curve> Default for Scalar<E>
where E::Scalar: Default,

source§

fn default() -> Scalar<E>

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

impl<'de, E: Curve> Deserialize<'de> for Scalar<E>

Available on crate feature serde only.
source§

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

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de, E: Curve> DeserializeAs<'de, Scalar<E>> for Compact

Available on crate feature serde only.
source§

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

Deserialize this value from the given Serde deserializer.
source§

impl<E: Curve> Digestable for Scalar<E>

Available on crate feature udigest only.
source§

fn unambiguously_encode<B>(&self, encoder: EncodeValue<'_, B>)
where B: Buffer,

Unambiguously encodes the value
source§

impl<E: Curve> From<NonZero<Scalar<E>>> for Scalar<E>

source§

fn from(scalar: NonZero<Scalar<E>>) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<i128> for Scalar<E>

source§

fn from(i: i128) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<i16> for Scalar<E>

source§

fn from(i: i16) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<i32> for Scalar<E>

source§

fn from(i: i32) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<i64> for Scalar<E>

source§

fn from(i: i64) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<i8> for Scalar<E>

source§

fn from(i: i8) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<u128> for Scalar<E>

source§

fn from(i: u128) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<u16> for Scalar<E>

source§

fn from(i: u16) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<u32> for Scalar<E>

source§

fn from(i: u32) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<u64> for Scalar<E>

source§

fn from(i: u64) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<u8> for Scalar<E>

source§

fn from(i: u8) -> Self

Converts to this type from the input type.
source§

impl<E: Curve> From<usize> for Scalar<E>

source§

fn from(i: usize) -> Self

Converts to this type from the input type.
source§

impl<E> FromHash for Scalar<E>
where E: Curve + HashToCurve,

source§

fn hash_concat(tag: Tag<'_>, message: &[&[u8]]) -> Result<Self, HashError>

Computes H(message[0] || ... || message[len - 1])
source§

fn hash(tag: Tag<'_>, message: &[u8]) -> Result<Self, HashError>

Computes H(message)
source§

impl<E: Curve> Hash for Scalar<E>

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<E: Curve> IsZero for Scalar<E>

source§

fn is_zero(&self) -> bool

Checks whether self is zero
source§

impl<E: Curve> Mul<&Generator<E>> for &Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Generator<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Generator<E>> for Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Generator<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&NonZero<Point<E>>> for &Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &NonZero<Point<E>>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&NonZero<Point<E>>> for Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &NonZero<Point<E>>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&NonZero<Scalar<E>>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &NonZero<Scalar<E>>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&NonZero<Scalar<E>>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &NonZero<Scalar<E>>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Point<E>> for &Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Point<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Point<E>> for Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Point<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for &Generator<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for &NonZero<Point<E>>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for &NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for &Point<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for &SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for Generator<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for NonZero<Point<E>>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for Point<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&Scalar<E>> for SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&SecretScalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &SecretScalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<&SecretScalar<E>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &SecretScalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Generator<E>> for &Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Generator<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Generator<E>> for Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Generator<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<NonZero<Point<E>>> for &Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NonZero<Point<E>>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<NonZero<Point<E>>> for Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NonZero<Point<E>>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<NonZero<Scalar<E>>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NonZero<Scalar<E>>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<NonZero<Scalar<E>>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: NonZero<Scalar<E>>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Point<E>> for &Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Point<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Point<E>> for Scalar<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Point<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for &Generator<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for &NonZero<Point<E>>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for &NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for &Point<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for &SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for Generator<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for NonZero<Point<E>>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for Point<E>

§

type Output = Point<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<Scalar<E>> for SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<SecretScalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: SecretScalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul<SecretScalar<E>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: SecretScalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> Mul for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Scalar<E>) -> Self::Output

Performs the * operation. Read more
source§

impl<E: Curve> MulAssign<&Scalar<E>> for Point<E>

source§

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

Performs the *= operation. Read more
source§

impl<E: Curve> MulAssign<&Scalar<E>> for Scalar<E>

source§

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

Performs the *= operation. Read more
source§

impl<E: Curve> MulAssign<Scalar<E>> for Point<E>

source§

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

Performs the *= operation. Read more
source§

impl<E: Curve> MulAssign for Scalar<E>

source§

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

Performs the *= operation. Read more
source§

impl<E: Curve> Neg for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<E: Curve> Neg for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<E: Curve> One for Scalar<E>

source§

fn one() -> Self

source§

fn is_one(x: &Self) -> Choice

source§

impl<E: Curve> Ord for Scalar<E>

source§

fn cmp(&self, other: &Self) -> 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<E: PartialEq + Curve> PartialEq for Scalar<E>
where E::Scalar: PartialEq,

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: Curve> PartialOrd for Scalar<E>

source§

fn partial_cmp(&self, other: &Self) -> 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<'a, E: Curve> Product<&'a Scalar<E>> for Scalar<E>

source§

fn product<I: Iterator<Item = &'a Self>>(iter: I) -> Self

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

impl<'s, E: Curve> Product<&'s SecretScalar<E>> for Scalar<E>

source§

fn product<I: Iterator<Item = &'s SecretScalar<E>>>(iter: I) -> Self

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

impl<E: Curve> Product<SecretScalar<E>> for Scalar<E>

source§

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

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

impl<E: Curve> Product for Scalar<E>

source§

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

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

impl<E: Curve> Samplable for Scalar<E>

source§

fn random<R: RngCore>(rng: &mut R) -> Self

source§

impl<E: Curve> Serialize for Scalar<E>

Available on crate feature serde only.
source§

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

Serialize this value into the given Serde serializer. Read more
source§

impl<E: Curve> SerializeAs<Scalar<E>> for Compact

Available on crate feature serde only.
source§

fn serialize_as<S>(source: &Scalar<E>, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer.
source§

impl<E: Curve> Sub<&NonZero<Scalar<E>>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &NonZero<Scalar<E>>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<&NonZero<Scalar<E>>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &NonZero<Scalar<E>>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<&Scalar<E>> for &NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<&Scalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<&Scalar<E>> for &SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<&Scalar<E>> for NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<&Scalar<E>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<&Scalar<E>> for SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<&SecretScalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &SecretScalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<&SecretScalar<E>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &SecretScalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<NonZero<Scalar<E>>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: NonZero<Scalar<E>>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<NonZero<Scalar<E>>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: NonZero<Scalar<E>>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<Scalar<E>> for &NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<Scalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<Scalar<E>> for &SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<Scalar<E>> for NonZero<Scalar<E>>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<Scalar<E>> for SecretScalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<SecretScalar<E>> for &Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: SecretScalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub<SecretScalar<E>> for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: SecretScalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Curve> Sub for Scalar<E>

§

type Output = Scalar<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Scalar<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<'s, E: Curve> Sum<&'s NonZero<Scalar<E>>> for Scalar<E>

source§

fn sum<I: Iterator<Item = &'s NonZero<Scalar<E>>>>(iter: I) -> Self

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

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

source§

fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self

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

impl<'s, E: Curve> Sum<&'s SecretScalar<E>> for Scalar<E>

source§

fn sum<I: Iterator<Item = &'s SecretScalar<E>>>(iter: I) -> Self

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

impl<E: Curve> Sum<NonZero<Scalar<E>>> for Scalar<E>

source§

fn sum<I: Iterator<Item = NonZero<Scalar<E>>>>(iter: I) -> Self

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

impl<E: Curve> Sum<SecretScalar<E>> for Scalar<E>

source§

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

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

impl<E: Curve> Sum for Scalar<E>

source§

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

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

impl<E: Curve> TryFrom<Scalar<E>> for NonZero<Scalar<E>>

§

type Error = ZeroScalar

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

fn try_from(scalar: Scalar<E>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<E: Curve> Zero for Scalar<E>

source§

impl<E: Curve> Zeroize for Scalar<E>

source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
source§

impl<E: Copy + Curve> Copy for Scalar<E>
where E::Scalar: Copy,

source§

impl<E: Eq + Curve> Eq for Scalar<E>
where E::Scalar: Eq,

source§

impl<E: Curve> StructuralPartialEq for Scalar<E>

Auto Trait Implementations§

§

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

§

impl<E> Send for Scalar<E>

§

impl<E> Sync for Scalar<E>

§

impl<E> Unpin for Scalar<E>

§

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

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> ConditionallyNegatable for T
where T: ConditionallySelectable, &'a T: for<'a> Neg<Output = T>,

source§

fn conditional_negate(&mut self, choice: Choice)

Negate self if choice == Choice(1); otherwise, leave it unchanged. 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, 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

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

§

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