-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Diffie-Hellman key exchange to Account (#809)
* add key_exchange, encrypt_data, decrypt_data to storage and account * add bindings and rust example * add bindings example * Add key_exchange, encrypt_data, decrypt_data to memstore, change encrypt/decrypt data signature * Add nonce to EncryptedData * Add associated data into EncryptedData * remove key_exchange from storage, remove encryption_key type, add algorithm encryption, move key_exchange to encrypt/decrypt functions * remove unnecessary into * Generate random shared secret location * Remove generic crypto error * Add crypto::error::Error as source for new errors * Add encryption option - with cek enum * Add EncryptionOptions to bindings and to memstore * Make PublicKey mandatory in the storage trait, return an error when using a ED25519 key for encryption/decryption * Doc/resolve (#823) * Upgrade to new `Stronghold` interface (#787) * Rename stronghold module * Postfix old stronghold with `_old` * Migrate to new stronghold interface * Impl did_create properly with client syncing * Add context to `StrongholdError`s * Add `Stronghold` wrapper test * Add `test_key_delete` * Add storage_test_suite setup & did_create test * Re-export test suite feature * Expose test suite in Wasm * Extend `did_create` test, fix index persistence * Test `key_generate` * Move `key_delete` to test suite * Remove test suite from this branch * Add initial test suite and expose to Wasm * rm `Error` postfix from `StrongholdError` variants * Remove duplicate `mod tests` in Wasm * Handle client sync error; document syncing * Use updated stronghold * Use dedicated `load_snapshot` function * Purge client in `did_purge` * Revert cfg_attr shenanigans * Make `Stronghold::client` not async * Remove asyncness from fns where not necessary * Make `mutate_client` not async either * Move test_util mod where it belongs * Remove `source` errors from `Display` impl * Remove `RecordHint` everywhere * Use base crate `MemoryError`; remove engine dep * Revert temporary send/sync change * Document `Stronghold` wrapper * Use same export style as other crates * Create parent directories if they don't exist * Remove outdated TODO * Fix index writing in purge; update stronghold rev * Remove old stronghold wrapper * Reactivate multi identity example * Add `dropsave` getter/setter * Fully qualify `std::any::type_name` * Remove tests which are already in test suite * Reactivate `Send`-assertion test * Return `Stronghold` instance from test `storages` * Test incorrect password returns error * Use `OsRng` instead of `thread_rng` * Bump stronghold revision * Remove unused `getrandom` depenency * Remove unused `actix` dependency * Remove tokio `rt-multi-thread` feature * Prefer `sample_string` over `sample_iter` * Enable `didPurge` test for NAPI stronghold * Simplify `did_create` by using `mutate_client` * Rename doc/state client paths to store keys * Add procedure_error fn to reduce err map code * Remove unnecessary clone * Disable multiple identities example temporarily * Disable musl build * Remove musl target from stronghold-nodejs * use local workflow file * Revert "use local workflow file" This reverts commit 2f12afd. Co-authored-by: Eike Haß <eike-hass@web.de> * add concat_kdf procedure * add concat kdf for memstore * rename Cekalgorithm struct; remove error variant; add constructor to bindings new function * Improve error msg; Add feature to cargo toml; Replace client for resolver * Add ephemeral key for ECDH-ES * Add test for stronghold encryption; Fix rust example; Add feature for account encryption; Improve docs * Sync comments for traits, account, and wasm * Improve docs; Fix Memstore cocat kdf; Remove EncryptionOptions * Add test for storage test suite; Fix padding in Memstore * Rename outdated file * Add exception for encryption methods in MemStore * Fix naming in javascript; Switch back to ThreadRng * Remove useless variable * Improve docs; Make EncryptedData fields pub * Fix readme * Undo removal of files * Fix function call Co-authored-by: Eike Haß <eike-hass@web.de> Co-authored-by: Oliver E. Anderson <oliver.anderson@iota.org> Co-authored-by: Philipp <philipp.gackstatter@iota.org>
- Loading branch information
1 parent
fb1948a
commit 9176761
Showing
44 changed files
with
1,997 additions
and
161 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { encryption } from "../../../../wasm/examples-account/src/encryption"; | ||
import { stronghold } from '../stronghold'; | ||
|
||
// Only verifies that no uncaught exceptions are thrown, including syntax errors etc. | ||
describe("Test Stronghold Node.js examples", function () { | ||
it("encryption", async () => { | ||
await encryption(await stronghold()); | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
bindings/stronghold-nodejs/src/account/types/cek_algorithm.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2020-2022 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use identity_account_storage::types::CekAlgorithm; | ||
use napi::Result; | ||
use napi_derive::napi; | ||
|
||
use crate::error::NapiResult; | ||
|
||
#[napi] | ||
pub struct NapiCekAlgorithm(pub(crate) CekAlgorithm); | ||
|
||
#[napi] | ||
impl NapiCekAlgorithm { | ||
#[napi(js_name = fromJSON)] | ||
pub fn from_json(json_value: serde_json::Value) -> Result<NapiCekAlgorithm> { | ||
serde_json::from_value(json_value).map(Self).napi_result() | ||
} | ||
|
||
#[napi(js_name = toJSON)] | ||
pub fn to_json(&self) -> Result<serde_json::Value> { | ||
serde_json::to_value(&self.0).napi_result() | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
bindings/stronghold-nodejs/src/account/types/encrypted_data.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2020-2022 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use identity_account_storage::types::EncryptedData; | ||
use napi::Result; | ||
use napi_derive::napi; | ||
|
||
use crate::error::NapiResult; | ||
|
||
#[napi] | ||
pub struct NapiEncryptedData(pub(crate) EncryptedData); | ||
|
||
#[napi] | ||
impl NapiEncryptedData { | ||
#[napi(js_name = fromJSON)] | ||
pub fn from_json(json_value: serde_json::Value) -> Result<NapiEncryptedData> { | ||
serde_json::from_value(json_value).map(Self).napi_result() | ||
} | ||
|
||
#[napi(js_name = toJSON)] | ||
pub fn to_json(&self) -> Result<serde_json::Value> { | ||
serde_json::to_value(&self.0).napi_result() | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
bindings/stronghold-nodejs/src/account/types/encryption_algorithm.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2020-2022 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use identity_account_storage::types::EncryptionAlgorithm; | ||
use napi::Result; | ||
use napi_derive::napi; | ||
|
||
use crate::error::NapiResult; | ||
|
||
#[napi] | ||
pub struct NapiEncryptionAlgorithm(pub(crate) EncryptionAlgorithm); | ||
|
||
#[napi] | ||
impl NapiEncryptionAlgorithm { | ||
#[napi(js_name = fromJSON)] | ||
pub fn from_json(json_value: serde_json::Value) -> Result<NapiEncryptionAlgorithm> { | ||
serde_json::from_value(json_value).map(Self).napi_result() | ||
} | ||
|
||
#[napi(js_name = toJSON)] | ||
pub fn to_json(&self) -> Result<serde_json::Value> { | ||
serde_json::to_value(&self.0).napi_result() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
// Copyright 2020-2022 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pub use cek_algorithm::NapiCekAlgorithm; | ||
pub use encrypted_data::NapiEncryptedData; | ||
pub use encryption_algorithm::NapiEncryptionAlgorithm; | ||
pub use key_location::NapiKeyLocation; | ||
pub use key_type::NapiKeyType; | ||
pub use signature::NapiSignature; | ||
|
||
mod cek_algorithm; | ||
mod encrypted_data; | ||
mod encryption_algorithm; | ||
mod key_location; | ||
mod key_type; | ||
mod signature; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.