Skip to content

Commit 38cd0d2

Browse files
committed
[wallet] encrypt/decrypt mnemonic using AES-128-CBC with SHA256 HMAC
1 parent 6e93db7 commit 38cd0d2

File tree

7 files changed

+331
-18
lines changed

7 files changed

+331
-18
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ target/
1818
#.idea/
1919

2020
devbox.json
21-
devbox.lock
21+
devbox.lock
22+
.vscode

Cargo.lock

+158
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,10 @@ edition = "2021"
55

66
[dependencies]
77
bip39 = "2.1.0"
8+
cbc = {version = "0.1.2", features = ["std"]}
9+
pbkdf2 = "0.12.2"
810
rand = "0.8.5"
11+
sha2 = "0.10.8"
12+
aes = "0.8.4"
13+
hmac = "0.12.1"
14+
hex = "0.4.3"

src/network/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[derive(PartialEq, Eq)]
1+
#[derive(PartialEq, Eq, Clone)]
22
pub enum NetworkKind {
33
Mainnet,
44
Testnet,
@@ -15,6 +15,7 @@ impl NetworkKind {
1515
}
1616
}
1717

18+
#[derive(Clone)]
1819
pub struct Network {
1920
pub kind: NetworkKind,
2021
pub url: String,

src/transactions/constants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl TransactionVersion {
1313
}
1414
}
1515

16-
pub fn from_network(network: NetworkKind) -> Self {
16+
pub fn from_network(network: &NetworkKind) -> Self {
1717
return match network {
1818
NetworkKind::Mainnet => Self::Mainnet,
1919
NetworkKind::Testnet => Self::Testnet,

src/transactions/tx.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum Payload {
1212
}
1313

1414
pub trait TransactionSerialization {
15-
fn serialize(&self) -> [u8];
15+
fn serialize(&self) -> Vec<u8>;
1616
}
1717

1818
pub struct StacksTransaction {
@@ -24,7 +24,7 @@ pub struct StacksTransaction {
2424
}
2525

2626
impl TransactionSerialization for StacksTransaction {
27-
fn serialize(&self) -> [u8] {}
27+
fn serialize(&self) -> Vec<u8> { vec![] }
2828
}
2929

3030
pub fn build_token_transfer_transaction(
@@ -42,8 +42,8 @@ pub fn build_token_transfer_transaction(
4242
memo: memo,
4343
recipient: recipient,
4444
}),
45-
network: network,
45+
network: network.clone(),
4646
post_condition_mode: PostConditionMode::Deny,
47-
version: TransactionVersion::from_network(network.kind),
47+
version: TransactionVersion::from_network(&network.kind),
4848
}
4949
}

0 commit comments

Comments
 (0)