[][src]Struct elliptic_curve::sec1::EncodedPoint

pub struct EncodedPoint<C> where
    C: Curve,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
{ /* fields omitted */ }

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>, 
[src]

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

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

pub fn from_untagged_bytes(
    bytes: &GenericArray<u8, UntaggedPointSize<C>>
) -> Self
[src]

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

pub fn from_affine_coordinates(
    x: &FieldBytes<C>,
    y: &FieldBytes<C>,
    compress: bool
) -> Self
[src]

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,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    AffinePoint<C>: ToEncodedPoint<C>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>> + Zeroize
[src]

This is supported on crate features arithmetic and zeroize only.

Compute EncodedPoint representing the public key for the provided SecretKey.

The compress flag requests point compression.

pub fn identity() -> Self[src]

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

pub fn len(&self) -> usize[src]

Get the length of the encoded point in bytes

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

Get byte slice containing the serialized EncodedPoint.

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

This is supported on crate feature 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,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>,
    AffinePoint<C>: ConditionallySelectable + Default + Decompress<C> + ToEncodedPoint<C>, 
[src]

This is supported on crate feature arithmetic only.

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

pub fn is_identity(&self) -> bool[src]

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

pub fn is_compressed(&self) -> bool[src]

Is this EncodedPoint compressed?

pub fn compress(&self) -> Self[src]

Compress this EncodedPoint, returning a new EncodedPoint.

pub fn decompress(&self) -> Option<Self> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>,
    AffinePoint<C>: ConditionallySelectable + Default + Decompress<C> + ToEncodedPoint<C>, 
[src]

This is supported on crate feature arithmetic only.

Decompress this EncodedPoint, returning a new EncodedPoint.

pub fn encode<T>(encodable: T, compress: bool) -> Self where
    T: ToEncodedPoint<C>, 
[src]

Encode an EncodedPoint from the desired type

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

Decode this EncodedPoint into the desired type

pub fn tag(&self) -> Tag[src]

Get the SEC1 tag for this EncodedPoint

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

Get the Coordinates for this EncodedPoint.

pub fn x(&self) -> Option<&FieldBytes<C>>[src]

Get the x-coordinate for this EncodedPoint.

Returns None if this point is the identity point.

pub fn y(&self) -> Option<&FieldBytes<C>>[src]

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>, 
[src]

impl<C: Clone> Clone for EncodedPoint<C> where
    C: Curve,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

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

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

impl<C> Debug for EncodedPoint<C> where
    C: Curve,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

impl<C: Eq> Eq for EncodedPoint<C> where
    C: Curve,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

impl<C, '_> From<&'_ PublicKey<C>> for EncodedPoint<C> where
    C: Curve + ProjectiveArithmetic + Compression,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>,
    AffinePoint<C>: Copy + Clone + Debug + Default + FromEncodedPoint<C> + ToEncodedPoint<C>,
    ProjectivePoint<C>: From<AffinePoint<C>>,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

This is supported on crate feature arithmetic only.

impl<C> From<PublicKey<C>> for EncodedPoint<C> where
    C: Curve + ProjectiveArithmetic + Compression,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>,
    AffinePoint<C>: Copy + Clone + Debug + Default + FromEncodedPoint<C> + ToEncodedPoint<C>,
    ProjectivePoint<C>: From<AffinePoint<C>>,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

This is supported on crate feature arithmetic only.

impl<C: Ord> Ord for EncodedPoint<C> where
    C: Curve,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

impl<C: PartialEq> PartialEq<EncodedPoint<C>> for EncodedPoint<C> where
    C: Curve,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

impl<C: PartialOrd> PartialOrd<EncodedPoint<C>> for EncodedPoint<C> where
    C: Curve,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

impl<C> StructuralEq for EncodedPoint<C> where
    C: Curve,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

impl<C> StructuralPartialEq for EncodedPoint<C> where
    C: Curve,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

impl<C, '_> TryFrom<&'_ EncodedPoint<C>> for PublicKey<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>,
    AffinePoint<C>: Copy + Clone + Debug + Default + FromEncodedPoint<C> + ToEncodedPoint<C>,
    ProjectivePoint<C>: From<AffinePoint<C>>,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

This is supported on crate feature arithmetic only.

type Error = Error

The type returned in the event of a conversion error.

impl<C> TryFrom<EncodedPoint<C>> for PublicKey<C> where
    C: Curve + ProjectiveArithmetic,
    FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
    Scalar<C>: PrimeField<Repr = FieldBytes<C>>,
    AffinePoint<C>: Copy + Clone + Debug + Default + FromEncodedPoint<C> + ToEncodedPoint<C>,
    ProjectivePoint<C>: From<AffinePoint<C>>,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

This is supported on crate feature arithmetic only.

type Error = Error

The type returned in the event of a conversion error.

impl<C> Zeroize for EncodedPoint<C> where
    C: Curve,
    UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
    UncompressedPointSize<C>: ArrayLength<u8>, 
[src]

Auto Trait Implementations

impl<C> RefUnwindSafe for EncodedPoint<C> where
    <<<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: RefUnwindSafe
[src]

impl<C> Send for EncodedPoint<C>[src]

impl<C> Sync for EncodedPoint<C>[src]

impl<C> Unpin for EncodedPoint<C> where
    <<<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: Unpin
[src]

impl<C> UnwindSafe for EncodedPoint<C> where
    <<<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as Add<UInt<UTerm, B1>>>::Output as ArrayLength<u8>>::ArrayType: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<A, T> AsBits<T> for A where
    A: AsRef<[T]>,
    T: BitStore + BitMemory
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.