Struct cardano_serialization_lib::crypto::Ed25519KeyHash
source · pub struct Ed25519KeyHash(_);
Implementations§
source§impl Ed25519KeyHash
impl Ed25519KeyHash
sourcepub fn from_bytes(bytes: Vec<u8>) -> Result<Ed25519KeyHash, DeserializeError>
pub fn from_bytes(bytes: Vec<u8>) -> Result<Ed25519KeyHash, DeserializeError>
Examples found in repository?
More examples
src/tx_builder.rs (line 37)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
fn witness_keys_for_cert(cert_enum: &Certificate) -> RequiredSigners {
let mut set = RequiredSigners::new();
match &cert_enum.0 {
// stake key registrations do not require a witness
CertificateEnum::StakeRegistration(_cert) => {}
CertificateEnum::StakeDeregistration(cert) => {
set.add(&cert.stake_credential().to_keyhash().unwrap());
}
CertificateEnum::StakeDelegation(cert) => {
set.add(&cert.stake_credential().to_keyhash().unwrap());
}
CertificateEnum::PoolRegistration(cert) => {
for owner in &cert.pool_params().pool_owners().0 {
set.add(&owner.clone());
}
set.add(&Ed25519KeyHash::from_bytes(cert.pool_params().operator().to_bytes()).unwrap());
}
CertificateEnum::PoolRetirement(cert) => {
set.add(&Ed25519KeyHash::from_bytes(cert.pool_keyhash().to_bytes()).unwrap());
}
CertificateEnum::GenesisKeyDelegation(cert) => {
set.add(&Ed25519KeyHash::from_bytes(cert.genesis_delegate_hash().to_bytes()).unwrap());
}
// not witness as there is no single core node or genesis key that posts the certificate
CertificateEnum::MoveInstantaneousRewardsCert(_cert) => {}
}
set
}
source§impl Ed25519KeyHash
impl Ed25519KeyHash
sourcepub fn to_bytes(&self) -> Vec<u8>
pub fn to_bytes(&self) -> Vec<u8>
Examples found in repository?
src/address.rs (line 158)
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
fn to_raw_bytes(&self) -> Vec<u8> {
match &self.0 {
StakeCredType::Key(hash) => hash.to_bytes(),
StakeCredType::Script(hash) => hash.to_bytes(),
}
}
}
impl_to_from!(StakeCredential);
impl cbor_event::se::Serialize for StakeCredential {
fn serialize<'se, W: Write>(
&self,
serializer: &'se mut Serializer<W>,
) -> cbor_event::Result<&'se mut Serializer<W>> {
serializer.write_array(cbor_event::Len::Len(2))?;
match &self.0 {
StakeCredType::Key(keyhash) => {
serializer.write_unsigned_integer(0u64)?;
serializer.write_bytes(keyhash.to_bytes())
}
StakeCredType::Script(scripthash) => {
serializer.write_unsigned_integer(1u64)?;
serializer.write_bytes(scripthash.to_bytes())
}
}
}
More examples
src/tx_builder.rs (line 37)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
fn witness_keys_for_cert(cert_enum: &Certificate) -> RequiredSigners {
let mut set = RequiredSigners::new();
match &cert_enum.0 {
// stake key registrations do not require a witness
CertificateEnum::StakeRegistration(_cert) => {}
CertificateEnum::StakeDeregistration(cert) => {
set.add(&cert.stake_credential().to_keyhash().unwrap());
}
CertificateEnum::StakeDelegation(cert) => {
set.add(&cert.stake_credential().to_keyhash().unwrap());
}
CertificateEnum::PoolRegistration(cert) => {
for owner in &cert.pool_params().pool_owners().0 {
set.add(&owner.clone());
}
set.add(&Ed25519KeyHash::from_bytes(cert.pool_params().operator().to_bytes()).unwrap());
}
CertificateEnum::PoolRetirement(cert) => {
set.add(&Ed25519KeyHash::from_bytes(cert.pool_keyhash().to_bytes()).unwrap());
}
CertificateEnum::GenesisKeyDelegation(cert) => {
set.add(&Ed25519KeyHash::from_bytes(cert.genesis_delegate_hash().to_bytes()).unwrap());
}
// not witness as there is no single core node or genesis key that posts the certificate
CertificateEnum::MoveInstantaneousRewardsCert(_cert) => {}
}
set
}
pub fn to_bech32(&self, prefix: &str) -> Result<String, JsError>
pub fn from_bech32(bech_str: &str) -> Result<Ed25519KeyHash, JsError>
pub fn to_hex(&self) -> String
pub fn from_hex(hex: &str) -> Result<Ed25519KeyHash, JsError>
source§impl Ed25519KeyHash
impl Ed25519KeyHash
pub const BYTE_COUNT: usize = 28usize
Trait Implementations§
source§impl Clone for Ed25519KeyHash
impl Clone for Ed25519KeyHash
source§fn clone(&self) -> Ed25519KeyHash
fn clone(&self) -> Ed25519KeyHash
Returns a copy 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 Ed25519KeyHash
impl Debug for Ed25519KeyHash
source§impl<'de> Deserialize<'de> for Ed25519KeyHash
impl<'de> Deserialize<'de> for Ed25519KeyHash
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 Deserialize for Ed25519KeyHash
impl Deserialize for Ed25519KeyHash
fn deserialize<R: BufRead>(
raw: &mut Deserializer<R>
) -> Result<Self, DeserializeError>
source§impl Display for Ed25519KeyHash
impl Display for Ed25519KeyHash
source§impl Hash for Ed25519KeyHash
impl Hash for Ed25519KeyHash
source§impl JsonSchema for Ed25519KeyHash
impl JsonSchema for Ed25519KeyHash
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &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 Ed25519KeyHash
impl Ord for Ed25519KeyHash
source§fn cmp(&self, other: &Ed25519KeyHash) -> Ordering
fn cmp(&self, other: &Ed25519KeyHash) -> 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<Ed25519KeyHash> for Ed25519KeyHash
impl PartialEq<Ed25519KeyHash> for Ed25519KeyHash
source§fn eq(&self, other: &Ed25519KeyHash) -> bool
fn eq(&self, other: &Ed25519KeyHash) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<Ed25519KeyHash> for Ed25519KeyHash
impl PartialOrd<Ed25519KeyHash> for Ed25519KeyHash
source§fn partial_cmp(&self, other: &Ed25519KeyHash) -> Option<Ordering>
fn partial_cmp(&self, other: &Ed25519KeyHash) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more