Struct sec1::point::EncodedPoint

source ·
pub struct EncodedPoint<Size>where
    Size: ModulusSize,{ /* private fields */ }
Available on crate feature point only.
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<Size> EncodedPoint<Size>where Size: ModulusSize,

source

pub fn from_bytes(input: impl AsRef<[u8]>) -> Result<Self>

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, Size::UntaggedPointSize> ) -> Self

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, Size>, y: &GenericArray<u8, Size>, compress: bool ) -> Self

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

source

pub fn identity() -> Self

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

Available on crate feature alloc only.

Get boxed byte slice containing the serialized EncodedPoint

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) -> Self

Compress this EncodedPoint, returning a new EncodedPoint.

source

pub fn tag(&self) -> Tag

Get the SEC1 tag for this EncodedPoint

source

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

Get the Coordinates for this EncodedPoint.

source

pub fn x(&self) -> Option<&GenericArray<u8, Size>>

Get the x-coordinate for this EncodedPoint.

Returns None if this point is the identity point.

source

pub fn y(&self) -> Option<&GenericArray<u8, Size>>

Get the y-coordinate for this EncodedPoint.

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

Trait Implementations§

source§

impl<Size> AsRef<[u8]> for EncodedPoint<Size>where Size: ModulusSize,

source§

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

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

impl<Size> Clone for EncodedPoint<Size>where Size: ModulusSize + Clone, Size::UncompressedPointSize: Clone,

source§

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

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<Size> ConditionallySelectable for EncodedPoint<Size>where Size: ModulusSize, <Size::UncompressedPointSize as ArrayLength<u8>>::ArrayType: Copy,

Available on crate feature subtle only.
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<Size> Debug for EncodedPoint<Size>where Size: ModulusSize,

source§

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

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

impl<Size> Default for EncodedPoint<Size>where Size: ModulusSize + Default, Size::UncompressedPointSize: Default,

source§

fn default() -> EncodedPoint<Size>

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

impl<'de, Size> Deserialize<'de> for EncodedPoint<Size>where Size: ModulusSize,

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<Size> Display for EncodedPoint<Size>where Size: ModulusSize,

source§

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

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

impl<Size> FromStr for EncodedPoint<Size>where Size: ModulusSize,

Decode a SEC1-encoded point from hexadecimal.

Upper and lower case hexadecimal are both accepted, however mixed case is rejected.

§

type Err = Error

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

fn from_str(hex: &str) -> Result<Self>

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

impl<Size> Hash for EncodedPoint<Size>where Size: ModulusSize,

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<Size> LowerHex for EncodedPoint<Size>where Size: ModulusSize,

source§

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

Formats the value using the given formatter.
source§

impl<Size> Ord for EncodedPoint<Size>where Size: ModulusSize,

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) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

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

impl<Size> PartialEq<EncodedPoint<Size>> for EncodedPoint<Size>where Size: ModulusSize,

source§

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

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<Size> Serialize for EncodedPoint<Size>where Size: ModulusSize,

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<Size> TryFrom<&[u8]> for EncodedPoint<Size>where Size: ModulusSize,

§

type Error = Error

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

fn try_from(bytes: &[u8]) -> Result<Self>

Performs the conversion.
source§

impl<Size> UpperHex for EncodedPoint<Size>where Size: ModulusSize,

source§

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

Formats the value using the given formatter.
source§

impl<Size> Zeroize for EncodedPoint<Size>where Size: ModulusSize,

Available on crate feature zeroize only.
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<Size> Copy for EncodedPoint<Size>where Size: ModulusSize, <Size::UncompressedPointSize as ArrayLength<u8>>::ArrayType: Copy,

source§

impl<Size: ModulusSize> Eq for EncodedPoint<Size>

Auto Trait Implementations§

§

impl<Size> RefUnwindSafe for EncodedPoint<Size>where <<Size as ModulusSize>::UncompressedPointSize as ArrayLength<u8>>::ArrayType: RefUnwindSafe,

§

impl<Size> Send for EncodedPoint<Size>

§

impl<Size> Sync for EncodedPoint<Size>

§

impl<Size> Unpin for EncodedPoint<Size>where <<Size as ModulusSize>::UncompressedPointSize as ArrayLength<u8>>::ArrayType: Unpin,

§

impl<Size> UnwindSafe for EncodedPoint<Size>where <<Size as ModulusSize>::UncompressedPointSize as ArrayLength<u8>>::ArrayType: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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 Twhere T: for<'de> Deserialize<'de>,