pub struct EncodedPoint<C>where
C: Curve,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Add<UInt<UTerm, B1>> + ArrayLength<u8>,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: ArrayLength<u8>,{ /* 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>
impl<C> EncodedPoint<C>
Sourcepub fn from_bytes(input: impl AsRef<[u8]>) -> Result<EncodedPoint<C>, Error>
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).
Sourcepub fn from_untagged_bytes(
bytes: &GenericArray<u8, <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output>,
) -> EncodedPoint<C>
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).
Sourcepub 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>
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)
Sourcepub fn from_secret_key(
secret_key: &SecretKey<C>,
compress: bool,
) -> EncodedPoint<C>where
C: Curve + ProjectiveArithmetic,
<C as AffineArithmetic>::AffinePoint: ToEncodedPoint<C>,
<C as ScalarArithmetic>::Scalar: Zeroize,
pub fn from_secret_key(
secret_key: &SecretKey<C>,
compress: bool,
) -> EncodedPoint<C>where
C: Curve + ProjectiveArithmetic,
<C as AffineArithmetic>::AffinePoint: ToEncodedPoint<C>,
<C as ScalarArithmetic>::Scalar: Zeroize,
Compute EncodedPoint representing the public key for the provided
SecretKey.
The compress flag requests point compression.
Sourcepub fn identity() -> EncodedPoint<C>
pub fn identity() -> EncodedPoint<C>
Return EncodedPoint representing the additive identity
(a.k.a. point at infinity)
Sourcepub fn as_bytes(&self) -> &[u8]
pub fn as_bytes(&self) -> &[u8]
Get byte slice containing the serialized EncodedPoint.
Sourcepub fn to_untagged_bytes(
&self,
) -> Option<GenericArray<u8, <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output>>where
C: Curve + ProjectiveArithmetic,
<C as AffineArithmetic>::AffinePoint: DecompressPoint<C> + ToEncodedPoint<C>,
pub fn to_untagged_bytes(
&self,
) -> Option<GenericArray<u8, <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output>>where
C: Curve + ProjectiveArithmetic,
<C as AffineArithmetic>::AffinePoint: DecompressPoint<C> + ToEncodedPoint<C>,
Serialize point as raw uncompressed coordinates without tag byte, i.e.
encoded as the concatenated x || y coordinates.
Sourcepub fn is_compact(&self) -> bool
pub fn is_compact(&self) -> bool
Is this EncodedPoint compact?
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
Is this EncodedPoint compressed?
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Is this EncodedPoint the additive identity? (a.k.a. point at infinity)
Sourcepub fn compress(&self) -> EncodedPoint<C>
pub fn compress(&self) -> EncodedPoint<C>
Compress this EncodedPoint, returning a new EncodedPoint.
Sourcepub fn decompress(&self) -> Option<EncodedPoint<C>>where
C: Curve + ProjectiveArithmetic,
<C as AffineArithmetic>::AffinePoint: DecompressPoint<C> + ToEncodedPoint<C>,
pub fn decompress(&self) -> Option<EncodedPoint<C>>where
C: Curve + ProjectiveArithmetic,
<C as AffineArithmetic>::AffinePoint: DecompressPoint<C> + ToEncodedPoint<C>,
Decompress this EncodedPoint, returning a new EncodedPoint.
Sourcepub fn encode<T>(encodable: T, compress: bool) -> EncodedPoint<C>where
T: ToEncodedPoint<C>,
pub fn encode<T>(encodable: T, compress: bool) -> EncodedPoint<C>where
T: ToEncodedPoint<C>,
Encode an EncodedPoint from the desired type
Sourcepub fn decode<T>(&self) -> Result<T, Error>where
T: FromEncodedPoint<C>,
pub fn decode<T>(&self) -> Result<T, Error>where
T: FromEncodedPoint<C>,
Decode this EncodedPoint into the desired type
Sourcepub fn tag(&self) -> Tag
pub fn tag(&self) -> Tag
Get the SEC1 tag for this EncodedPoint
Sourcepub fn coordinates(&self) -> Coordinates<'_, C>
pub fn coordinates(&self) -> Coordinates<'_, C>
Get the Coordinates for this EncodedPoint.
Sourcepub fn x(
&self,
) -> Option<&GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>>
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.
Sourcepub fn y(
&self,
) -> Option<&GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>>
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>
impl<C> AsRef<[u8]> for EncodedPoint<C>
Source§impl<C> Clone for EncodedPoint<C>
impl<C> Clone for EncodedPoint<C>
Source§fn clone(&self) -> EncodedPoint<C>
fn clone(&self) -> EncodedPoint<C>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<C> ConditionallySelectable for EncodedPoint<C>where
C: Curve,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Add<UInt<UTerm, B1>> + ArrayLength<u8>,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: ArrayLength<u8>,
<<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: Copy,
impl<C> ConditionallySelectable for EncodedPoint<C>where
C: Curve,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Add<UInt<UTerm, B1>> + ArrayLength<u8>,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: ArrayLength<u8>,
<<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: Copy,
Source§fn conditional_select(
a: &EncodedPoint<C>,
b: &EncodedPoint<C>,
choice: Choice,
) -> EncodedPoint<C>
fn conditional_select( a: &EncodedPoint<C>, b: &EncodedPoint<C>, choice: Choice, ) -> EncodedPoint<C>
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
self and other if choice == 1; otherwise,
reassign both unto themselves. Read moreimpl<C> Copy for EncodedPoint<C>where
C: Curve,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Add<UInt<UTerm, B1>> + ArrayLength<u8>,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: ArrayLength<u8>,
<<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: Copy,
Source§impl<C> Debug for EncodedPoint<C>
impl<C> Debug for EncodedPoint<C>
Source§impl<C> Default for EncodedPoint<C>
impl<C> Default for EncodedPoint<C>
Source§fn default() -> EncodedPoint<C>
fn default() -> EncodedPoint<C>
impl<C> Eq for EncodedPoint<C>
Source§impl<C> From<&PublicKey<C>> for EncodedPoint<C>where
C: Curve + ProjectiveArithmetic + PointCompression,
<C as AffineArithmetic>::AffinePoint: FromEncodedPoint<C> + ToEncodedPoint<C>,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Add<UInt<UTerm, B1>> + ArrayLength<u8>,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: ArrayLength<u8>,
impl<C> From<&PublicKey<C>> for EncodedPoint<C>where
C: Curve + ProjectiveArithmetic + PointCompression,
<C as AffineArithmetic>::AffinePoint: FromEncodedPoint<C> + ToEncodedPoint<C>,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Add<UInt<UTerm, B1>> + ArrayLength<u8>,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: ArrayLength<u8>,
Source§fn from(public_key: &PublicKey<C>) -> EncodedPoint<C>
fn from(public_key: &PublicKey<C>) -> EncodedPoint<C>
Source§impl<C> From<&VerifyingKey<C>> for EncodedPoint<C>where
C: Curve + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> From<&VerifyingKey<C>> for EncodedPoint<C>where
C: Curve + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
Source§fn from(verifying_key: &VerifyingKey<C>) -> EncodedPoint<C>
fn from(verifying_key: &VerifyingKey<C>) -> EncodedPoint<C>
Source§impl<C> From<PublicKey<C>> for EncodedPoint<C>where
C: Curve + ProjectiveArithmetic + PointCompression,
<C as AffineArithmetic>::AffinePoint: FromEncodedPoint<C> + ToEncodedPoint<C>,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Add<UInt<UTerm, B1>> + ArrayLength<u8>,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: ArrayLength<u8>,
impl<C> From<PublicKey<C>> for EncodedPoint<C>where
C: Curve + ProjectiveArithmetic + PointCompression,
<C as AffineArithmetic>::AffinePoint: FromEncodedPoint<C> + ToEncodedPoint<C>,
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Add<UInt<UTerm, B1>> + ArrayLength<u8>,
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UTerm, B1>>>::Output: ArrayLength<u8>,
Source§fn from(public_key: PublicKey<C>) -> EncodedPoint<C>
fn from(public_key: PublicKey<C>) -> EncodedPoint<C>
Source§impl<C> Ord for EncodedPoint<C>
impl<C> Ord for EncodedPoint<C>
Source§fn cmp(&self, other: &EncodedPoint<C>) -> Ordering
fn cmp(&self, other: &EncodedPoint<C>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<C> PartialEq for EncodedPoint<C>
impl<C> PartialEq for EncodedPoint<C>
Source§impl<C> PartialOrd for EncodedPoint<C>
impl<C> PartialOrd for EncodedPoint<C>
impl<C> StructuralPartialEq for EncodedPoint<C>
Source§impl<C> Zeroize for EncodedPoint<C>
Available on crate feature zeroize only.
impl<C> Zeroize for EncodedPoint<C>
zeroize only.