pub struct Secp256r1PublicKey(/* private fields */);Expand description
A secp256r1 public key.
§BCS
The BCS serialized form for this type is defined by the following ABNF:
secp256r1-public-key = 33OCTECTImplementations§
Source§impl Secp256r1PublicKey
impl Secp256r1PublicKey
Sourcepub fn derive_address(&self) -> Address
Available on crate feature hash only.
pub fn derive_address(&self) -> Address
hash only.Derive an Address from this Public Key
An Address can be derived from a Secp256r1PublicKey by hashing the
bytes of the public key prefixed with the Secp256r1
SignatureScheme flag (0x02).
hash( 0x02 || 33-byte secp256r1 public key)
use iota_sdk_types::{Address, Secp256r1PublicKey, hash::Hasher};
let public_key_bytes = [0; 33];
let mut hasher = Hasher::new();
hasher.update([0x02]); // The SignatureScheme flag for Secp256r1 is `2`
hasher.update(public_key_bytes);
let address = Address::new(hasher.finalize().into_inner());
println!("Address: {}", address);
let public_key = Secp256r1PublicKey::new(public_key_bytes);
assert_eq!(address, public_key.derive_address());Source§impl Secp256r1PublicKey
impl Secp256r1PublicKey
Trait Implementations§
Source§impl Arbitrary for Secp256r1PublicKey
impl Arbitrary for Secp256r1PublicKey
Source§type Parameters = ()
type Parameters = ()
The type of parameters that
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = BoxedStrategy<Secp256r1PublicKey>
type Strategy = BoxedStrategy<Secp256r1PublicKey>
The type of
Strategy used to generate values of type Self.Source§fn arbitrary_with(args: <Self as Arbitrary>::Parameters) -> Self::Strategy
fn arbitrary_with(args: <Self as Arbitrary>::Parameters) -> Self::Strategy
Source§impl AsRef<[u8]> for Secp256r1PublicKey
impl AsRef<[u8]> for Secp256r1PublicKey
Source§impl Clone for Secp256r1PublicKey
impl Clone for Secp256r1PublicKey
Source§fn clone(&self) -> Secp256r1PublicKey
fn clone(&self) -> Secp256r1PublicKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for Secp256r1PublicKey
impl Display for Secp256r1PublicKey
Source§impl From<Secp256r1PublicKey> for [u8; 33]
impl From<Secp256r1PublicKey> for [u8; 33]
Source§fn from(public_key: Secp256r1PublicKey) -> Self
fn from(public_key: Secp256r1PublicKey) -> Self
Converts to this type from the input type.
Source§impl FromStr for Secp256r1PublicKey
impl FromStr for Secp256r1PublicKey
Source§impl Hash for Secp256r1PublicKey
impl Hash for Secp256r1PublicKey
Source§impl JsonSchema for Secp256r1PublicKey
impl JsonSchema for Secp256r1PublicKey
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreSource§impl Ord for Secp256r1PublicKey
impl Ord for Secp256r1PublicKey
Source§fn cmp(&self, other: &Secp256r1PublicKey) -> Ordering
fn cmp(&self, other: &Secp256r1PublicKey) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for Secp256r1PublicKey
impl PartialEq for Secp256r1PublicKey
Source§impl PartialOrd for Secp256r1PublicKey
impl PartialOrd for Secp256r1PublicKey
Source§impl PublicKeyExt for Secp256r1PublicKey
impl PublicKeyExt for Secp256r1PublicKey
Source§fn from_bytes<T: AsRef<[u8]>>(bytes: T) -> Result<Self, Self::FromBytesErr>
fn from_bytes<T: AsRef<[u8]>>(bytes: T) -> Result<Self, Self::FromBytesErr>
Tries to create a Secp256r1PublicKey from bytes.
Source§fn scheme(&self) -> SignatureScheme
fn scheme(&self) -> SignatureScheme
Returns the signature scheme for this public key.
type FromBytesErr = TryFromSliceError
Source§impl Serialize for Secp256r1PublicKey
impl Serialize for Secp256r1PublicKey
impl Copy for Secp256r1PublicKey
impl Eq for Secp256r1PublicKey
impl StructuralPartialEq 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 moreSource§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)