Type Alias k256::NonZeroScalar

source ·
pub type NonZeroScalar = NonZeroScalar<Secp256k1>;
Expand description

Non-zero secp256k1 (K-256) scalar field element.

Aliased Type§

struct NonZeroScalar { /* private fields */ }

Implementations

source§

impl<C> NonZeroScalar<C>
where C: CurveArithmetic,

source

pub fn random(rng: &mut impl CryptoRngCore) -> NonZeroScalar<C>

Generate a random NonZeroScalar.

source

pub fn new(scalar: <C as CurveArithmetic>::Scalar) -> CtOption<NonZeroScalar<C>>

Create a NonZeroScalar from a scalar.

source

pub fn from_repr( repr: GenericArray<u8, <C as Curve>::FieldBytesSize>, ) -> CtOption<NonZeroScalar<C>>

Decode a NonZeroScalar from a big endian-serialized field element.

source

pub fn from_uint(uint: <C as Curve>::Uint) -> CtOption<NonZeroScalar<C>>

Create a NonZeroScalar from a C::Uint.

Trait Implementations

source§

impl<C> AsRef<<C as CurveArithmetic>::Scalar> for NonZeroScalar<C>
where C: CurveArithmetic,

source§

fn as_ref(&self) -> &<C as CurveArithmetic>::Scalar

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

impl<C> Clone for NonZeroScalar<C>

source§

fn clone(&self) -> NonZeroScalar<C>

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<C> ConditionallySelectable for NonZeroScalar<C>
where C: CurveArithmetic,

source§

fn conditional_select( a: &NonZeroScalar<C>, b: &NonZeroScalar<C>, choice: Choice, ) -> NonZeroScalar<C>

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<C> ConstantTimeEq for NonZeroScalar<C>
where C: CurveArithmetic,

source§

fn ct_eq(&self, other: &NonZeroScalar<C>) -> 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<C> Deref for NonZeroScalar<C>
where C: CurveArithmetic,

§

type Target = <C as CurveArithmetic>::Scalar

The resulting type after dereferencing.
source§

fn deref(&self) -> &<C as CurveArithmetic>::Scalar

Dereferences the value.
source§

impl<'de, C> Deserialize<'de> for NonZeroScalar<C>
where C: CurveArithmetic,

source§

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

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

impl<C> Display for NonZeroScalar<C>
where C: CurveArithmetic,

source§

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

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

impl<C> From<&SecretKey<C>> for NonZeroScalar<C>
where C: CurveArithmetic,

source§

fn from(sk: &SecretKey<C>) -> NonZeroScalar<C>

Converts to this type from the input type.
source§

impl<C> From<SecretKey<C>> for NonZeroScalar<C>
where C: CurveArithmetic,

source§

fn from(sk: SecretKey<C>) -> NonZeroScalar<C>

Converts to this type from the input type.
source§

impl<C> FromStr for NonZeroScalar<C>
where C: CurveArithmetic,

§

type Err = Error

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

fn from_str(hex: &str) -> Result<NonZeroScalar<C>, Error>

Parses a string s to return a value of this type. Read more
source§

impl<C> Invert for NonZeroScalar<C>

§

type Output = NonZeroScalar<C>

Field element type
source§

fn invert(&self) -> NonZeroScalar<C>

Invert a field element.
source§

fn invert_vartime(&self) -> <NonZeroScalar<C> as Invert>::Output

Invert a field element in variable time. Read more
source§

impl<C> IsHigh for NonZeroScalar<C>
where C: CurveArithmetic,

source§

fn is_high(&self) -> Choice

Is this scalar greater than or equal to n / 2?
source§

impl<C> LowerHex for NonZeroScalar<C>
where C: CurveArithmetic,

source§

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

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

impl<C> Mul<&NonZeroScalar<C>> for NonZeroScalar<C>

§

type Output = NonZeroScalar<C>

The resulting type after applying the * operator.
source§

fn mul(self, other: &NonZeroScalar<C>) -> NonZeroScalar<C>

Performs the * operation. Read more
source§

impl<C> Mul for NonZeroScalar<C>

§

type Output = NonZeroScalar<C>

The resulting type after applying the * operator.
source§

fn mul(self, other: NonZeroScalar<C>) -> NonZeroScalar<C>

Performs the * operation. Read more
source§

impl<C> Neg for NonZeroScalar<C>
where C: CurveArithmetic,

§

type Output = NonZeroScalar<C>

The resulting type after applying the - operator.
source§

fn neg(self) -> NonZeroScalar<C>

Performs the unary - operation. Read more
source§

impl<C, I> Reduce<I> for NonZeroScalar<C>

Note: this is a non-zero reduction, as it’s impl’d for NonZeroScalar.

§

type Bytes = <<C as CurveArithmetic>::Scalar as Reduce<I>>::Bytes

Bytes used as input to Reduce::reduce_bytes.
source§

fn reduce(n: I) -> NonZeroScalar<C>

Perform a modular reduction, returning a field element.
source§

fn reduce_bytes( bytes: &<NonZeroScalar<C> as Reduce<I>>::Bytes, ) -> NonZeroScalar<C>

Interpret the given bytes as an integer and perform a modular reduction.
source§

impl<C, I> ReduceNonZero<I> for NonZeroScalar<C>

Note: forwards to the Reduce impl.

source§

fn reduce_nonzero(n: I) -> NonZeroScalar<C>

Perform a modular reduction, returning a field element.
source§

fn reduce_nonzero_bytes( bytes: &<NonZeroScalar<C> as Reduce<I>>::Bytes, ) -> NonZeroScalar<C>

Interpret the given bytes as an integer and perform a modular reduction to a non-zero output.
source§

impl<C> Serialize for NonZeroScalar<C>
where C: CurveArithmetic,

source§

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

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

impl<C> TryFrom<&[u8]> for NonZeroScalar<C>
where C: CurveArithmetic,

§

type Error = Error

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

fn try_from(bytes: &[u8]) -> Result<NonZeroScalar<C>, Error>

Performs the conversion.
source§

impl<C> UpperHex for NonZeroScalar<C>
where C: CurveArithmetic,

source§

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

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

impl<C> Zeroize for NonZeroScalar<C>
where C: CurveArithmetic,

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<C> Copy for NonZeroScalar<C>
where C: CurveArithmetic,