Skip to content
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

Generating wallet on web hangs #30

Open
elliotsayes opened this issue Jul 5, 2022 · 4 comments
Open

Generating wallet on web hangs #30

elliotsayes opened this issue Jul 5, 2022 · 4 comments
Labels
Under asessment We are assessing this issue

Comments

@elliotsayes
Copy link

elliotsayes commented Jul 5, 2022

Calling Wallet.generate() when compiled for web seems to never complete.

To reproduce:

  1. create test/wallets_test.html:
<!DOCTYPE html>
<html>
  <head>
    <title>Wallets Test</title>
    <script src="js/avsc.min.js"></script>
    <script src="js/tagparser.js"></script>
    <link rel="x-dart-test" href="wallets_test.dart" />
    <script defer src="packages/test/dart.js"></script>
  </head>
  <body>
    // ...
  </body>
</html>
  1. run dart test test/wallets_test.dart -N "generate wallet" --platform chrome
  2. observe output never completes: 01:17 +0: wallets: generate wallet
@elliotsayes
Copy link
Author

Root issue appears to be from pointycastle library
final pair = keyGen.generateKeyPair();
bcgit/pc-dart#113

@elliotsayes
Copy link
Author

elliotsayes commented Jul 6, 2022

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));

@agsuy agsuy added the Under asessment We are assessing this issue label Jul 7, 2022
@karlprieb
Copy link
Collaborator

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.

@elliotsayes
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Under asessment We are assessing this issue
Projects
None yet
Development

No branches or pull requests

3 participants