Skip to content

Commit

Permalink
Use iota-crypto aead helpers (#1194)
Browse files Browse the repository at this point in the history
* Use iota-crypto aead helpers

* CHANGELOG entries

* Fix encryption/decryption

* Use new crypto version
  • Loading branch information
thibault-martinez authored Aug 22, 2022
1 parent 4898263 commit 0b7c7ef
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 75 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rename `finish_single_thread_pow` to `finish_single_threaded_pow`;
- Rename `minimum_storage_deposit` to `minimum_storage_deposit_basic_output`;
- Accept `GenerateAddressesOptions` in `consolidate_funds()` instead of `account_index` and `address_range`;
- Use `chacha::{aead_encrypt, aead_decrypt}` from `crypto.rs` in stronghold's `db` module;

### Removed

- Removed `snapshot_loaded` field from StrongholdAdapter;
- Removed `outputs()` field from GetAddressBuilder;
- Stronghold's `encryption` module;

### Fixed

Expand Down
15 changes: 13 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bee-block = { version = "1.0.0-beta.6", default-features = false, features = [ "
bee-pow = { version = "1.0.0-alpha.1", default-features = false }
derive_builder = { version = "0.11.2", default-features = false, features = [ "std" ]}
futures = { version = "0.3.21", default-features = false, features = [ "thread-pool" ] }
iota-crypto = { version = "0.13.0", default-features = false, features = [ "std", "chacha", "blake2b", "ed25519", "random", "slip10", "bip39", "bip39-en" ] }
iota-crypto = { version = "0.14.0", default-features = false, features = [ "std", "chacha", "blake2b", "ed25519", "random", "slip10", "bip39", "bip39-en" ] }
log = { version = "0.4.17", default-features = false }
num_cpus = { version = "1.13.1", default-features = false }
packable = { version = "0.5.0", default-features = false, features = [ "serde", "primitive-types", "std" ] }
Expand Down
11 changes: 4 additions & 7 deletions src/stronghold/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
use std::ops::Deref;

use async_trait::async_trait;
use crypto::ciphers::chacha;

use super::{
common::PRIVATE_DATA_CLIENT_PATH,
encryption::{decrypt, encrypt},
StrongholdAdapter,
};
use super::{common::PRIVATE_DATA_CLIENT_PATH, StrongholdAdapter};
use crate::{db::DatabaseProvider, Error, Result};

#[async_trait]
Expand All @@ -38,7 +35,7 @@ impl DatabaseProvider for StrongholdAdapter {
let buffer = key_provider.try_unlock()?;
let buffer_ref = buffer.borrow();

decrypt(&data, buffer_ref.deref()).map(Some)
Ok(Some(chacha::aead_decrypt(buffer_ref.deref(), &data)?))
}

async fn insert(&mut self, k: &[u8], v: &[u8]) -> Result<Option<Vec<u8>>> {
Expand All @@ -52,7 +49,7 @@ impl DatabaseProvider for StrongholdAdapter {
let buffer = key_provider.try_unlock()?;
let buffer_ref = buffer.borrow();

encrypt(v, buffer_ref.deref())?
chacha::aead_encrypt(buffer_ref.deref(), v)?
};

Ok(self
Expand Down
64 changes: 0 additions & 64 deletions src/stronghold/encryption.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/stronghold/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
mod common;
mod db;
mod encryption;
mod secret;

use std::{
Expand Down

0 comments on commit 0b7c7ef

Please sign in to comment.