pub struct LegacyPriv(_);
Implementations§
source§impl LegacyPriv
impl LegacyPriv
pub fn from_xprv(xprv: &XPrv) -> Self
sourcepub fn inner_key(&self) -> [u8; 64]
pub fn inner_key(&self) -> [u8; 64]
Examples found in repository?
src/chain_crypto/algorithms/legacy_daedalus.rs (line 96)
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
fn compute_public(key: &Self::Secret) -> <Self as AsymmetricPublicKey>::Public {
let ed25519e = key.inner_key();
let pubkey = ed25519::extended_to_public(&ed25519e);
let chaincode = key.chaincode();
let mut buf = [0; XPUB_SIZE];
buf[0..ed25519::PUBLIC_KEY_LENGTH].clone_from_slice(&pubkey);
buf[ed25519::PUBLIC_KEY_LENGTH..XPUB_SIZE].clone_from_slice(&chaincode);
XPub::from_bytes(buf)
}
fn secret_from_binary(data: &[u8]) -> Result<Self::Secret, SecretKeyError> {
// Note: we do NOT verify that the bytes match proper bip32 format
// this is because legacy Daedalus wallets do not match the format
if data.len() != XPRV_SIZE {
return Err(SecretKeyError::SizeInvalid);
}
let mut buf = [0; XPRV_SIZE];
buf[0..XPRV_SIZE].clone_from_slice(data);
Ok(LegacyPriv(buf))
}
}
impl SecretKeySizeStatic for LegacyDaedalus {
const SECRET_KEY_SIZE: usize = XPRV_SIZE;
}
type XSig = ed25519_bip32::Signature<u8>;
impl VerificationAlgorithm for LegacyDaedalus {
type Signature = XSig;
const SIGNATURE_SIZE: usize = ed25519_bip32::SIGNATURE_SIZE;
const SIGNATURE_BECH32_HRP: &'static str = "legacy_xsig";
fn signature_from_bytes(data: &[u8]) -> Result<Self::Signature, SignatureError> {
let xsig = XSig::from_slice(data)?;
Ok(xsig)
}
fn verify_bytes(
pubkey: &Self::Public,
signature: &Self::Signature,
msg: &[u8],
) -> Verification {
pubkey.verify(msg, signature).into()
}
}
impl SigningAlgorithm for LegacyDaedalus {
fn sign(key: &Self::Secret, msg: &[u8]) -> XSig {
let buf = key.inner_key();
let sig = ei::Sig(ed25519::signature_extended(msg, &buf));
ed25519_bip32::Signature::from_bytes(sig.0)
}
Trait Implementations§
source§impl AsRef<[u8]> for LegacyPriv
impl AsRef<[u8]> for LegacyPriv
source§impl Clone for LegacyPriv
impl Clone for LegacyPriv
source§fn clone(&self) -> LegacyPriv
fn clone(&self) -> LegacyPriv
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 moreAuto Trait Implementations§
impl RefUnwindSafe for LegacyPriv
impl Send for LegacyPriv
impl Sync for LegacyPriv
impl Unpin for LegacyPriv
impl UnwindSafe for LegacyPriv
Blanket Implementations§
source§impl<T> Base32Len for Twhere
T: AsRef<[u8]>,
impl<T> Base32Len for Twhere
T: AsRef<[u8]>,
source§fn base32_len(&self) -> usize
fn base32_len(&self) -> usize
Calculate the base32 serialized length
source§impl<T> ToBase32 for Twhere
T: AsRef<[u8]>,
impl<T> ToBase32 for Twhere
T: AsRef<[u8]>,
source§fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
Encode as base32 and write it to the supplied writer
Implementations shouldn’t allocate.
source§impl<T> ToHex for Twhere
T: AsRef<[u8]>,
impl<T> ToHex for Twhere
T: AsRef<[u8]>,
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
)