Skip to main content

AuthenticationKey

Struct AuthenticationKey 

Source
pub struct AuthenticationKey(/* private fields */);
Expand description

A struct that represents an account authentication key. An account’s address is the last 16 bytes of authentication key used to create it

Implementations§

Source§

impl AuthenticationKey

Source

pub const LENGTH: usize = 32

The number of bytes in an authentication key.

Source

pub const fn new(bytes: [u8; 32]) -> Self

Create an authentication key from bytes

Source

pub const fn zero() -> Self

Return an authentication key that is impossible (in expectation) to sign for–useful for intentionally relinquishing control of an account.

Source

pub fn from_preimage(preimage: &AuthenticationKeyPreimage) -> AuthenticationKey

Create an authentication key from a preimage by taking its sha3 hash

Source

pub fn ed25519(public_key: &Ed25519PublicKey) -> AuthenticationKey

Create an authentication key from an Ed25519 public key

Source

pub fn multi_ed25519(public_key: &MultiEd25519PublicKey) -> Self

Create an authentication key from a MultiEd25519 public key

Source

pub fn derived_address(&self) -> AccountAddress

Return an address derived from the last AccountAddress::LENGTH bytes of this authentication key.

Source

pub fn prefix(&self) -> [u8; 16]

Return the first AccountAddress::LENGTH bytes of this authentication key

Source

pub fn to_vec(&self) -> Vec<u8>

Construct a vector from this authentication key

Source

pub fn random() -> Self

Create a random authentication key. For testing only

Trait Implementations§

Source§

impl AsRef<[u8]> for AuthenticationKey

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for AuthenticationKey

Source§

fn clone(&self) -> AuthenticationKey

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for AuthenticationKey

Source§

impl Debug for AuthenticationKey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AuthenticationKey

Source§

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 AuthenticationKey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for AuthenticationKey

Source§

impl FromStr for AuthenticationKey

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for AuthenticationKey

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl LowerHex for AuthenticationKey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Ord for AuthenticationKey

Source§

fn cmp(&self, other: &AuthenticationKey) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for AuthenticationKey

Source§

fn eq(&self, other: &AuthenticationKey) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for AuthenticationKey

Source§

fn partial_cmp(&self, other: &AuthenticationKey) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for AuthenticationKey

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AuthenticationKey

Source§

impl TryFrom<&[u8]> for AuthenticationKey

Source§

type Error = CryptoMaterialError

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &[u8]) -> Result<AuthenticationKey, CryptoMaterialError>

Performs the conversion.
Source§

impl TryFrom<Vec<u8>> for AuthenticationKey

Source§

type Error = CryptoMaterialError

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: Vec<u8>) -> Result<AuthenticationKey, CryptoMaterialError>

Performs the conversion.
Source§

impl ValidCryptoMaterial for AuthenticationKey

Source§

fn to_bytes(&self) -> Vec<u8>

Convert the valid crypto material to bytes.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> TestOnlyHash for T
where T: Serialize + ?Sized,

Source§

fn test_only_hash(&self) -> HashValue

Generates a hash used only for tests.
Source§

impl<T> ToHex for T
where T: AsRef<[u8]>,

Source§

fn encode_hex<U>(&self) -> U
where 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) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ValidCryptoMaterialStringExt for T

Source§

fn from_encoded_string(encoded_str: &str) -> Result<Self, CryptoMaterialError>

When trying to convert from bytes, we simply decode the string into bytes before checking if we can convert.
Source§

fn to_encoded_string(&self) -> Result<String, Error>

A function to encode into hex-string after serializing.