-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Diffie-Hellman key exchange for encryption to Account
#809
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preliminary review: I think we need to remove key_exchange
(from the Storage
interface) and move the Diffie-Hellman operation into the encrypt/decrypt functions. We also need to be more explicit about which encryption algorithm is to be used in both Account
and Storage
. Lastly, we need to support the A256KW key wrapping algorithm for ECDH-1PU required by DIDComm.
See:
…orithm encryption, move key_exchange to encrypt/decrypt functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how useful this is until we get support for key wrapping and key concatenation in Stronghold:
- [Request] Support AES key wrapping stronghold.rs#338
- [Request] Add a procedure to concatenate secrets stronghold.rs#339
We can only really support ECDH-ES
with no key wrapping right now.
Supporting a pre-generated keypair (as an
Agreed. |
@@ -4,6 +4,7 @@ import { stronghold } from '../stronghold'; | |||
// Only verifies that no uncaught exceptions are thrown, including syntax errors etc. | |||
describe("Test Stronghold Node.js examples", function () { | |||
it("Multiple Identities", async () => { | |||
await multipleIdentities(await stronghold()); | |||
// TODO: Temporarily disabled until iotaledger/stronghold.rs#353 is fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be okay again after a merging dev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, it's disabled on dev
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And it will be for a while, it looks like 😕: iotaledger/stronghold.rs#353 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use an async RwLock
over the Stronghold storage implementation to prevent this bug in the meantime then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can, but this issue is supposed to be prioritized now, so perhaps @felsweg-iota can give an update on the current status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current problem with the implementation of the standard interface to Stronghold is, that it internally uses a std::sync::RwLock, since every function in the interface isn't supposed to be async
. This actually brings in a problem while working with async
code.
There are two solutions to this, and i am just naming them here for reference, @PhilippGackstatter already pointed out the link to the issue:
- we either change the current standard library locking mechanism to their
async
counterparts, which will effectively change the interface to operate as pseudo-async
, - the STM based approach will be finalized and will replace all existing locks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer if we try the RwLock
solution in our code to fix it temporarily (if that works), and that could avoid you having to do temporary work if the STM will eventually be the proper solution.
…bindings new function
… account encryption; Improve docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good. The MemStore
modifications need some changes. Other than that mostly quality of life stuff, docs, typos, etc. To solve the tuple problem in Wasm, I think you can just make the ephemeral public key part of EncryptedData
.
Not sure about the naming, i.e. EcdhEs
vs. ECDH_ES
, but if it's not too much work to change, I'd prefer the latter, and we can just follow JWA naming in the future, preventing further naming debates 😛.
Edit: Extending the StorageTestSuite
is probably the most important outstanding part so both MemStore
and Stronghold
are tested, ideally in Rust and Wasm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks for addressing all the previous comments so thoroughly!
A few more minor comments.
One more thing: The I'm fine with not implementing the encryption functions for the TS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see how far this PR has come.
Most issues have already been addressed, minor comments.
identity-account-storage/src/types/encryption/encrypted_data.rs
Outdated
Show resolved
Hide resolved
Account
Description of change
Add Diffie-Hellman key exchange to Account
Links to any relevant issues
closes #756
Type of change
How the change has been tested
New key_exchange example.
Change checklist