pub struct Ed25519PublicKey(/* private fields */);Expand description
An ed25519 public key.
§BCS
The BCS serialized form for this type is defined by the following ABNF:
ed25519-public-key = 32OCTECTImplementations§
Source§impl Ed25519PublicKey
impl Ed25519PublicKey
pub const fn new(bytes: [u8; 32]) -> Self
pub fn generate<R>(rng: R) -> Self
Available on crate feature
rand only.Sourcepub const fn into_inner(self) -> [u8; 32]
pub const fn into_inner(self) -> [u8; 32]
Return the underlying byte array of an Ed25519PublicKey.
pub const fn inner(&self) -> &[u8; 32]
pub const fn as_bytes(&self) -> &[u8] ⓘ
pub fn from_bytes<T: AsRef<[u8]>>(bytes: T) -> Result<Self, TryFromSliceError>
Source§impl Ed25519PublicKey
impl Ed25519PublicKey
Sourcepub fn scheme(&self) -> SignatureScheme
pub fn scheme(&self) -> SignatureScheme
Return the flag for this signature scheme
Source§impl Ed25519PublicKey
impl Ed25519PublicKey
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 an Ed25519PublicKey by hashing the bytes of the public
key prefixed with the Ed25519 SignatureScheme flag (0x00).
hash( 0x00 || 32-byte ed25519 public key)
use sui_sdk_types::Address;
use sui_sdk_types::Ed25519PublicKey;
use sui_sdk_types::hash::Hasher;
let public_key_bytes = [0; 32];
let mut hasher = Hasher::new();
hasher.update([0x00]); // The SignatureScheme flag for Ed25519 is `0`
hasher.update(public_key_bytes);
let address = Address::new(hasher.finalize().into_inner());
println!("Address: {}", address);
let public_key = Ed25519PublicKey::new(public_key_bytes);
assert_eq!(address, public_key.derive_address());Trait Implementations§
Source§impl Arbitrary for Ed25519PublicKey
impl Arbitrary for Ed25519PublicKey
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<Ed25519PublicKey>
type Strategy = BoxedStrategy<Ed25519PublicKey>
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 Ed25519PublicKey
impl AsRef<[u8]> for Ed25519PublicKey
Source§impl Clone for Ed25519PublicKey
impl Clone for Ed25519PublicKey
Source§fn clone(&self) -> Ed25519PublicKey
fn clone(&self) -> Ed25519PublicKey
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 Ed25519PublicKey
impl Debug for Ed25519PublicKey
Source§impl<'de> Deserialize<'de> for Ed25519PublicKey
impl<'de> Deserialize<'de> for Ed25519PublicKey
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 Ed25519PublicKey
impl Display for Ed25519PublicKey
Source§impl From<Ed25519PublicKey> for [u8; 32]
impl From<Ed25519PublicKey> for [u8; 32]
Source§fn from(public_key: Ed25519PublicKey) -> Self
fn from(public_key: Ed25519PublicKey) -> Self
Converts to this type from the input type.
Source§impl FromStr for Ed25519PublicKey
impl FromStr for Ed25519PublicKey
Source§impl Hash for Ed25519PublicKey
impl Hash for Ed25519PublicKey
Source§impl Ord for Ed25519PublicKey
impl Ord for Ed25519PublicKey
Source§fn cmp(&self, other: &Ed25519PublicKey) -> Ordering
fn cmp(&self, other: &Ed25519PublicKey) -> 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 Ed25519PublicKey
impl PartialEq for Ed25519PublicKey
Source§impl PartialOrd for Ed25519PublicKey
impl PartialOrd for Ed25519PublicKey
Source§impl Serialize for Ed25519PublicKey
impl Serialize for Ed25519PublicKey
impl Copy for Ed25519PublicKey
impl Eq for Ed25519PublicKey
impl StructuralPartialEq for Ed25519PublicKey
Auto Trait Implementations§
impl Freeze for Ed25519PublicKey
impl RefUnwindSafe for Ed25519PublicKey
impl Send for Ed25519PublicKey
impl Sync for Ed25519PublicKey
impl Unpin for Ed25519PublicKey
impl UnwindSafe for Ed25519PublicKey
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
Casts
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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 more