Struct EncodedPoint

Source
pub struct EncodedPoint<C>{ /* private fields */ }
Expand description

SEC1 encoded curve point.

This type is an enum over the compressed and uncompressed encodings, useful for cases where either encoding can be supported, or conversions between the two forms.

Implementations§

Source§

impl<C> EncodedPoint<C>

Source

pub fn from_bytes(input: impl AsRef<[u8]>) -> Result<EncodedPoint<C>, Error>

Decode elliptic curve point (compressed or uncompressed) from the Elliptic-Curve-Point-to-Octet-String encoding described in SEC 1: Elliptic Curve Cryptography (Version 2.0) section 2.3.3 (page 10).

http://www.secg.org/sec1-v2.pdf

Source

pub fn from_untagged_bytes( bytes: &GenericArray<u8, <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output>, ) -> EncodedPoint<C>

Decode elliptic curve point from raw uncompressed coordinates, i.e. encoded as the concatenated x || y coordinates with no leading SEC1 tag byte (which would otherwise be 0x04 for an uncompressed point).

Source

pub fn from_affine_coordinates( x: &GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>, y: &GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>, compress: bool, ) -> EncodedPoint<C>

Encode an elliptic curve point from big endian serialized coordinates (with optional point compression)

Source

pub fn from_secret_key( secret_key: &SecretKey<C>, compress: bool, ) -> EncodedPoint<C>

Compute EncodedPoint representing the public key for the provided SecretKey.

The compress flag requests point compression.

Source

pub fn identity() -> EncodedPoint<C>

Return EncodedPoint representing the additive identity (a.k.a. point at infinity)

Source

pub fn len(&self) -> usize

Get the length of the encoded point in bytes

Source

pub fn as_bytes(&self) -> &[u8]

Get byte slice containing the serialized EncodedPoint.

Source

pub fn to_bytes(&self) -> Box<[u8]>

Get boxed byte slice containing the serialized EncodedPoint

Source

pub fn to_untagged_bytes( &self, ) -> Option<GenericArray<u8, <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output>>

Serialize point as raw uncompressed coordinates without tag byte, i.e. encoded as the concatenated x || y coordinates.

Source

pub fn is_compact(&self) -> bool

Is this EncodedPoint compact?

Source

pub fn is_compressed(&self) -> bool

Is this EncodedPoint compressed?

Source

pub fn is_identity(&self) -> bool

Is this EncodedPoint the additive identity? (a.k.a. point at infinity)

Source

pub fn compress(&self) -> EncodedPoint<C>

Compress this EncodedPoint, returning a new EncodedPoint.

Source

pub fn decompress(&self) -> Option<EncodedPoint<C>>

Decompress this EncodedPoint, returning a new EncodedPoint.

Source

pub fn encode<T>(encodable: T, compress: bool) -> EncodedPoint<C>
where T: ToEncodedPoint<C>,

Encode an EncodedPoint from the desired type

Source

pub fn decode<T>(&self) -> Result<T, Error>
where T: FromEncodedPoint<C>,

Decode this EncodedPoint into the desired type

Source

pub fn tag(&self) -> Tag

Get the SEC1 tag for this EncodedPoint

Source

pub fn coordinates(&self) -> Coordinates<'_, C>

Get the Coordinates for this EncodedPoint.

Source

pub fn x( &self, ) -> Option<&GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>>

Get the x-coordinate for this EncodedPoint.

Returns None if this point is the identity point.

Source

pub fn y( &self, ) -> Option<&GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>>

Get the y-coordinate for this EncodedPoint.

Returns None if this point is compressed or the identity point.

Trait Implementations§

Source§

impl<C> AsRef<[u8]> for EncodedPoint<C>

Source§

fn as_ref(&self) -> &[u8]

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

impl<C> Clone for EncodedPoint<C>

Source§

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

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<C> ConditionallySelectable for EncodedPoint<C>

Source§

fn conditional_select( a: &EncodedPoint<C>, b: &EncodedPoint<C>, choice: Choice, ) -> EncodedPoint<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> Debug for EncodedPoint<C>

Source§

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

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

impl<C> Default for EncodedPoint<C>

Source§

fn default() -> EncodedPoint<C>

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

impl<C> From<&PublicKey<C>> for EncodedPoint<C>

Source§

fn from(public_key: &PublicKey<C>) -> EncodedPoint<C>

Converts to this type from the input type.
Source§

impl<C> From<&VerifyingKey<C>> for EncodedPoint<C>

Source§

fn from(verifying_key: &VerifyingKey<C>) -> EncodedPoint<C>

Converts to this type from the input type.
Source§

impl<C> From<PublicKey<C>> for EncodedPoint<C>

Source§

fn from(public_key: PublicKey<C>) -> EncodedPoint<C>

Converts to this type from the input type.
Source§

impl<C> Ord for EncodedPoint<C>

Source§

fn cmp(&self, other: &EncodedPoint<C>) -> 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,

Restrict a value to a certain interval. Read more
Source§

impl<C> PartialEq for EncodedPoint<C>

Source§

fn eq(&self, other: &EncodedPoint<C>) -> 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<C> PartialOrd for EncodedPoint<C>

Source§

fn partial_cmp(&self, other: &EncodedPoint<C>) -> 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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<C> Zeroize for EncodedPoint<C>

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 EncodedPoint<C>

Source§

impl<C> Eq for EncodedPoint<C>

Source§

impl<C> StructuralPartialEq for EncodedPoint<C>

Auto Trait Implementations§

§

impl<C> Freeze for EncodedPoint<C>
where <<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: Sized, <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized, <<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: Freeze,

§

impl<C> RefUnwindSafe for EncodedPoint<C>

§

impl<C> Send for EncodedPoint<C>
where <<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: Sized, <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized,

§

impl<C> Sync for EncodedPoint<C>
where <<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: Sized, <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized,

§

impl<C> Unpin for EncodedPoint<C>
where <<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: Sized, <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized, <<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: Unpin,

§

impl<C> UnwindSafe for EncodedPoint<C>

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