pub struct Secp256r1PublicKey { /* private fields */ }Implementations§
Source§impl Secp256r1PublicKey
impl Secp256r1PublicKey
Sourcepub fn new(gx: [u8; 32], gy: [u8; 32]) -> Option<Self>
pub fn new(gx: [u8; 32], gy: [u8; 32]) -> Option<Self>
Constructs a new Secp256r1PublicKey from the given x and y coordinates.
This function attempts to create a public key from uncompressed x and y coordinates.
It returns None if the provided coordinates do not correspond to a valid point on the curve.
-
Parameters:
- gx: The x coordinate of the public key.
- gy: The y coordinate of the public key.
-
Returns: An
Option<Secp256r1PublicKey>.
Sourcepub fn from_public_key(public_key: PublicKey) -> Self
pub fn from_public_key(public_key: PublicKey) -> Self
Constructs a Secp256r1PublicKey from an existing PublicKey.
This method can be used to convert a PublicKey from the p256 crate into a Secp256r1PublicKey.
-
Parameter public_key: A
PublicKeyinstance. -
Returns: A
Secp256r1PublicKeyinstance.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, CryptoError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, CryptoError>
Constructs a Secp256r1PublicKey from a byte slice.
Attempts to parse a byte slice as an encoded elliptic curve point and create a public key.
Returns a CryptoError if the byte slice does not represent a valid public key.
-
Parameter bytes: A byte slice representing an encoded elliptic curve point.
-
Returns: A
Result<Secp256r1PublicKey, CryptoError>.
Sourcepub fn verify(
&self,
message: &[u8],
signature: &Secp256r1Signature,
) -> Result<(), CryptoError>
pub fn verify( &self, message: &[u8], signature: &Secp256r1Signature, ) -> Result<(), CryptoError>
Verifies a digital signature against a message using this public key.
This method checks if the provided signature is valid for the given message under this public key.
Returns a CryptoError if the signature verification fails.
-
Parameters:
- message: The message that was signed.
- signature: The signature to verify.
-
Returns: A
Result<(), CryptoError>.
Sourcepub fn get_encoded(&self, compressed: bool) -> Vec<u8> ⓘ
pub fn get_encoded(&self, compressed: bool) -> Vec<u8> ⓘ
Gets this public key’s elliptic curve point encoded as defined in section 2.3.3 of SEC1.
-
Parameter compressed: If the EC point should be encoded in compressed or uncompressed format
-
Returns: The encoded public key
pub fn get_encoded_point(&self, compressed: bool) -> EncodedPoint
Sourcepub fn get_encoded_compressed_hex(&self) -> String
pub fn get_encoded_compressed_hex(&self) -> String
Gets this public key’s elliptic curve point encoded as defined in section 2.3.3 of SEC1 in compressed format as hexadecimal.
- Returns: The encoded public key in compressed format as hexadecimal without a prefix
Sourcepub fn from_encoded(encoded: &str) -> Option<Self>
pub fn from_encoded(encoded: &str) -> Option<Self>
Constructs a Secp256r1PublicKey from a hexadecimal string representation.
This method attempts to parse a hexadecimal string as an encoded elliptic curve point.
Returns None if the string is not a valid encoding or does not represent a valid public key.
-
Parameter encoded: A hexadecimal string representing an encoded elliptic curve point.
-
Returns: An
Option<Secp256r1PublicKey>.
Trait Implementations§
Source§impl Clone for Secp256r1PublicKey
impl Clone for Secp256r1PublicKey
Source§fn clone(&self) -> Secp256r1PublicKey
fn clone(&self) -> Secp256r1PublicKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Secp256r1PublicKey
impl Debug for Secp256r1PublicKey
Source§impl<'de> Deserialize<'de> for Secp256r1PublicKey
impl<'de> Deserialize<'de> for Secp256r1PublicKey
Source§fn 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>,
Source§impl Display for Secp256r1PublicKey
impl Display for Secp256r1PublicKey
Source§impl From<&Secp256r1PublicKey> for ContractParameter
impl From<&Secp256r1PublicKey> for ContractParameter
Source§fn from(value: &Secp256r1PublicKey) -> Self
fn from(value: &Secp256r1PublicKey) -> Self
Source§impl Hash for Secp256r1PublicKey
impl Hash for Secp256r1PublicKey
Source§impl NeoSerializable for Secp256r1PublicKey
impl NeoSerializable for Secp256r1PublicKey
Source§impl Ord for Secp256r1PublicKey
impl Ord for Secp256r1PublicKey
Source§impl PartialEq for Secp256r1PublicKey
impl PartialEq for Secp256r1PublicKey
Source§impl PartialOrd for Secp256r1PublicKey
impl PartialOrd for Secp256r1PublicKey
Source§impl Serialize for Secp256r1PublicKey
impl Serialize for Secp256r1PublicKey
Source§impl ValueExtension for Secp256r1PublicKey
impl ValueExtension for Secp256r1PublicKey
impl Eq for Secp256r1PublicKey
Auto Trait Implementations§
impl Freeze for Secp256r1PublicKey
impl RefUnwindSafe for Secp256r1PublicKey
impl Send for Secp256r1PublicKey
impl Sync for Secp256r1PublicKey
impl Unpin for Secp256r1PublicKey
impl UnwindSafe for Secp256r1PublicKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.