X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Foffers%2Fsigner.rs;fp=lightning%2Fsrc%2Foffers%2Fsigner.rs;h=fff0514564ca34253d8a2b958e95ba1a9e8f4549;hb=a8bd4c097f7ae6620eee66c1cb49144e38568439;hp=c5a96cbf18491e3f22eb830c879eb4d274e9abc3;hpb=df0120809f3453aa4cfc6ca4d34bbedcc823928d;p=rust-lightning diff --git a/lightning/src/offers/signer.rs b/lightning/src/offers/signer.rs index c5a96cbf..fff05145 100644 --- a/lightning/src/offers/signer.rs +++ b/lightning/src/offers/signer.rs @@ -13,7 +13,7 @@ use bitcoin::hashes::{Hash, HashEngine}; use bitcoin::hashes::cmp::fixed_time_eq; use bitcoin::hashes::hmac::{Hmac, HmacEngine}; use bitcoin::hashes::sha256::Hash as Sha256; -use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey, self}; +use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey, self}; use core::fmt; use crate::ln::channelmanager::PaymentId; use crate::ln::inbound_payment::{ExpandedKey, IV_LEN, Nonce}; @@ -102,7 +102,7 @@ impl Metadata { pub fn derive_from( self, tlv_stream: W, secp_ctx: Option<&Secp256k1> - ) -> (Self, Option) { + ) -> (Self, Option) { match self { Metadata::Bytes(_) => (self, None), Metadata::Derived(mut metadata_material) => { @@ -188,7 +188,7 @@ impl MetadataMaterial { fn derive_metadata_and_keys( mut self, secp_ctx: &Secp256k1 - ) -> (Vec, KeyPair) { + ) -> (Vec, Keypair) { self.hmac.input(DERIVED_METADATA_AND_KEYS_HMAC_INPUT); self.maybe_include_encrypted_payment_id(); @@ -197,7 +197,7 @@ impl MetadataMaterial { let hmac = Hmac::from_engine(self.hmac); let privkey = SecretKey::from_slice(hmac.as_byte_array()).unwrap(); - let keys = KeyPair::from_secret_key(secp_ctx, &privkey); + let keys = Keypair::from_secret_key(secp_ctx, &privkey); (bytes, keys) } @@ -213,12 +213,12 @@ impl MetadataMaterial { } } -pub(super) fn derive_keys(nonce: Nonce, expanded_key: &ExpandedKey) -> KeyPair { +pub(super) fn derive_keys(nonce: Nonce, expanded_key: &ExpandedKey) -> Keypair { const IV_BYTES: &[u8; IV_LEN] = b"LDK Invoice ~~~~"; let secp_ctx = Secp256k1::new(); let hmac = Hmac::from_engine(expanded_key.hmac_for_offer(nonce, IV_BYTES)); let privkey = SecretKey::from_slice(hmac.as_byte_array()).unwrap(); - KeyPair::from_secret_key(&secp_ctx, &privkey) + Keypair::from_secret_key(&secp_ctx, &privkey) } /// Verifies data given in a TLV stream was used to produce the given metadata, consisting of: @@ -265,12 +265,12 @@ pub(super) fn verify_payer_metadata<'a, T: secp256k1::Signing>( /// If the latter is not included in the metadata, the TLV stream is used to check if the given /// `signing_pubkey` can be derived from it. /// -/// Returns the [`KeyPair`] for signing the invoice, if it can be derived from the metadata. +/// Returns the [`Keypair`] for signing the invoice, if it can be derived from the metadata. pub(super) fn verify_recipient_metadata<'a, T: secp256k1::Signing>( metadata: &[u8], expanded_key: &ExpandedKey, iv_bytes: &[u8; IV_LEN], signing_pubkey: PublicKey, tlv_stream: impl core::iter::Iterator>, secp_ctx: &Secp256k1 -) -> Result, ()> { +) -> Result, ()> { let mut hmac = hmac_for_message(metadata, expanded_key, iv_bytes, tlv_stream)?; hmac.input(WITHOUT_ENCRYPTED_PAYMENT_ID_HMAC_INPUT); @@ -279,9 +279,9 @@ pub(super) fn verify_recipient_metadata<'a, T: secp256k1::Signing>( fn verify_metadata( metadata: &[u8], hmac: Hmac, signing_pubkey: PublicKey, secp_ctx: &Secp256k1 -) -> Result, ()> { +) -> Result, ()> { if metadata.len() == Nonce::LENGTH { - let derived_keys = KeyPair::from_secret_key( + let derived_keys = Keypair::from_secret_key( secp_ctx, &SecretKey::from_slice(hmac.as_byte_array()).unwrap() ); if fixed_time_eq(&signing_pubkey.serialize(), &derived_keys.public_key().serialize()) {