Open elliotsayes opened 2 years ago
Root issue appears to be from pointycastle library
final pair = keyGen.generateKeyPair();
https://github.com/bcgit/pc-dart/issues/113
Workaround: use fast_rsa package to generate the keys, then load using Wallet.fromJwk()
. Becausefast_rsa
is a flutter package (for web it uses wasm under the hood) it cannot be used in arweave-dart
directly. Still it takes ~30 seconds on average, much slower than ~1s for native dart, but comparable to arweave.app
Example usage:
final wallet = await RSA.generate(keyLength)
.then((kp) => RSA.convertPrivateKeyToJWK(kp.privateKey))
.then((jwk) => Wallet.fromJwk(jwk));
Hi @elliotsayes thank you for your report!
We did some tests and conclude the same as you. We tested with a simple Flutter Web project and we could generate a wallet, but it took more than 10 minutes having frozen UI. We also tested fast_rsa
and it works perfectly :)
Our approach to this issue will be to create an interface to abstract the wallet generation.
We want to keep using pointycastle
for pure Dart projects and implement fast_rsa
for Flutter projects.
As we don't have this feature on ArDrive Web we will not work on this fix for now, but it's on our roadmap and when the time comes we will release this implementation.
Hi @karlprieb that makes sense to me. What I don't understand though is why dart does not support plugins (i.e. js on web) without flutter SDK... seems like they want to tie you to flutter if you are using dart libraries
Calling
Wallet.generate()
when compiled for web seems to never complete.To reproduce:
test/wallets_test.html
:dart test test/wallets_test.dart -N "generate wallet" --platform chrome
01:17 +0: wallets: generate wallet