Skip to content

Commit

Permalink
Depend on bitcoin-ohttp
Browse files Browse the repository at this point in the history
Which in turn depends on bitcoin-hpke and libsecp256k1 C bindings
  • Loading branch information
DanGould committed Sep 4, 2024
1 parent b14f179 commit 3decf2d
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 160 deletions.
197 changes: 47 additions & 150 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion payjoin-directory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ http-body-util = "0.1.2"
hyper = { version = "1", features = ["http1", "server"] }
hyper-rustls = { version = "0.26", optional = true }
hyper-util = { version = "0.1", features = ["tokio"] }
ohttp = "0.5.1"
ohttp = { package = "bitcoin-ohttp", version = "0.6.0"}
redis = { version = "0.23.3", features = ["aio", "tokio-comp"] }
rustls = { version = "0.22.4", optional = true }
tokio = { version = "1.12.0", features = ["full"] }
Expand Down
2 changes: 1 addition & 1 deletion payjoin-directory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn init_ohttp() -> Result<ohttp::Server> {
use ohttp::{KeyId, SymmetricSuite};

const KEY_ID: KeyId = 1;
const KEM: Kem = Kem::X25519Sha256;
const KEM: Kem = Kem::K256Sha256;
const SYMMETRIC: &[SymmetricSuite] =
&[SymmetricSuite::new(Kdf::HkdfSha256, Aead::ChaCha20Poly1305)];

Expand Down
2 changes: 1 addition & 1 deletion payjoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ chacha20poly1305 = { version = "0.10.1", optional = true }
log = { version = "0.4.14"}
http = { version = "1", optional = true }
bhttp = { version = "=0.5.1", optional = true }
ohttp = { version = "0.5.1", optional = true }
ohttp = { package = "bitcoin-ohttp", version = "0.6.0", optional = true }
serde = { version = "1.0.186", default-features = false, optional = true }
reqwest = { version = "0.12", default-features = false, optional = true }
rustls = { version = "0.22.4", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion payjoin/src/receive/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ mod test {
use ohttp::hpke::{Aead, Kdf, Kem};
use ohttp::{KeyId, SymmetricSuite};
const KEY_ID: KeyId = 1;
const KEM: Kem = Kem::X25519Sha256;
const KEM: Kem = Kem::K256Sha256;
const SYMMETRIC: &[SymmetricSuite] =
&[ohttp::SymmetricSuite::new(Kdf::HkdfSha256, Aead::ChaCha20Poly1305)];

Expand Down
8 changes: 4 additions & 4 deletions payjoin/src/uri/url_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ mod tests {
let mut url = Url::parse("https://example.com").unwrap();

let ohttp_keys =
OhttpKeys::from_str("AQAg3WpRjS0aqAxQUoLvpas2VYjT2oIg6-3XSiB-QiYI1BAABAABAAM").unwrap();
OhttpKeys::from_str("AQAWBG3fkg7fQCN-bafc-BEJOSnDfq8k1M9Cy1kgQZX42GVOvI0bWVAciTaJCy2A_wy7R7VxtU88xej692bv0uXgt98ABAABAAM").unwrap();
let _ = url.set_ohttp(Some(ohttp_keys.clone()));
assert_eq!(
url.fragment(),
Some("ohttp=AQAg3WpRjS0aqAxQUoLvpas2VYjT2oIg6-3XSiB-QiYI1BAABAABAAM")
Some("ohttp=AQAWBG3fkg7fQCN-bafc-BEJOSnDfq8k1M9Cy1kgQZX42GVOvI0bWVAciTaJCy2A_wy7R7VxtU88xej692bv0uXgt98ABAABAAM")
);

assert_eq!(url.ohttp(), Some(ohttp_keys));
Expand Down Expand Up @@ -124,7 +124,7 @@ mod tests {
// fragment is not percent encoded so `&ohttp=` is parsed as a query parameter, not a fragment parameter
let uri = "bitcoin:12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX?amount=0.01\
&pj=https://example.com\
#exp=1720547781&ohttp=AQAg3WpRjS0aqAxQUoLvpas2VYjT2oIg6-3XSiB-QiYI1BAABAABAAM";
#exp=1720547781&ohttp=AQAWBG3fkg7fQCN-bafc-BEJOSnDfq8k1M9Cy1kgQZX42GVOvI0bWVAciTaJCy2A_wy7R7VxtU88xej692bv0uXgt98ABAABAAM";
let uri = Uri::try_from(uri).unwrap().assume_checked().check_pj_supported().unwrap();
assert!(uri.extras.endpoint().ohttp().is_none());
}
Expand All @@ -133,7 +133,7 @@ mod tests {
fn test_valid_v2_url_fragment_on_bip21() {
let uri = "bitcoin:12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX?amount=0.01\
&pj=https://example.com\
#ohttp%3DAQAg3WpRjS0aqAxQUoLvpas2VYjT2oIg6-3XSiB-QiYI1BAABAABAAM%26exp%3D1720547781";
#ohttp%3DAQAWBG3fkg7fQCN-bafc-BEJOSnDfq8k1M9Cy1kgQZX42GVOvI0bWVAciTaJCy2A_wy7R7VxtU88xej692bv0uXgt98ABAABAAM";
let uri = Uri::try_from(uri).unwrap().assume_checked().check_pj_supported().unwrap();
assert!(uri.extras.endpoint().ohttp().is_some());
}
Expand Down
2 changes: 1 addition & 1 deletion payjoin/src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ mod test {
use ohttp::hpke::{Aead, Kdf, Kem};
use ohttp::{KeyId, SymmetricSuite};
const KEY_ID: KeyId = 1;
const KEM: Kem = Kem::X25519Sha256;
const KEM: Kem = Kem::K256Sha256;
const SYMMETRIC: &[SymmetricSuite] =
&[ohttp::SymmetricSuite::new(Kdf::HkdfSha256, Aead::ChaCha20Poly1305)];
let keys = OhttpKeys(ohttp::KeyConfig::new(KEY_ID, KEM, Vec::from(SYMMETRIC)).unwrap());
Expand Down
2 changes: 1 addition & 1 deletion payjoin/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mod integration {
#[tokio::test]
async fn test_bad_ohttp_keys() {
let bad_ohttp_keys =
OhttpKeys::from_str("AQAg3WpRjS0aqAxQUoLvpas2VYjT2oIg6-3XSiB-QiYI1BAABAABAAM")
OhttpKeys::from_str("AQAWBG3fkg7fQCN-bafc-BEJOSnDfq8k1M9Cy1kgQZX42GVOvI0bWVAciTaJCy2A_wy7R7VxtU88xej692bv0uXgt98ABAABAAM")
.expect("Invalid OhttpKeys");

let (cert, key) = local_cert_key();
Expand Down

0 comments on commit 3decf2d

Please sign in to comment.