input-output-hk / cardano-js-sdk

JavaScript SDK for interacting with Cardano, providing various key management options, with support for popular hardware wallets
https://input-output-hk.github.io/cardano-js-sdk/
Apache License 2.0
214 stars 58 forks source link

remove the use of await sodium.ready #1529

Open jinglescode opened 2 days ago

jinglescode commented 2 days ago

Describe the feature you'd like

To make keys functions non-async.

Rewrite packages/crypto/src/Bip32/Bip32PrivateKey.ts and packages/crypto/src/Bip32/Bip32PublicKey.ts to remove async when derive(derivationIndices: number[]): Bip32PublicKey and toPublic(): Bip32PublicKey

Describe alternatives you've considered

mkazlauskas commented 2 days ago

Hey @jinglescode, would we require consumer to await it separately/globally then, or do you have some other ideas?

jinglescode commented 2 days ago

if reference strica and harmonic implementation as reference, and dont use libsodium lib, might be able to remove async await entirely. i cannot be 100% sure, about this, @ashisherc for sense check.

ashisherc commented 2 days ago

@mkazlauskas The existing approach seems due to the way sodium functions. To clarify @jinglescode suggestion, he is advocating for a pure JavaScript library that doesn’t rely on async code for derivation. One example of this type of implementation is here: https://github.com/StricaHQ/bip32ed25519. Just sharing this as an example to help illustrate Jingles’ point.

AngelCastilloB commented 2 days ago

Thanks for the report guys, we will look into this. We should be able to remove the async from these functions