@@ -15,9 +15,11 @@ use hyper_util::rt::TokioIo;
1515use payjoin:: directory:: { ShortId , ShortIdError , ENCAPSULATED_MESSAGE_BYTES } ;
1616use tokio:: net:: TcpListener ;
1717use tokio:: sync:: Mutex ;
18- use tracing:: { debug, error, info , trace} ;
18+ use tracing:: { debug, error, trace} ;
1919
2020use crate :: db:: DbPool ;
21+ mod key_config;
22+ use crate :: key_config:: init_ohttp;
2123
2224pub const DEFAULT_DIR_PORT : u16 = 8080 ;
2325pub const DEFAULT_DB_HOST : & str = "localhost:6379" ;
@@ -158,21 +160,6 @@ fn init_tls_acceptor(cert_key: (Vec<u8>, Vec<u8>)) -> Result<tokio_rustls::TlsAc
158160 Ok ( TlsAcceptor :: from ( Arc :: new ( server_config) ) )
159161}
160162
161- fn init_ohttp ( ) -> Result < ohttp:: Server > {
162- use ohttp:: hpke:: { Aead , Kdf , Kem } ;
163- use ohttp:: { KeyId , SymmetricSuite } ;
164-
165- const KEY_ID : KeyId = 1 ;
166- const KEM : Kem = Kem :: K256Sha256 ;
167- const SYMMETRIC : & [ SymmetricSuite ] =
168- & [ SymmetricSuite :: new ( Kdf :: HkdfSha256 , Aead :: ChaCha20Poly1305 ) ] ;
169-
170- // create or read from file
171- let server_config = ohttp:: KeyConfig :: new ( KEY_ID , KEM , Vec :: from ( SYMMETRIC ) ) ?;
172- info ! ( "Initialized a new OHTTP Key Configuration. GET /ohttp-keys to fetch it." ) ;
173- Ok ( ohttp:: Server :: new ( server_config) ?)
174- }
175-
176163async fn serve_payjoin_directory (
177164 req : Request < Incoming > ,
178165 pool : DbPool ,
0 commit comments