pub struct Ed25519Pubkey(/* private fields */);Expand description
An Ed25519 public key.
This type is known to have the correct length, which serves as a minimal validation. This does not mean it is a valid curve point though.
Similar types struct Secp256k1Pubkey([u8; 33]) and struct Sr25519Pubkey([u8; 32])
should be created on demand.
§Examples
This is generated from Pubkey as follows:
use std::convert::TryFrom;
use tg_bindings::{Ed25519Pubkey, Pubkey};
let pubkey = Pubkey::Ed25519(hex!("14253d61ef42d166d02e68d540d07fdf8d65a9af0acaa46302688e788a8521e2").into());
let ed25519_pubkey = Ed25519Pubkey::try_from(pubkey);
assert!(ed25519_pubkey.is_ok());
let pubkey = Pubkey::Secp256k1(hex!("0292a066ec32d37c607519d7a86eb2107013a26b160ce3da732ee76e9b2e502492").into());
let ed25519_pubkey = Ed25519Pubkey::try_from(pubkey);
assert!(ed25519_pubkey.is_err());When we have an Ed25519Pubkey we can derive an address:
use std::convert::TryFrom;
use tg_bindings::{Ed25519Pubkey, Pubkey, ToAddress};
let pubkey = Pubkey::Ed25519(hex!("14253d61ef42d166d02e68d540d07fdf8d65a9af0acaa46302688e788a8521e2").into());
let ed25519_pubkey = Ed25519Pubkey::try_from(pubkey).unwrap();
let address = ed25519_pubkey.to_address();
assert_eq!(address, hex!("0CDA3F47EF3C4906693B170EF650EB968C5F4B2C"));Implementations§
Trait Implementations§
Source§impl Clone for Ed25519Pubkey
impl Clone for Ed25519Pubkey
Source§fn clone(&self) -> Ed25519Pubkey
fn clone(&self) -> Ed25519Pubkey
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 Ed25519Pubkey
impl Debug for Ed25519Pubkey
Source§impl<'de> Deserialize<'de> for Ed25519Pubkey
impl<'de> Deserialize<'de> for Ed25519Pubkey
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 From<Ed25519Pubkey> for Pubkey
impl From<Ed25519Pubkey> for Pubkey
Source§fn from(ed: Ed25519Pubkey) -> Self
fn from(ed: Ed25519Pubkey) -> Self
Converts to this type from the input type.
Source§impl JsonSchema for Ed25519Pubkey
impl JsonSchema for Ed25519Pubkey
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 PartialEq for Ed25519Pubkey
impl PartialEq for Ed25519Pubkey
Source§impl Serialize for Ed25519Pubkey
impl Serialize for Ed25519Pubkey
Source§impl ToAddress for Ed25519Pubkey
impl ToAddress for Ed25519Pubkey
fn to_address(&self) -> [u8; 20]
Source§impl<'a> TryFrom<&'a Pubkey> for Ed25519Pubkey
impl<'a> TryFrom<&'a Pubkey> for Ed25519Pubkey
Source§impl TryFrom<Pubkey> for Ed25519Pubkey
impl TryFrom<Pubkey> for Ed25519Pubkey
impl Eq for Ed25519Pubkey
impl StructuralPartialEq for Ed25519Pubkey
Auto Trait Implementations§
impl Freeze for Ed25519Pubkey
impl RefUnwindSafe for Ed25519Pubkey
impl Send for Ed25519Pubkey
impl Sync for Ed25519Pubkey
impl Unpin for Ed25519Pubkey
impl UnwindSafe for Ed25519Pubkey
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