Skip to main content

NonIdentity

Struct NonIdentity 

Source
#[repr(transparent)]
pub struct NonIdentity<P> { point: P, }
Expand description

Non-identity point type.

This type ensures that its value is not the identity point, ala core::num::NonZero*.

In the context of ECC, it’s useful for ensuring that certain arithmetic cannot result in the identity point.

Fields§

§point: P

Implementations§

Source§

impl<P> NonIdentity<P>

Source

pub fn new(point: P) -> CtOption<Self>

Create a NonIdentity from a point.

Source

pub(crate) fn new_unchecked(point: P) -> Self

Source§

impl<P> NonIdentity<P>

Source

pub fn from_repr(repr: &P::Repr) -> CtOption<Self>

Decode a NonIdentity from its encoding.

Source§

impl<P> NonIdentity<P>

Source

pub fn array_as_inner<const N: usize>(points: &[Self; N]) -> &[P; N]

Transform array reference containing NonIdentity points to an array reference to the inner point type.

Source

pub fn slice_as_inner(points: &[Self]) -> &[P]

Transform slice containing NonIdentity points to a slice of the inner point type.

Source

pub fn cast_array_as_inner<const N: usize>(points: &[Self; N]) -> &[P; N]

👎Deprecated since 0.14.0: use NonIdentity::array_as_inner instead

Transform array reference containing NonIdentity points to an array reference to the inner point type.

Source

pub fn cast_slice_as_inner(points: &[Self]) -> &[P]

👎Deprecated since 0.14.0: use NonIdentity::slice_as_inner instead

Transform slice containing NonIdentity points to a slice of the inner point type.

Source§

impl<P: Copy> NonIdentity<P>

Source

pub fn to_point(self) -> P

Return wrapped point.

Source§

impl<P> NonIdentity<P>

Source

pub fn random<R: CryptoRng + ?Sized>(rng: &mut R) -> Self

👎Deprecated since 0.14.0: use the Generate trait instead

Generate a random NonIdentity<ProjectivePoint>.

Source

pub fn to_affine(self) -> NonIdentity<P::Affine>

Converts this element into its affine representation.

Source

pub fn mul_by_generator<C: CurveArithmetic>(scalar: &NonZeroScalar<C>) -> Self
where P: Group<Scalar = C::Scalar>,

Multiply by the generator of the prime-order subgroup.

Source§

impl<P> NonIdentity<P>

Source

pub fn to_curve(self) -> NonIdentity<P::Curve>

Converts this element to its curve representation.

Trait Implementations§

Source§

impl<P> AsRef<P> for NonIdentity<P>

Source§

fn as_ref(&self) -> &P

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

impl<P> BatchNormalize<[NonIdentity<P>]> for NonIdentity<P>
where P: CurveGroup + BatchNormalize<[P], Output = Vec<P::Affine>>,

Available on crate feature alloc only.
Source§

type Output = Vec<NonIdentity<<P as Curve>::Affine>>

The output of the batch normalization; a container of affine points.
Source§

fn batch_normalize(points: &[Self]) -> Vec<NonIdentity<P::Affine>>

Perform a batched conversion to affine representation on a sequence of projective points at an amortized cost that should be practically as efficient as a single conversion. Internally, implementors should rely upon InvertBatch.
Source§

fn batch_normalize_vartime(points: &Points) -> Self::Output

Perform a batched conversion to affine representation on a sequence of projective points in variable-time. Read more
Source§

impl<const N: usize, P> BatchNormalize<[NonIdentity<P>; N]> for NonIdentity<P>
where P: CurveGroup + BatchNormalize<[P; N], Output = [P::Affine; N]>,

Source§

type Output = [NonIdentity<<P as Curve>::Affine>; N]

The output of the batch normalization; a container of affine points.
Source§

fn batch_normalize(points: &[Self; N]) -> [NonIdentity<P::Affine>; N]

Perform a batched conversion to affine representation on a sequence of projective points at an amortized cost that should be practically as efficient as a single conversion. Internally, implementors should rely upon InvertBatch.
Source§

fn batch_normalize_vartime(points: &Points) -> Self::Output

Perform a batched conversion to affine representation on a sequence of projective points in variable-time. Read more
Source§

impl<P: Clone> Clone for NonIdentity<P>

Source§

fn clone(&self) -> NonIdentity<P>

Returns a duplicate 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<P> ConditionallySelectable for NonIdentity<P>

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<P> ConstantTimeEq for NonIdentity<P>
where P: ConstantTimeEq,

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<P: Debug> Debug for NonIdentity<P>

Source§

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

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

impl<P> Deref for NonIdentity<P>

Source§

type Target = P

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<C, P> From<&NonIdentity<P>> for PublicKey<C>
where C: CurveArithmetic, P: Copy + Into<AffinePoint<C>>,

Source§

fn from(value: &NonIdentity<P>) -> Self

Converts to this type from the input type.
Source§

impl<C> From<&PublicKey<C>> for NonIdentity<AffinePoint<C>>
where C: CurveArithmetic,

Source§

fn from(value: &PublicKey<C>) -> Self

Converts to this type from the input type.
Source§

