react-native-quick-crypto icon indicating copy to clipboard operation
react-native-quick-crypto copied to clipboard

🐛 Ed generateKeyPair missing return for Promise?

Open xgiovio opened this issue 1 year ago • 1 comments

What's happening?

On https://github.com/margelo/react-native-quick-crypto/blob/main/packages/react-native-quick-crypto/src/ed.ts Is return Promise missing on line 19?

Reproducible Code

var ed1 = new Ed('ed25519', {});
    var p = await ed1.generateKeyPair();
    const priv = ed1.getPrivateKey();

    console.log(priv);

Relevant log output

[Error: EdKeyPair.getPrivateKey(...): Keypair not initialized]

Device

ios real device, latest ios, xcode and expo

QuickCrypto Version

  1. beta 9

Can you reproduce this issue in the QuickCrypto Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

xgiovio avatar Jan 20 '25 14:01 xgiovio

@xgiovio I'm not sure why you got that error in the getPrivateKey() result, but Ed.generateKeyPair() has the return type of Promise<void>, meaning it will not return anything once resolved. The keys are stored in the class. You can get them via getPublicKey() and getPrivateKey(), as your code does. The tests are passing for all versions of 1.0.0-beta.x, so this might be a local issue.

boorad avatar Jun 24 '25 16:06 boorad