pub trait KeysInterface {
    type Signer: Sign;

    fn get_node_secret(&self, recipient: Recipient) -> Result<SecretKey, ()>;
    fn ecdh(
        &self,
        recipient: Recipient,
        other_key: &PublicKey,
        tweak: Option<&Scalar>
    ) -> Result<SharedSecret, ()>; fn get_destination_script(&self) -> Script; fn get_shutdown_scriptpubkey(&self) -> ShutdownScript; fn get_channel_signer(
        &self,
        inbound: bool,
        channel_value_satoshis: u64
    ) -> Self::Signer; fn get_secure_random_bytes(&self) -> [u8; 32]; fn read_chan_signer(
        &self,
        reader: &[u8]
    ) -> Result<Self::Signer, DecodeError>; fn sign_invoice(
        &self,
        hrp_bytes: &[u8],
        invoice_data: &[u5],
        receipient: Recipient
    ) -> Result<RecoverableSignature, ()>; fn get_inbound_payment_key_material(&self) -> KeyMaterial; fn get_node_id(&self, recipient: Recipient) -> Result<PublicKey, ()> { ... } }
Expand description

A trait to describe an object which can get user secrets and key material.

Required Associated Types

A type which implements Sign which will be returned by get_channel_signer.

Required Methods

Get node secret key based on the provided Recipient.

The node_id/network_key is the public key that corresponds to this secret key.

This method must return the same value each time it is called with a given Recipient parameter.

Errors if the Recipient variant is not supported by the implementation.

Gets the ECDH shared secret of our node secret and other_key, multiplying by tweak if one is provided. Note that this tweak can be applied to other_key instead of our node secret, though this is less efficient.

Errors if the Recipient variant is not supported by the implementation.

Get a script pubkey which we send funds to when claiming on-chain contestable outputs.

This method should return a different value each time it is called, to avoid linking on-chain funds across channels as controlled to the same user.

Get a script pubkey which we will send funds to when closing a channel.

This method should return a different value each time it is called, to avoid linking on-chain funds across channels as controlled to the same user.

Get a new set of Sign for per-channel secrets. These MUST be unique even if you restarted with some stale data!

This method must return a different value each time it is called.

Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting onion packets and for temporary channel IDs. There is no requirement that these be persisted anywhere, though they must be unique across restarts.

This method must return a different value each time it is called.

Reads a Signer for this KeysInterface from the given input stream. This is only called during deserialization of other objects which contain Sign-implementing objects (ie ChannelMonitors and ChannelManagers). The bytes are exactly those which <Self::Signer as Writeable>::write() writes, and contain no versioning scheme. You may wish to include your own version prefix and ensure you’ve read all of the provided bytes to ensure no corruption occurred.

Sign an invoice. By parameterizing by the raw invoice bytes instead of the hash, we allow implementors of this trait to parse the invoice and make sure they’re signing what they expect, rather than blindly signing the hash. The hrp is ascii bytes, while the invoice data is base32.

The secret key used to sign the invoice is dependent on the Recipient.

Errors if the Recipient variant is not supported by the implementation.

Get secret key material as bytes for use in encrypting and decrypting inbound payment data.

If the implementor of this trait supports phantom node payments, then every node that is intended to be included in the phantom invoice route hints must return the same value from this method.

This method must return the same value each time it is called.

Provided Methods

Get node id based on the provided Recipient. This public key corresponds to the secret in get_node_secret.

This method must return the same value each time it is called with a given Recipient parameter.

Errors if the Recipient variant is not supported by the implementation.

Implementors