pub struct LegacyPriv(_);

Implementations§

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)
    }
Examples found in repository?
src/chain_crypto/algorithms/legacy_daedalus.rs (line 98)
95
96
97
98
99
100
101
102
103
104
105
    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)
    }

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Calculate the base32 serialized length
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Error type if conversion fails
Check if all values are in range and return array-like struct of u5 values

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
Encode as base32 and write it to the supplied writer Implementations shouldn’t allocate.
Convert Self to base32 vector
Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca)
Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.