Closed s8sato closed 1 year ago
Hah, TypeScript tried to prevent the error!
The bug is here:
const config = new (crypto as any).KeyGenConfiguration()
.useSeed(Uint8Array.from(SEED_BYTES))
.withAlgorithm(keyAlgo);
You cannot create underlying crypto classes directly via constructors, and @iroha2/crypto-core
declares it. That is why you can see (crypto as any)
here.
- const config = new (crypto as any).KeyGenConfiguration()
+ const config = crypto.createKeyGenConfiguration()
.useSeed(Uint8Array.from(SEED_BYTES))
.withAlgorithm(keyAlgo);
new KeyGenConfiguration()
?Implementation details I tried to hide behind TypeScript declarations.
https://github.com/hyperledger/iroha-javascript/pull/69#issue-963187691 (start from "Don't forget to free()
crypto structures!")
This might be rather a Q&A issue than a bug reporting.
Steps to Reproduce
Clone the reporting repository https://github.com/outSH/iroha2_check/tree/7e148419ae1d886a1f41b045bcc4dda1e379bfff and
Expected Behavior
The script, which is trying to utilize
generateKeyPairWithConfiguration
, successfully runsActual Behavior
As described in the script https://github.com/outSH/iroha2_check/blob/7e148419ae1d886a1f41b045bcc4dda1e379bfff/generate-key.ts
Possible Causes
Possible Solution