Skip to content

Commit a5dba58

Browse files
authored
Randomly pad OHTTP requests (payjoin#715)
Using random padding instead of 0 padding allows for multi-hop OHTTP to use pre-computed filler strings similarly to Sphinx indistinguishably from single hop requests which just use random padding. Making this change now means that if we ever implement multi-hop requests, their use would not be observable by the directory.
2 parents 2d69868 + 4649fb9 commit a5dba58

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

payjoin/src/ohttp.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::{error, fmt};
33

44
use bitcoin::bech32::{self, EncodeError};
55
use bitcoin::key::constants::UNCOMPRESSED_PUBLIC_KEY_SIZE;
6+
use hpke::rand_core::{OsRng, RngCore};
67

78
use crate::directory::ENCAPSULATED_MESSAGE_BYTES;
89

@@ -41,6 +42,7 @@ pub fn ohttp_encapsulate(
4142
}
4243

4344
let mut bhttp_req = [0u8; PADDED_BHTTP_REQ_BYTES];
45+
OsRng.fill_bytes(&mut bhttp_req);
4446
bhttp_message.write_bhttp(bhttp::Mode::KnownLength, &mut bhttp_req.as_mut_slice())?;
4547
let (encapsulated, ohttp_ctx) = ctx.encapsulate(&bhttp_req)?;
4648

0 commit comments

Comments
 (0)