Struct elliptic_curve::sec1::EncodedPoint [−][src]
pub struct EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>, { /* fields omitted */ }
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
impl<C> EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
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).
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).
Encode an elliptic curve point from big endian serialized coordinates (with optional point compression)
pub fn from_secret_key(secret_key: &SecretKey<C>, compress: bool) -> Self where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: ToEncodedPoint<C>,
Scalar<C>: Zeroize,
This is supported on crate features arithmetic
and zeroize
only.
pub fn from_secret_key(secret_key: &SecretKey<C>, compress: bool) -> Self where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: ToEncodedPoint<C>,
Scalar<C>: Zeroize,
arithmetic
and zeroize
only.Compute EncodedPoint
representing the public key for the provided
SecretKey
.
The compress
flag requests point compression.
Return EncodedPoint
representing the additive identity
(a.k.a. point at infinity)
This is supported on crate feature alloc
only.
alloc
only.Get boxed byte slice containing the serialized EncodedPoint
pub fn to_untagged_bytes(
&self
) -> Option<GenericArray<u8, UntaggedPointSize<C>>> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: DecompressPoint<C> + ToEncodedPoint<C>,
This is supported on crate feature arithmetic
only.
pub fn to_untagged_bytes(
&self
) -> Option<GenericArray<u8, UntaggedPointSize<C>>> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: DecompressPoint<C> + ToEncodedPoint<C>,
arithmetic
only.Serialize point as raw uncompressed coordinates without tag byte, i.e.
encoded as the concatenated x || y
coordinates.
Is this EncodedPoint
compact?
Is this EncodedPoint
compressed?
Is this EncodedPoint
the additive identity? (a.k.a. point at infinity)
Compress this EncodedPoint
, returning a new EncodedPoint
.
pub fn decompress(&self) -> Option<Self> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: DecompressPoint<C> + ToEncodedPoint<C>,
This is supported on crate feature arithmetic
only.
pub fn decompress(&self) -> Option<Self> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: DecompressPoint<C> + ToEncodedPoint<C>,
arithmetic
only.Decompress this EncodedPoint
, returning a new EncodedPoint
.
Encode an EncodedPoint
from the desired type
Decode this EncodedPoint
into the desired type
Get the SEC1 tag for this EncodedPoint
Get the Coordinates
for this EncodedPoint
.
Get the x-coordinate for this EncodedPoint
.
Returns None
if this point is the identity point.
Get the y-coordinate for this EncodedPoint
.
Returns None
if this point is compressed or the identity point.
Trait Implementations
impl<C> AsRef<[u8]> for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> AsRef<[u8]> for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C: Clone> Clone for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C: Clone> Clone for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> ConditionallySelectable for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
<UncompressedPointSize<C> as ArrayLength<u8>>::ArrayType: Copy,
impl<C> ConditionallySelectable for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
<UncompressedPointSize<C> as ArrayLength<u8>>::ArrayType: Copy,
impl<C> Debug for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> Debug for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C: Default> Default for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C: Default> Default for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
Returns the “default value” for a type. Read more
impl<C> From<&'_ PublicKey<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<&'_ PublicKey<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>,
Performs the conversion.
impl<C> From<PublicKey<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<PublicKey<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>,
Performs the conversion.
impl<C: Ord> Ord for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C: Ord> Ord for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C: PartialEq> PartialEq<EncodedPoint<C>> for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C: PartialEq> PartialEq<EncodedPoint<C>> for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
impl<C: PartialOrd> PartialOrd<EncodedPoint<C>> for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C: PartialOrd> PartialOrd<EncodedPoint<C>> for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
impl<C> TryFrom<&'_ EncodedPoint<C>> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> TryFrom<&'_ EncodedPoint<C>> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> TryFrom<&'_ EncodedPoint<C>> for JwkEcKey where
C: Curve + JwkParameters,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
This is supported on crate feature jwk
only.
impl<C> TryFrom<&'_ EncodedPoint<C>> for JwkEcKey where
C: Curve + JwkParameters,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
jwk
only.impl<C> TryFrom<&'_ JwkEcKey> for EncodedPoint<C> where
C: Curve + JwkParameters,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
This is supported on crate feature jwk
only.
impl<C> TryFrom<&'_ JwkEcKey> for EncodedPoint<C> where
C: Curve + JwkParameters,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
jwk
only.impl<C> TryFrom<EncodedPoint<C>> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> TryFrom<EncodedPoint<C>> for PublicKey<C> where
C: Curve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> TryFrom<EncodedPoint<C>> for JwkEcKey where
C: Curve + JwkParameters,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
This is supported on crate feature jwk
only.
impl<C> TryFrom<EncodedPoint<C>> for JwkEcKey where
C: Curve + JwkParameters,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
jwk
only.impl<C> TryFrom<JwkEcKey> for EncodedPoint<C> where
C: Curve + JwkParameters,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
This is supported on crate feature jwk
only.
impl<C> TryFrom<JwkEcKey> for EncodedPoint<C> where
C: Curve + JwkParameters,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
jwk
only.impl<C> Zeroize for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> Zeroize for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> Copy for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
<UncompressedPointSize<C> as ArrayLength<u8>>::ArrayType: Copy,
impl<C: Eq> Eq for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> StructuralEq for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
impl<C> StructuralPartialEq for EncodedPoint<C> where
C: Curve,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
Auto Trait Implementations
impl<C> RefUnwindSafe for EncodedPoint<C> where
<<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
impl<C> Send for EncodedPoint<C>
impl<C> Sync for EncodedPoint<C>
impl<C> Unpin for EncodedPoint<C> where
<<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: Unpin,
impl<C> UnwindSafe for EncodedPoint<C> where
<<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self