impl<C, P> From<NonIdentity<P>> for PublicKey<C>
where C: CurveArithmetic, P: Copy + Into<AffinePoint<C>>,

Source§

fn from(value: NonIdentity<P>) -> Self

Converts to this type from the input type.
Source§

impl<C> From<PublicKey<C>> for NonIdentity<AffinePoint<C>>
where C: CurveArithmetic,

Source§

fn from(value: PublicKey<C>) -> Self

Converts to this type from the input type.
Source§

impl<P> Generate for NonIdentity<P>

Source§

fn try_generate_from_rng<R: TryCryptoRng + ?Sized>( rng: &mut R, ) -> Result<Self, R::Error>

Generate random key using the provided TryCryptoRng. Read more
Source§

fn generate_from_rng<R>(rng: &mut R) -> Self
where R: CryptoRng + ?Sized,

Generate random key using the provided CryptoRng.
Source§

fn try_generate() -> Result<Self, Error>

Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator. Read more
Source§

fn generate() -> Self

Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator. Read more
Source§

impl<P> GroupEncoding for NonIdentity<P>

Source§

type Repr = <P as GroupEncoding>::Repr

The encoding of group elements. Read more
Source§

fn from_bytes(bytes: &Self::Repr) -> CtOption<Self>

Attempts to deserialize a group element from its encoding.
Source§

fn from_bytes_unchecked(bytes: &Self::Repr) -> CtOption<Self>

Attempts to deserialize a group element, not checking if the element is valid. Read more
Source§

fn to_bytes(&self) -> Self::Repr

Converts this element into its byte encoding. This may or may not support encoding the identity.
Source§

impl<C, P> Mul<&NonIdentity<P>> for &NonZeroScalar<C>
where C: CurveArithmetic, for<'a> &'a NonIdentity<P>: Mul<&'a NonZeroScalar<C>, Output = NonIdentity<P>>,

Source§

type Output = NonIdentity<P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NonIdentity<P>) -> Self::Output

Performs the * operation. Read more
Source§

impl<C, P> Mul<&NonIdentity<P>> for NonZeroScalar<C>
where C: CurveArithmetic, for<'a> &'a NonIdentity<P>: Mul<NonZeroScalar<C>, Output = NonIdentity<P>>,

Source§

type Output = NonIdentity<P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NonIdentity<P>) -> Self::Output

Performs the * operation. Read more
Source§

impl<C, P> Mul<&NonZeroScalar<C>> for &NonIdentity<P>
where C: CurveArithmetic, P: Copy + Mul<Scalar<C>, Output = P>,

Source§

type Output = NonIdentity<P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NonZeroScalar<C>) -> Self::Output

Performs the * operation. Read more
Source§

impl<C, P> Mul<&NonZeroScalar<C>> for NonIdentity<P>
where C: CurveArithmetic, P: Copy + Mul<Scalar<C>, Output = P>,

Source§

type Output = NonIdentity<P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NonZeroScalar<C>) -> Self::Output

Performs the * operation. Read more
Source§

impl<C, P> Mul<NonIdentity<P>> for &NonZeroScalar<C>
where C: CurveArithmetic, for<'a> NonIdentity<P>: Mul<&'a NonZeroScalar<C>, Output = NonIdentity<P>>,

Source§

type Output = NonIdentity<P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NonIdentity<P>) -> Self::Output

Performs the * operation. Read more
Source§

impl<C, P> Mul<NonIdentity<P>> for NonZeroScalar<C>
where C: CurveArithmetic, NonIdentity<P>: Mul<NonZeroScalar<C>, Output = NonIdentity<P>>,

Source§

type Output = NonIdentity<P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NonIdentity<P>) -> Self::Output

Performs the * operation. Read more
Source§

impl<C, P> Mul<NonZeroScalar<C>> for &NonIdentity<P>
where C: CurveArithmetic, P: Copy + Mul<Scalar<C>, Output = P>,

Source§

type Output = NonIdentity<P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NonZeroScalar<C>) -> Self::Output

Performs the * operation. Read more
Source§

impl<C, P> Mul<NonZeroScalar<C>> for NonIdentity<P>
where C: CurveArithmetic, P: Copy + Mul<Scalar<C>, Output = P>,

Source§

type Output = NonIdentity<P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NonZeroScalar<C>) -> Self::Output

Performs the * operation. Read more
Source§

impl<P: PartialEq> PartialEq for NonIdentity<P>

Source§

fn eq(&self, other: &NonIdentity<P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P: Group> Zeroize for NonIdentity<P>

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<P: Copy> Copy for NonIdentity<P>

Source§

impl<P: Eq> Eq for NonIdentity<P>

Source§

impl<P> StructuralPartialEq for NonIdentity<P>

Auto Trait Implementations§

§

impl<P> Freeze for NonIdentity<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for NonIdentity<P>
where P: RefUnwindSafe,

§

impl<P> Send for NonIdentity<P>
where P: Send,

§

impl<P> Sync for NonIdentity<P>
where P: Sync,

§

impl<P> Unpin for NonIdentity<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for NonIdentity<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for NonIdentity<P>
where P: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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>,

Source§

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>,

Source§

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.