mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Derive Tor secret key from seed.
This commit is contained in:
parent
3a5395d7a5
commit
c8e6db24f8
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3742,6 +3742,7 @@ dependencies = [
|
||||
"dialoguer",
|
||||
"directories-next",
|
||||
"ecdsa_fun",
|
||||
"ed25519-dalek",
|
||||
"futures",
|
||||
"get-port",
|
||||
"hyper 0.14.7",
|
||||
|
@ -26,6 +26,7 @@ data-encoding = "2.3"
|
||||
dialoguer = "0.8"
|
||||
directories-next = "2"
|
||||
ecdsa_fun = { git = "https://github.com/LLFourn/secp256kfun", features = ["libsecp_compat", "serde"] }
|
||||
ed25519-dalek = "1"
|
||||
futures = { version = "0.3", default-features = false }
|
||||
itertools = "0.10"
|
||||
libp2p = { version = "0.37", default-features = false, features = ["tcp-tokio", "yamux", "mplex", "dns-tokio", "noise", "request-response", "websocket"] }
|
||||
|
@ -12,6 +12,7 @@ use std::fmt;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{self, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use torut::onion::TorSecretKeyV3;
|
||||
|
||||
pub const SEED_LENGTH: usize = 32;
|
||||
|
||||
@ -47,6 +48,14 @@ impl Seed {
|
||||
identity::Keypair::Ed25519(key.into())
|
||||
}
|
||||
|
||||
pub fn derive_torv3_key(&self) -> TorSecretKeyV3 {
|
||||
let bytes = self.derive(b"TOR").bytes();
|
||||
let sk = ed25519_dalek::SecretKey::from_bytes(&bytes)
|
||||
.expect("Failed to create a new extended secret key for Tor.");
|
||||
let esk = ed25519_dalek::ExpandedSecretKey::from(&sk);
|
||||
esk.to_bytes().into()
|
||||
}
|
||||
|
||||
pub fn from_file_or_generate(data_dir: &Path) -> Result<Self, Error> {
|
||||
let file_path_buf = data_dir.join("seed.pem");
|
||||
let file_path = Path::new(&file_path_buf);
|
||||
|
Loading…
Reference in New Issue
Block a user