Struct sec1::point::EncodedPoint
source · [−]pub struct EncodedPoint<Size> where
Size: ModulusSize, { /* 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
sourceimpl<Size> EncodedPoint<Size> where
Size: ModulusSize,
impl<Size> EncodedPoint<Size> where
Size: ModulusSize,
sourcepub fn from_bytes(input: impl AsRef<[u8]>) -> Result<Self>
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).
sourcepub fn from_untagged_bytes(
bytes: &GenericArray<u8, Size::UntaggedPointSize>
) -> Self
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).
sourcepub fn from_affine_coordinates(
x: &GenericArray<u8, Size>,
y: &GenericArray<u8, Size>,
compress: bool
) -> Self
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)
sourcepub fn identity() -> Self
pub fn identity() -> Self
Return EncodedPoint
representing the additive identity
(a.k.a. point at infinity)
sourcepub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
Get byte slice containing the serialized EncodedPoint
.
sourcepub fn to_bytes(&self) -> Box<[u8]>
Available on crate feature alloc
only.
pub fn to_bytes(&self) -> Box<[u8]>
alloc
only.Get boxed byte slice containing the serialized EncodedPoint
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) -> Self
pub fn compress(&self) -> Self
Compress this EncodedPoint
, returning a new EncodedPoint
.
sourcepub fn tag(&self) -> Tag
pub fn tag(&self) -> Tag
Get the SEC1 tag for this EncodedPoint
sourcepub fn coordinates(&self) -> Coordinates<'_, Size>
pub fn coordinates(&self) -> Coordinates<'_, Size>
Get the Coordinates
for this EncodedPoint
.
sourcepub fn x(&self) -> Option<&GenericArray<u8, Size>>
pub fn x(&self) -> Option<&GenericArray<u8, Size>>
Get the x-coordinate for this EncodedPoint
.
Returns None
if this point is the identity point.
sourcepub fn y(&self) -> Option<&GenericArray<u8, Size>>
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
sourceimpl<Size> AsRef<[u8]> for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size> AsRef<[u8]> for EncodedPoint<Size> where
Size: ModulusSize,
sourceimpl<Size: Clone> Clone for EncodedPoint<Size> where
Size: ModulusSize,
Size::UncompressedPointSize: Clone,
impl<Size: Clone> Clone for EncodedPoint<Size> where
Size: ModulusSize,
Size::UncompressedPointSize: Clone,
sourcefn clone(&self) -> EncodedPoint<Size>
fn clone(&self) -> EncodedPoint<Size>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<Size> ConditionallySelectable for EncodedPoint<Size> where
Size: ModulusSize,
<Size::UncompressedPointSize as ArrayLength<u8>>::ArrayType: Copy,
impl<Size> ConditionallySelectable for EncodedPoint<Size> where
Size: ModulusSize,
<Size::UncompressedPointSize as ArrayLength<u8>>::ArrayType: Copy,
sourceimpl<Size> Debug for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size> Debug for EncodedPoint<Size> where
Size: ModulusSize,
sourceimpl<Size: Default> Default for EncodedPoint<Size> where
Size: ModulusSize,
Size::UncompressedPointSize: Default,
impl<Size: Default> Default for EncodedPoint<Size> where
Size: ModulusSize,
Size::UncompressedPointSize: Default,
sourcefn default() -> EncodedPoint<Size>
fn default() -> EncodedPoint<Size>
Returns the “default value” for a type. Read more
sourceimpl<'de, Size> Deserialize<'de> for EncodedPoint<Size> where
Size: ModulusSize,
Available on crate feature serde
only.
impl<'de, Size> Deserialize<'de> for EncodedPoint<Size> where
Size: ModulusSize,
serde
only.sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<Size> Display for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size> Display for EncodedPoint<Size> where
Size: ModulusSize,
sourceimpl<Size> FromStr for EncodedPoint<Size> where
Size: ModulusSize,
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.
sourceimpl<Size> LowerHex for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size> LowerHex for EncodedPoint<Size> where
Size: ModulusSize,
sourceimpl<Size: ModulusSize> Ord for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size: ModulusSize> Ord for EncodedPoint<Size> where
Size: ModulusSize,
sourceimpl<Size> PartialEq<EncodedPoint<Size>> for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size> PartialEq<EncodedPoint<Size>> for EncodedPoint<Size> where
Size: ModulusSize,
sourceimpl<Size: ModulusSize> PartialOrd<EncodedPoint<Size>> for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size: ModulusSize> PartialOrd<EncodedPoint<Size>> for EncodedPoint<Size> where
Size: ModulusSize,
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl<Size> Serialize for EncodedPoint<Size> where
Size: ModulusSize,
Available on crate feature serde
only.
impl<Size> Serialize for EncodedPoint<Size> where
Size: ModulusSize,
serde
only.sourceimpl<Size: ModulusSize> TryFrom<&'_ [u8]> for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size: ModulusSize> TryFrom<&'_ [u8]> for EncodedPoint<Size> where
Size: ModulusSize,
sourceimpl<Size> UpperHex for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size> UpperHex for EncodedPoint<Size> where
Size: ModulusSize,
sourceimpl<Size> Zeroize for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size> Zeroize for EncodedPoint<Size> where
Size: ModulusSize,
impl<Size> Copy for EncodedPoint<Size> where
Size: ModulusSize,
<Size::UncompressedPointSize as ArrayLength<u8>>::ArrayType: Copy,
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more