konstantinullrich / crypton

A simple Dart library for asymmetric encryption and digital signatures
https://pub.dev/packages/crypton
MIT License
34 stars 12 forks source link

Building for web fails with javascript compilation errors #27

Closed mattmaddux closed 3 years ago

mattmaddux commented 3 years ago

I'm able to build for other platforms just fine, but when attempting to build for the web it throws the following errors.

Launching lib/main.dart on Chrome in debug mode...
lib/main.dart:1
../../flutter/.pub-cache/hosted/pub.dartlang.org/pointycastle-3.1.3/lib/key_derivators/argon2.dart:42:27: Error: The integer literal 0xFFFFFFFFFFFFFFFF can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in Javascript. In Javascript 0x10000000000000000 is the nearest value that can be represented exactly.
  static const int M32L = 0xFFFFFFFFFFFFFFFF;
                          ^^^^^^^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/pointycastle-3.1.3/lib/src/utils.dart:313:9: Error: The integer literal 0xFFFFFFFFFFFFFFFF can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in Javascript. In Javascript 0x10000000000000000 is the nearest value that can be represented exactly.
      ((0xFFFFFFFFFFFFFFFF) ^ ((1 << (64 - count)) - 1));
        ^^^^^^^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/pointycastle-3.1.3/lib/src/platform_check/platform_check.dart:6:35: Error: Method not found: 'getPlatform'.
  static Platform get instance => getPlatform();
                                  ^^^^^^^^^^^
Failed to compile application.
Exited (sigterm)
mattmaddux commented 3 years ago

Seems like all the fixes need to happen at the pointcastle repo. I've opened an issue there. Should I close this or keep it open until it's fixed there?

AKushWarrior commented 3 years ago

Worth mentioning that this library can temporarily depend on a version of pointycastle which doesn't have this regression, because crypton doesn't use Argon2. That would be (I think) 3.1.0, but you can check the changelog - whatever is before the Argon2 update will work.

mattmaddux commented 3 years ago

Yes, you're right. 3.1.1 actually works fine. Created a simple PR that just sets the dependency in pubspec.yaml to 3.1.1.