Skip to content

Commit

Permalink
Switch to bitcoin's version of HKDF
Browse files Browse the repository at this point in the history
* Our implementation of HKDF was pushed down into bitcoin, but has
only been published in bitcoin_hashes, not in a new version of bitcoin
yet. Once bitcoin is updated we can depend on the re-exported HKDF
there.
  • Loading branch information
nyonson committed Nov 12, 2024
1 parent 8547e47 commit 6421e2a
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 169 deletions.
59 changes: 47 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rust-version = "1.63.0"
default = ["std"]
async = ["std", "futures/std"]
tokio = ["std", "tokio/io-util"]
std = ["alloc", "bitcoin/std", "chacha20-poly1305/std", "rand/std", "rand/std_rng"]
std = ["alloc", "bitcoin/std", "bitcoin_hashes/std", "chacha20-poly1305/std", "rand/std", "rand/std_rng"]
alloc = ["chacha20-poly1305/alloc"]

[dependencies]
Expand All @@ -21,6 +21,9 @@ futures = { version = "0.3.30", default-features = false, optional = true }
tokio = { version = ">=1.37.0, <1.39.0", default-features = false, optional = true }
rand = { version = "0.8.0", default-features = false }
bitcoin = { version = "0.32.4", default-features = false }
# Depending on hashes directly for HKDF, can drop this and
# use the re-exported version in bitcoin > 0.32.*.
bitcoin_hashes = { version ="0.15.0", default-features = false }
chacha20-poly1305 = { version = "0.1.1", default-features = false }

[dev-dependencies]
Expand Down
148 changes: 0 additions & 148 deletions protocol/src/hkdf.rs

This file was deleted.

13 changes: 5 additions & 8 deletions protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ extern crate alloc;
extern crate std;

mod fschacha20poly1305;
mod hkdf;
#[cfg(feature = "std")]
pub mod serde;

Expand All @@ -37,14 +36,12 @@ use alloc::vec;
#[cfg(feature = "alloc")]
use alloc::vec::Vec;

use bitcoin::{
hashes::sha256,
secp256k1::{
self,
ellswift::{ElligatorSwift, ElligatorSwiftParty},
PublicKey, Secp256k1, SecretKey, Signing,
},
use bitcoin::secp256k1::{
self,
ellswift::{ElligatorSwift, ElligatorSwiftParty},
PublicKey, Secp256k1, SecretKey, Signing,
};
use bitcoin_hashes::{hkdf, sha256};
use fschacha20poly1305::{FSChaCha20, FSChaCha20Poly1305};
// Default to the futures-rs traits, but can overwrite with more specific
// tokio implemenations for easier caller integration.
Expand Down

0 comments on commit 6421e2a

Please sign in to comment.