bless
This commit is contained in:
parent
177550d03f
commit
ba7de2aa53
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
**/target/
|
||||||
0
node/lib/.gitignore → lib/.gitignore
vendored
0
node/lib/.gitignore → lib/.gitignore
vendored
37
node/Cargo.lock
generated
37
node/Cargo.lock
generated
@ -204,6 +204,7 @@ dependencies = [
|
|||||||
"memory-stats",
|
"memory-stats",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
|
"ring",
|
||||||
"secp256k1",
|
"secp256k1",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -683,6 +684,17 @@ dependencies = [
|
|||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.2.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"wasi 0.11.1+wasi-snapshot-preview1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
@ -1091,7 +1103,7 @@ version = "0.9.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.3.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1133,6 +1145,20 @@ dependencies = [
|
|||||||
"bitflags 2.9.3",
|
"bitflags 2.9.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ring"
|
||||||
|
version = "0.17.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"cfg-if",
|
||||||
|
"getrandom 0.2.16",
|
||||||
|
"libc",
|
||||||
|
"untrusted",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.26"
|
version = "0.1.26"
|
||||||
@ -1192,6 +1218,7 @@ dependencies = [
|
|||||||
"bitcoin_hashes",
|
"bitcoin_hashes",
|
||||||
"rand",
|
"rand",
|
||||||
"secp256k1-sys",
|
"secp256k1-sys",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1518,6 +1545,12 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "untrusted"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unty"
|
name = "unty"
|
||||||
version = "0.0.4"
|
version = "0.0.4"
|
||||||
@ -1542,7 +1575,7 @@ version = "1.18.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be"
|
checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom 0.3.3",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"serde",
|
"serde",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
|||||||
@ -14,7 +14,7 @@ thiserror = "2.0.16"
|
|||||||
tokio = { version = "1.47.1", features = ["rt-multi-thread", "net", "sync", "time", "macros"] }
|
tokio = { version = "1.47.1", features = ["rt-multi-thread", "net", "sync", "time", "macros"] }
|
||||||
tokio-tungstenite = "0.27.0"
|
tokio-tungstenite = "0.27.0"
|
||||||
uuid = { version = "1.18.0", features = ["v4", "serde"] }
|
uuid = { version = "1.18.0", features = ["v4", "serde"] }
|
||||||
vlogger = { path = "./lib/logger-rs" }
|
vlogger = { path = "../lib/logger-rs" }
|
||||||
ratatui = "0.29.0"
|
ratatui = "0.29.0"
|
||||||
crossterm = { version = "0.29.0", features = ["event-stream"] }
|
crossterm = { version = "0.29.0", features = ["event-stream"] }
|
||||||
once_cell = "1.21.3"
|
once_cell = "1.21.3"
|
||||||
@ -27,4 +27,5 @@ textwrap = "0.16.2"
|
|||||||
sled = "0.34.7"
|
sled = "0.34.7"
|
||||||
bincode = { version = "2.0.1", features = ["derive", "serde"] }
|
bincode = { version = "2.0.1", features = ["derive", "serde"] }
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
secp256k1 = { version = "0.31.1", features = ["rand"] }
|
secp256k1 = { version = "0.31.1", features = ["hashes", "rand", "recovery", "serde"] }
|
||||||
|
ring = "0.17.14"
|
||||||
|
|||||||
@ -34,6 +34,14 @@ pub enum CliCommand {
|
|||||||
block_cmd: CliBlockCommand,
|
block_cmd: CliBlockCommand,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
#[command(name = "award")]
|
||||||
|
Award {
|
||||||
|
#[arg(short, long)]
|
||||||
|
amount: u64,
|
||||||
|
#[arg(short, long)]
|
||||||
|
address: String,
|
||||||
|
},
|
||||||
|
|
||||||
/// Make a Transaction
|
/// Make a Transaction
|
||||||
#[command(name = "tx")]
|
#[command(name = "tx")]
|
||||||
Transaction(core::Tx),
|
Transaction(core::Tx),
|
||||||
|
|||||||
@ -53,6 +53,7 @@ pub fn cli(input: &str) -> ExecutorCommand {
|
|||||||
CliCommand::Transaction(tx) => {
|
CliCommand::Transaction(tx) => {
|
||||||
ExecutorCommand::Node(NodeCommand::ProcessChainData(ChainData::Transaction(tx)))
|
ExecutorCommand::Node(NodeCommand::ProcessChainData(ChainData::Transaction(tx)))
|
||||||
}
|
}
|
||||||
|
CliCommand::Award { address, amount } => {ExecutorCommand::Node(NodeCommand::AwardCurrency{ address, amount })}
|
||||||
CliCommand::DebugShowId => ExecutorCommand::Node(NodeCommand::ShowId),
|
CliCommand::DebugShowId => ExecutorCommand::Node(NodeCommand::ShowId),
|
||||||
CliCommand::StartListner { addr } => {
|
CliCommand::StartListner { addr } => {
|
||||||
ExecutorCommand::Node(NodeCommand::StartListner(addr.parse().unwrap()))
|
ExecutorCommand::Node(NodeCommand::StartListner(addr.parse().unwrap()))
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
use secp256k1::{ rand, Message, Secp256k1 };
|
use sha2::{Sha256, Digest};
|
||||||
use sha2::{Digest, Sha256};
|
use secp256k1::rand;
|
||||||
|
use secp256k1::{Secp256k1, PublicKey, SecretKey};
|
||||||
|
|
||||||
pub type Address = String;
|
pub type Address = String;
|
||||||
|
|
||||||
#[derive(Debug, bincode::Decode, bincode::Encode)]
|
#[derive(Debug, bincode::Decode, bincode::Encode)]
|
||||||
@ -7,17 +9,15 @@ pub struct Account {
|
|||||||
address: Address,
|
address: Address,
|
||||||
balance: u64,
|
balance: u64,
|
||||||
nonce: u64,
|
nonce: u64,
|
||||||
login_method: LoginMethod,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, bincode::Decode, bincode::Encode)]
|
|
||||||
pub enum LoginMethod {
|
|
||||||
Password {
|
|
||||||
password_hash: String,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Account {
|
impl Account {
|
||||||
|
pub fn public_key_to_address(public_key: &PublicKey) -> Address {
|
||||||
|
let pk_ser = public_key.serialize();
|
||||||
|
let hash = Sha256::digest(&pk_ser);
|
||||||
|
hex::encode(&hash[..20])
|
||||||
|
}
|
||||||
|
|
||||||
pub fn nonce(&self) -> u64 {
|
pub fn nonce(&self) -> u64 {
|
||||||
self.nonce
|
self.nonce
|
||||||
}
|
}
|
||||||
@ -30,18 +30,22 @@ impl Account {
|
|||||||
&self.address
|
&self.address
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new() {
|
pub fn new() -> Self {
|
||||||
let secp = Secp256k1::new();
|
let secp = Secp256k1::new();
|
||||||
let (secret_key, public_key) = secp.generate_keypair(&mut rand::rng());
|
let (secret_key, public_key) = secp.generate_keypair(&mut rand::rng());
|
||||||
|
let addr = Self::public_key_to_address(&public_key);
|
||||||
|
|
||||||
let digest = Sha256::digest("Hello World");
|
println!("{:?}", secret_key);
|
||||||
|
|
||||||
let message = Message::from_digest(digest.into());
|
Self {
|
||||||
|
address: addr,
|
||||||
let sig = secp.sign_ecdsa(message, &secret_key);
|
balance: 0,
|
||||||
|
nonce: 0,
|
||||||
let pk_hash = Sha256::digest(secret_key);
|
}
|
||||||
|
|
||||||
assert!(secp.verify_ecdsa(message, &sig, &public_key).is_ok());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_acc_new() {
|
||||||
|
Account::new();
|
||||||
|
}
|
||||||
|
|||||||
@ -65,6 +65,10 @@ impl Blockchain {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn award_currency(&self, address: String, amount: u64) -> Result<(), BlockchainError> {
|
||||||
|
Ok(self.db.add_balance(&address, amount)?)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn create_block(&mut self) -> Result<Arc<core::Block>, BlockchainError> {
|
pub fn create_block(&mut self) -> Result<Arc<core::Block>, BlockchainError> {
|
||||||
match self.blocks() {
|
match self.blocks() {
|
||||||
Ok(blocks) => {
|
Ok(blocks) => {
|
||||||
@ -111,18 +115,25 @@ impl Blockchain {
|
|||||||
tx.validate()?;
|
tx.validate()?;
|
||||||
let from = tx.from();
|
let from = tx.from();
|
||||||
let to = tx.to();
|
let to = tx.to();
|
||||||
let from_balance = self.db.get_balance(tx.from())?;
|
if let Some(from_balance) = self.db.get_balance(tx.from())? {
|
||||||
let to_balance = self.db.get_balance(tx.to())?;
|
let to_balance = if let Some(b) = self.db.get_balance(tx.to())? {
|
||||||
|
b
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
if tx.value() > from_balance {
|
if tx.value() > from_balance {
|
||||||
return Err(BlockchainError::InsufficientFunds(tx.from().to_string()))
|
return Err(BlockchainError::InsufficientFunds(tx.from().to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
let new_from_balance = from_balance - tx.value();
|
||||||
|
let new_to_balance = to_balance + tx.value();
|
||||||
|
|
||||||
|
let changes = vec![(from, new_from_balance), (to, new_to_balance)];
|
||||||
|
Ok(self.db.set_balance_batch(changes)?)
|
||||||
|
} else {
|
||||||
|
Err(BlockchainError::Database(DatabaseError::AccountNotFound(from.to_string())))
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_from_balance = from_balance - tx.value();
|
|
||||||
let new_to_balance = to_balance + tx.value();
|
|
||||||
|
|
||||||
let changes = vec![(from, new_from_balance), (to, new_to_balance)];
|
|
||||||
Ok(self.db.set_balance_batch(changes)?)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_chain_data(&mut self, data: ChainData) -> Result<(), BlockchainError> {
|
pub fn apply_chain_data(&mut self, data: ChainData) -> Result<(), BlockchainError> {
|
||||||
|
|||||||
@ -1,23 +1,34 @@
|
|||||||
use crate::error::TxError;
|
use crate::error::TxError;
|
||||||
use super::Address;
|
use super::{ Address, Account};
|
||||||
|
|
||||||
|
//use secp256k1::{
|
||||||
|
// ecdsa::{RecoveryId, Signature},
|
||||||
|
// Message, PublicKey, Secp256k1, SecretKey,
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
//use ring::digest;
|
||||||
|
//
|
||||||
#[derive(
|
#[derive(
|
||||||
serde::Deserialize, serde::Serialize, Debug, clap::Args, Clone, bincode::Encode, bincode::Decode,
|
serde::Deserialize, serde::Serialize, Debug, clap::Args, Clone, bincode::Encode, bincode::Decode,
|
||||||
)]
|
)]
|
||||||
pub struct Tx {
|
pub struct Tx {
|
||||||
from: String,
|
from: Address,
|
||||||
to: String,
|
to: Address,
|
||||||
value: u64,
|
value: u64,
|
||||||
data: String,
|
data: String,
|
||||||
|
nonce: u64,
|
||||||
|
signature: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tx {
|
impl Tx {
|
||||||
pub fn new(from: String, to: String, value: u64, data: String) -> Self {
|
pub fn new(from: &Account, to: Address, value: u64, data: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
from,
|
from: from.address().to_string(),
|
||||||
to,
|
to,
|
||||||
value,
|
value,
|
||||||
data,
|
data,
|
||||||
|
nonce: from.nonce() + 1,
|
||||||
|
signature: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,14 +40,18 @@ impl Tx {
|
|||||||
} else if self.value == 0 {
|
} else if self.value == 0 {
|
||||||
return Err(TxError::ValueEmpty);
|
return Err(TxError::ValueEmpty);
|
||||||
}
|
}
|
||||||
|
//let secp = secp256k1::Secp256k1::new();
|
||||||
|
//let mut tx_hash = [0u8; 32];
|
||||||
|
//tx_hash.copy_from_slice(self.hash().as_bytes());
|
||||||
|
//let message = secp256k1::Message::from_digest(tx_hash);
|
||||||
|
//let signature = secp256k1::ecdsa::Signature::from_compact(&self.signature).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn is_new_account(&self) -> bool {
|
|
||||||
return self.data == "new_account";
|
pub fn hash(&self) -> String {
|
||||||
}
|
super::Hasher::hash_chain_data(&super::ChainData::Transaction(self.clone()))
|
||||||
pub fn is_reward(&self) -> bool {
|
|
||||||
return self.data == "reward";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from(&self) -> &Address {
|
pub fn from(&self) -> &Address {
|
||||||
&self.from
|
&self.from
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,6 +156,15 @@ impl ChainDb {
|
|||||||
Ok(self.db.flush_async().await?)
|
Ok(self.db.flush_async().await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_balance(&self, address: &Address, new_balance: u64) -> Result<(), DatabaseError> {
|
||||||
|
let new_balance = if let Some(old_balance) = self.get_balance(address)? {
|
||||||
|
old_balance + new_balance
|
||||||
|
} else {
|
||||||
|
new_balance
|
||||||
|
};
|
||||||
|
Ok(self.set_balance(address, new_balance)?)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_balance(&self, address: &Address, new_balance: u64) -> Result<(), DatabaseError> {
|
pub fn set_balance(&self, address: &Address, new_balance: u64) -> Result<(), DatabaseError> {
|
||||||
let mut batch = Batch::default();
|
let mut batch = Batch::default();
|
||||||
let account_nonce = self.get_nonce(address)?;
|
let account_nonce = self.get_nonce(address)?;
|
||||||
@ -199,13 +208,13 @@ impl ChainDb {
|
|||||||
Ok(self.db.apply_batch(batch)?)
|
Ok(self.db.apply_batch(batch)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_balance(&self, address: &Address) -> Result<u64, DatabaseError> {
|
pub fn get_balance(&self, address: &Address) -> Result<Option<u64>, DatabaseError> {
|
||||||
match self.db.get(balances_prefix(address))? {
|
match self.db.get(balances_prefix(address))? {
|
||||||
Some(b) => {
|
Some(b) => {
|
||||||
let (balance, _) = bincode::decode_from_slice::<u64, _>(&b, BINCODE_CONFIG)?;
|
let (balance, _) = bincode::decode_from_slice::<u64, _>(&b, BINCODE_CONFIG)?;
|
||||||
Ok(balance)
|
Ok(Some(balance))
|
||||||
},
|
},
|
||||||
None => Err(DatabaseError::AccountNotFound(address.to_string())),
|
None => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,9 @@ pub mod renderer {
|
|||||||
|
|
||||||
pub mod layout;
|
pub mod layout;
|
||||||
pub use layout::*;
|
pub use layout::*;
|
||||||
|
|
||||||
|
pub mod command;
|
||||||
|
pub use command::*;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod watcher {
|
pub mod watcher {
|
||||||
|
|||||||
@ -75,6 +75,7 @@ pub enum NodeCommand {
|
|||||||
ListBlocks,
|
ListBlocks,
|
||||||
ListPeers,
|
ListPeers,
|
||||||
ShowId,
|
ShowId,
|
||||||
|
AwardCurrency { address: String, amount: u64 },
|
||||||
ConnectToSeeds,
|
ConnectToSeeds,
|
||||||
ConnectTcpPeer(String),
|
ConnectTcpPeer(String),
|
||||||
BootStrap,
|
BootStrap,
|
||||||
@ -398,6 +399,11 @@ impl Node {
|
|||||||
NodeCommand::ProcessMessage { peer_id, message } => {
|
NodeCommand::ProcessMessage { peer_id, message } => {
|
||||||
self.process_message(peer_id, message).await;
|
self.process_message(peer_id, message).await;
|
||||||
}
|
}
|
||||||
|
NodeCommand::AwardCurrency { address, amount } => {
|
||||||
|
if let Err(e) = self.chain.award_currency(address, amount) {
|
||||||
|
print_error_chain(&e.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
NodeCommand::ProcessChainData(data) => {
|
NodeCommand::ProcessChainData(data) => {
|
||||||
if let Err(e) = self.chain.apply_chain_data(data.clone()) {
|
if let Err(e) = self.chain.apply_chain_data(data.clone()) {
|
||||||
print_error_chain(&e.into());
|
print_error_chain(&e.into());
|
||||||
|
|||||||
26
node/src/renderer/command.rs
Normal file
26
node/src/renderer/command.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub enum RenderCommand {
|
||||||
|
StringToPaneId {
|
||||||
|
str: String,
|
||||||
|
pane: RenderTarget,
|
||||||
|
},
|
||||||
|
StringToPaneFocused {
|
||||||
|
str: String,
|
||||||
|
},
|
||||||
|
KeyInput(KeyCode),
|
||||||
|
ListMove {
|
||||||
|
pane: RenderTarget,
|
||||||
|
index: usize,
|
||||||
|
},
|
||||||
|
ChangeLayout(RenderLayoutKind),
|
||||||
|
ClearPane,
|
||||||
|
|
||||||
|
/// Mouse Events
|
||||||
|
MouseClickLeft(u16, u16),
|
||||||
|
MouseScrollUp,
|
||||||
|
MouseScrollDown,
|
||||||
|
|
||||||
|
SetMode(InputMode),
|
||||||
|
Exit,
|
||||||
|
}
|
||||||
|
|
||||||
@ -2,12 +2,9 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use crossterm::event::KeyCode;
|
use crossterm::event::KeyCode;
|
||||||
use ratatui::{Frame, buffer::Buffer, layout::Rect, widgets::Widget};
|
use ratatui::{Frame, buffer::Buffer, layout::Rect, widgets::Widget};
|
||||||
|
|
||||||
use vlogger::*;
|
use vlogger::*;
|
||||||
use tokio::time::{Duration, timeout};
|
|
||||||
|
|
||||||
use crate::log;
|
use crate::log;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -290,15 +287,6 @@ impl Renderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn listen(
|
|
||||||
&mut self,
|
|
||||||
rx: &mut tokio::sync::broadcast::Receiver<RenderCommand>,
|
|
||||||
) -> Result<RenderCommand, ()> {
|
|
||||||
if let Ok(Ok(mes)) = timeout(Duration::from_millis(400), rx.recv()).await {
|
|
||||||
return Ok(mes);
|
|
||||||
}
|
|
||||||
Err(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Widget for &mut Renderer {
|
impl Widget for &mut Renderer {
|
||||||
|
|||||||
481
testing/keys/Cargo.lock
generated
Normal file
481
testing/keys/Cargo.lock
generated
Normal file
@ -0,0 +1,481 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aes"
|
||||||
|
version = "0.8.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"cipher",
|
||||||
|
"cpufeatures",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "arrayvec"
|
||||||
|
version = "0.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base64ct"
|
||||||
|
version = "1.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89e25b6adfb930f02d1981565a6e5d9c547ac15a96606256d3b59040e5cd4ca3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitcoin-io"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0b47c4ab7a93edb0c7198c5535ed9b52b63095f4e9b45279c6736cec4b856baf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitcoin_hashes"
|
||||||
|
version = "0.14.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
|
||||||
|
dependencies = [
|
||||||
|
"bitcoin-io",
|
||||||
|
"hex-conservative",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "block-buffer"
|
||||||
|
version = "0.10.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "block-padding"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cbc"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
|
||||||
|
dependencies = [
|
||||||
|
"cipher",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.2.35"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "590f9024a68a8c40351881787f1934dc11afd69090f5edb6831464694d836ea3"
|
||||||
|
dependencies = [
|
||||||
|
"find-msvc-tools",
|
||||||
|
"shlex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cipher"
|
||||||
|
version = "0.4.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
|
||||||
|
dependencies = [
|
||||||
|
"crypto-common",
|
||||||
|
"inout",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const-oid"
|
||||||
|
version = "0.9.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cpufeatures"
|
||||||
|
version = "0.2.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crypto-common"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
"typenum",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "der"
|
||||||
|
version = "0.7.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"
|
||||||
|
dependencies = [
|
||||||
|
"const-oid",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "digest"
|
||||||
|
version = "0.10.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||||
|
dependencies = [
|
||||||
|
"block-buffer",
|
||||||
|
"crypto-common",
|
||||||
|
"subtle",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "find-msvc-tools"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e178e4fba8a2726903f6ba98a6d221e76f9c12c650d5dc0e6afdc50677b49650"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "generic-array"
|
||||||
|
version = "0.14.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||||
|
dependencies = [
|
||||||
|
"typenum",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"r-efi",
|
||||||
|
"wasi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hex-conservative"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
|
||||||
|
dependencies = [
|
||||||
|
"arrayvec",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hmac"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
|
||||||
|
dependencies = [
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "inout"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
|
||||||
|
dependencies = [
|
||||||
|
"block-padding",
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "keys"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"pkcs8",
|
||||||
|
"rand",
|
||||||
|
"secp256k1",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.175"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pbkdf2"
|
||||||
|
version = "0.12.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
|
||||||
|
dependencies = [
|
||||||
|
"digest",
|
||||||
|
"hmac",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pkcs5"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e847e2c91a18bfa887dd028ec33f2fe6f25db77db3619024764914affe8b69a6"
|
||||||
|
dependencies = [
|
||||||
|
"aes",
|
||||||
|
"cbc",
|
||||||
|
"der",
|
||||||
|
"pbkdf2",
|
||||||
|
"scrypt",
|
||||||
|
"sha2",
|
||||||
|
"spki",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pkcs8"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
|
||||||
|
dependencies = [
|
||||||
|
"der",
|
||||||
|
"pkcs5",
|
||||||
|
"rand_core 0.6.4",
|
||||||
|
"spki",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ppv-lite86"
|
||||||
|
version = "0.2.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.101"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.40"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "r-efi"
|
||||||
|
version = "5.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.9.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
|
||||||
|
dependencies = [
|
||||||
|
"rand_chacha",
|
||||||
|
"rand_core 0.9.3",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_chacha"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||||
|
dependencies = [
|
||||||
|
"ppv-lite86",
|
||||||
|
"rand_core 0.9.3",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.6.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "salsa20"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213"
|
||||||
|
dependencies = [
|
||||||
|
"cipher",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scrypt"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f"
|
||||||
|
dependencies = [
|
||||||
|
"pbkdf2",
|
||||||
|
"salsa20",
|
||||||
|
"sha2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "secp256k1"
|
||||||
|
version = "0.31.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2c3c81b43dc2d8877c216a3fccf76677ee1ebccd429566d3e67447290d0c42b2"
|
||||||
|
dependencies = [
|
||||||
|
"bitcoin_hashes",
|
||||||
|
"rand",
|
||||||
|
"secp256k1-sys",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "secp256k1-sys"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcb913707158fadaf0d8702c2db0e857de66eb003ccfdda5924b5f5ac98efb38"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.219"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.219"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sha2"
|
||||||
|
version = "0.10.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"cpufeatures",
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shlex"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "spki"
|
||||||
|
version = "0.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
|
||||||
|
dependencies = [
|
||||||
|
"base64ct",
|
||||||
|
"der",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "subtle"
|
||||||
|
version = "2.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "typenum"
|
||||||
|
version = "1.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.9.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.14.3+wasi-0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a51ae83037bdd272a9e28ce236db8c07016dd0d50c27038b3f407533c030c95"
|
||||||
|
dependencies = [
|
||||||
|
"wit-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wit-bindgen"
|
||||||
|
version = "0.45.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "052283831dbae3d879dc7f51f3d92703a316ca49f91540417d38591826127814"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.8.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.8.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zeroize"
|
||||||
|
version = "1.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
|
||||||
9
testing/keys/Cargo.toml
Normal file
9
testing/keys/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "keys"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
pkcs8 = { version = "0.10.2", features = ["encryption", "std", "alloc", "pkcs5"] }
|
||||||
|
rand = { version = "0.9.2", features = ["thread_rng"] }
|
||||||
|
secp256k1 = { version = "0.31.1", features = ["hashes", "rand", "serde"] }
|
||||||
59
testing/keys/src/main.rs
Normal file
59
testing/keys/src/main.rs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
use pkcs8::der::Decode;
|
||||||
|
use pkcs8::{EncryptedPrivateKeyInfo, PrivateKeyInfo};
|
||||||
|
use pkcs8::pkcs5::scrypt::Params;
|
||||||
|
use secp256k1::{Secp256k1, SecretKey};
|
||||||
|
use rand::{rng, RngCore};
|
||||||
|
//
|
||||||
|
// OID for secp256k1 curve
|
||||||
|
const SECP256K1_OID: pkcs8::ObjectIdentifier = pkcs8::ObjectIdentifier::new_unwrap("1.3.132.0.10");
|
||||||
|
|
||||||
|
fn generate_salt() -> [u8; 16] {
|
||||||
|
let mut salt = [0u8; 16];
|
||||||
|
rng().fill_bytes(&mut salt);
|
||||||
|
salt
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let secp = Secp256k1::new();
|
||||||
|
let (secret_key, public_key) = secp.generate_keypair(&mut rand::rng());
|
||||||
|
|
||||||
|
let password = "test";
|
||||||
|
|
||||||
|
let secret_bytes = &secret_key.secret_bytes();
|
||||||
|
let pk_info = PrivateKeyInfo::new(
|
||||||
|
pkcs8::AlgorithmIdentifierRef {
|
||||||
|
oid: SECP256K1_OID,
|
||||||
|
parameters: None,
|
||||||
|
},
|
||||||
|
secret_bytes
|
||||||
|
);
|
||||||
|
|
||||||
|
println!("private key length: {}", secret_bytes.len());
|
||||||
|
|
||||||
|
let salt = generate_salt();
|
||||||
|
|
||||||
|
let enc_priv = pk_info.encrypt_with_params(
|
||||||
|
pkcs8::pkcs5::pbes2::Parameters::scrypt_aes256cbc(
|
||||||
|
Params::new(15, 8, 1, secret_bytes.len()).unwrap(),
|
||||||
|
&salt,
|
||||||
|
&salt
|
||||||
|
).unwrap(),
|
||||||
|
password
|
||||||
|
).unwrap();
|
||||||
|
|
||||||
|
&enc_priv.write_der_file("./out.der").unwrap();
|
||||||
|
let buf = std::fs::read("./out.der").unwrap();
|
||||||
|
|
||||||
|
let enc_key = EncryptedPrivateKeyInfo::from_der(buf.as_slice()).unwrap();
|
||||||
|
let dec_doc = enc_key.decrypt(password.as_bytes()).unwrap();
|
||||||
|
let dec_key = PrivateKeyInfo::from_der(dec_doc.as_bytes()).unwrap();
|
||||||
|
|
||||||
|
dbg!(&dec_key);
|
||||||
|
|
||||||
|
let sec_key_bytes = dec_key.private_key;
|
||||||
|
let mut sec_key_bytes = [0u8; 32];
|
||||||
|
sec_key_bytes.copy_from_slice(dec_key.private_key);
|
||||||
|
let sec_key = SecretKey::from_byte_array(sec_key_bytes);
|
||||||
|
println!("original key: {:#?}", secret_key);
|
||||||
|
println!("decrypted key: {:#?}", sec_key);
|
||||||
|
}
|
||||||
BIN
testing/keys/src/out.der
Normal file
BIN
testing/keys/src/out.der
Normal file
Binary file not shown.
BIN
testing/keys/src/out.pem
Normal file
BIN
testing/keys/src/out.pem
Normal file
Binary file not shown.
1
testing/keys/target/.rustc_info.json
Normal file
1
testing/keys/target/.rustc_info.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"rustc_fingerprint":16432367459772410349,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/sgoinfre/vvobis/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\nfmt_debug=\"full\"\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"x87\"\ntarget_has_atomic\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"unknown\"\nub_checks\nunix\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.87.0-nightly (1aeb99d24 2025-03-19)\nbinary: rustc\ncommit-hash: 1aeb99d248e1b0069110cb03c6f1dcc7b36fd7f3\ncommit-date: 2025-03-19\nhost: x86_64-unknown-linux-gnu\nrelease: 1.87.0-nightly\nLLVM version: 20.1.0\n","stderr":""}},"successes":{}}
|
||||||
3
testing/keys/target/CACHEDIR.TAG
Normal file
3
testing/keys/target/CACHEDIR.TAG
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Signature: 8a477f597d28d172789f06886806bc55
|
||||||
|
# This file is a cache directory tag created by cargo.
|
||||||
|
# For information about cache directory tags see https://bford.info/cachedir/
|
||||||
0
testing/keys/target/debug/.cargo-lock
Normal file
0
testing/keys/target/debug/.cargo-lock
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
26d5e979ac12a827
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[]","declared_features":"[\"hazmat\", \"zeroize\"]","target":1651443328692853038,"profile":15657897354478470176,"path":4641415625551080286,"deps":[[7843059260364151289,"cfg_if",false,17961025459697583128],[7916416211798676886,"cipher",false,16789523336842748765],[17620084158052398167,"cpufeatures",false,7649894574007107543]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/aes-615b1486886526d4/dep-lib-aes","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
f4590533ed8b8bc5
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[]","declared_features":"[\"hazmat\", \"zeroize\"]","target":1651443328692853038,"profile":2241668132362809309,"path":4641415625551080286,"deps":[[7843059260364151289,"cfg_if",false,11776523789572572926],[7916416211798676886,"cipher",false,2069468555743037801],[17620084158052398167,"cpufeatures",false,9782894825656796161]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/aes-946f37f9c8e390a2/dep-lib-aes","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
7b806575f6bf8d83
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[]","declared_features":"[\"borsh\", \"default\", \"serde\", \"std\", \"zeroize\"]","target":12564975964323158710,"profile":2241668132362809309,"path":10058583505522926657,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/arrayvec-62de5feb621ca38e/dep-lib-arrayvec","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
d89d6e6618909fe5
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[]","declared_features":"[\"borsh\", \"default\", \"serde\", \"std\", \"zeroize\"]","target":12564975964323158710,"profile":15657897354478470176,"path":10058583505522926657,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/arrayvec-a5e92737053faea4/dep-lib-arrayvec","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
ce2a53394d10ec7e
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[\"alloc\", \"std\"]","declared_features":"[\"alloc\", \"default\", \"std\"]","target":5408242616063297496,"profile":2413078953500990702,"path":4814152696596951703,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/bitcoin-io-344f038bfeee2f7b/dep-build-script-build-script-build","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
100a3925ce7c525b
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[\"alloc\", \"std\"]","declared_features":"[\"alloc\", \"default\", \"std\"]","target":12235904672363824751,"profile":3703635419003940054,"path":5939156256663730406,"deps":[[3847559136816940884,"build_script_build",false,18147935058724338750]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/bitcoin-io-7d32dc964f7675d6/dep-lib-bitcoin_io","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
3e3c1fb6c86adafb
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"","declared_features":"","target":0,"profile":0,"path":0,"deps":[[3847559136816940884,"build_script_build",false,9145702867142912718]],"local":[{"Precalculated":"0.1.3"}],"rustflags":[],"config":0,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
3369c337bc5907ab
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[\"alloc\", \"std\"]","declared_features":"[\"alloc\", \"default\", \"std\"]","target":12235904672363824751,"profile":14982394140055827282,"path":5939156256663730406,"deps":[[3847559136816940884,"build_script_build",false,18147935058724338750]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/bitcoin-io-cf840446ce9290f6/dep-lib-bitcoin_io","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
2ae9430d54dab15a
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[\"alloc\", \"bitcoin-io\", \"std\"]","declared_features":"[\"alloc\", \"bitcoin-io\", \"default\", \"io\", \"schemars\", \"serde\", \"small-hash\", \"std\"]","target":2778122730832977837,"profile":15657897354478470176,"path":13728239418820424378,"deps":[[3847559136816940884,"bitcoin_io",false,6580459230371318288],[7827166758079505189,"hex",false,3227268973506987556]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/bitcoin_hashes-30cb1c50eb5d4a15/dep-lib-bitcoin_hashes","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
080eae2faced43e3
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[\"alloc\", \"bitcoin-io\", \"std\"]","declared_features":"[\"alloc\", \"bitcoin-io\", \"default\", \"io\", \"schemars\", \"serde\", \"small-hash\", \"std\"]","target":2778122730832977837,"profile":2241668132362809309,"path":13728239418820424378,"deps":[[3847559136816940884,"bitcoin_io",false,12323917570246928691],[7827166758079505189,"hex",false,14610954580339708839]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/bitcoin_hashes-6129c05409ac26b3/dep-lib-bitcoin_hashes","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
bceee8487b91355b
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[]","declared_features":"[]","target":4098124618827574291,"profile":15657897354478470176,"path":9633197536652568781,"deps":[[10520923840501062997,"generic_array",false,1583194012956149388]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/block-buffer-3633fdf76aafcf56/dep-lib-block_buffer","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
1ac2df3b3112ee6f
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[]","declared_features":"[]","target":4098124618827574291,"profile":2241668132362809309,"path":9633197536652568781,"deps":[[10520923840501062997,"generic_array",false,734384670163514112]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/block-buffer-ec44c28bd675a959/dep-lib-block_buffer","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
429f0591debedf60
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[]","declared_features":"[\"std\"]","target":6686848351246330659,"profile":2241668132362809309,"path":10402925075511192791,"deps":[[10520923840501062997,"generic_array",false,734384670163514112]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/block-padding-55b6d1c86c184ab8/dep-lib-block_padding","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
602965c5cbb3e512
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[]","declared_features":"[\"std\"]","target":6686848351246330659,"profile":15657897354478470176,"path":10402925075511192791,"deps":[[10520923840501062997,"generic_array",false,1583194012956149388]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/block-padding-9328120497585122/dep-lib-block_padding","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
d23467f4b32a1cbb
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[\"block-padding\", \"default\"]","declared_features":"[\"alloc\", \"block-padding\", \"default\", \"std\", \"zeroize\"]","target":5103841873489430697,"profile":15657897354478470176,"path":12135497908907267828,"deps":[[7916416211798676886,"cipher",false,16789523336842748765]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/cbc-7937670863a8f261/dep-lib-cbc","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
44e5678fe23d0d70
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[\"block-padding\", \"default\"]","declared_features":"[\"alloc\", \"block-padding\", \"default\", \"std\", \"zeroize\"]","target":5103841873489430697,"profile":2241668132362809309,"path":12135497908907267828,"deps":[[7916416211798676886,"cipher",false,2069468555743037801]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/cbc-c0be940744986596/dep-lib-cbc","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
4b0ce2cd925fef6f
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[]","declared_features":"[\"jobserver\", \"parallel\"]","target":11042037588551934598,"profile":4333757155065362140,"path":1758226852452067753,"deps":[[7929451307103596938,"find_msvc_tools",false,15727682873107389201],[8410525223747752176,"shlex",false,16653943046597496746]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/cc-01d3fd90d8c9e26a/dep-lib-cc","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
188405777e6142f9
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"rustc":9200240233716061564,"features":"[]","declared_features":"[\"core\", \"rustc-dep-of-std\"]","target":13840298032947503755,"profile":15657897354478470176,"path":9546138913560012481,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/cfg-if-37dbecc4e73cfb25/dep-lib-cfg_if","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0}
|
||||||
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This file has an mtime of when this was started.
|
||||||
@ -0,0 +1 @@
|
|||||||
|
fe0669eefd9d6ea3
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user