PointyCastle / pointycastle

Moved into the Bouncy Castle project: https://github.com/bcgit/pc-dart
MIT License
270 stars 76 forks source link

Pointycastle broken with new flutter version #116

Open ctnguyen opened 6 years ago

ctnguyen commented 6 years ago

Recently update flutter and I cannot get pointycastle working.

Step to reproduce :

my flutter --version

Flutter 0.0.25-pre.5 • channel dev • https://github.com/flutter/flutter.git
Framework • revision 4ae1b5f415 (5 days ago) • 2018-02-07 15:18:04 -0800
Engine • revision 9bc2efdf47
Tools • Dart 2.0.0-dev.19.0
hemanthrajv commented 6 years ago

+1

stevenroose commented 6 years ago

What I'm confused about is that Dart 2 doesn't seem to be out yet, but Flutter is already using it.

Ah, you're using the flutter dev channel? Hmm, I'll try to get Dart 2 setup coming weekend, see what error Pointy Castle has and try to fix them. Should be doable.

ctnguyen commented 6 years ago

That was my point as well, not really sure why flutter decide to use Dart 2. But recently flutter has changed the branching strategy, so alpha channel doesn't exist anymore. The best way to reproduce is to remove the existing flutter, and reclone it. It will checkout the newest flutter, defaulted to dev channel, with all the related configuration ( Dart 2 ). Thanks Steven

faboweb commented 6 years ago

+1

hemanthrajv commented 6 years ago

+1

On Thu 22 Mar, 2018, 2:32 PM Fabian, notifications@github.com wrote:

+1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PointyCastle/pointycastle/issues/116#issuecomment-375224862, or mute the thread https://github.com/notifications/unsubscribe-auth/ATepHWunF_a2im8xfYTDRpVe7gxmzGtJks5tg2iwgaJpZM4SCOxS .

stevenroose commented 6 years ago

This should have been fixed some months ago in v0.11.1. See the README.

stevenroose commented 6 years ago

Oh, that's for usage of mirrors. Not about Dart 2. I'll have to look into Dart 2 as well.

faboweb commented 6 years ago

Thank you for your quick response.

faboweb commented 6 years ago

Did you have a chance to lock at the issue yet?

stevenroose commented 6 years ago

I just merged a PR that solves the strong mode issues by @kaendfinger (thanks a lot,btw!), and I'm working on migrating to BigInt because Dart 2.0 seems to break BigInteger functions.

faboweb commented 6 years ago

Thanks for the effort

ctnguyen commented 6 years ago

Thanks a lot for your time.

stevenroose commented 6 years ago

Can you check if this is solved with the new v1.0.0-rc1 release?

ctnguyen commented 6 years ago

Thank you, I'll try to test with my code this weekend.

ctnguyen commented 6 years ago

Hi, I tried to download the pointycastle source code and test it by creating a flutter project. I go inside, run

flutter packages get

And when I run the test in pointycastle/test/stream/salsa20_test.dart, I got the error below :

E/flutter (32662): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception: E/flutter (32662): Bad state: Reflectable has not been initialized. Did you forget to add the main file to the reflectable transformer's entry_points in pubspec.yaml? E/flutter (32662): #0 data (package:reflectable/src/reflectable_transformer_based.dart:173:5) E/flutter (32662): #1 data (package:reflectable/src/reflectable_transformer_based.dart:172:33) E/flutter (32662): #2 ReflectableImpl.annotatedClasses (package:reflectable/src/reflectable_transformer_based.dart:2460:47) E/flutter (32662): #3 _ReflectableFactoryRegistryImpl.initialize (package:pointycastle/src/registry/registry_reflectable.dart:106:41) E/flutter (32662): #4 _ReflectableFactoryRegistryImpl._checkInit (package:pointycastle/src/registry/registry_reflectable.dart:101:7) E/flutter (32662): #5 _ReflectableFactoryRegistryImpl.createConstructor (package:pointycastle/src/registry/registry_reflectable.dart:78:5) E/flutter (32662): #6 _ReflectableFactoryRegistryImpl.getConstructor (package:pointycastle/src/registry/registry_reflectable.dart:67:21) E/flutter (32662): #7 _ReflectableFactoryRegistryImpl.create (package:pointycastle/src/registry/registry_reflectable.dart:59:42) E/flutter (32662): #8 new StreamCipher (file:///C:/pointycastle/lib/src/api/stream_cipher.dart:13:16) E/flutter (32662): #9 main (file:///C:/pointycastle/test/stream/salsa20_test.dart:22:29) E/flutter (32662): #10 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:279:19) E/flutter (32662): #11 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)

Sounds like something bad with Reflectable. Do you have any quick idea how to solve it?

stevenroose commented 6 years ago

@ctnguyen yeah to run tests, you can only run all tests. I think pub run test should work or dart test/all_tests_web.dart. I'm thinking about removing the whole reflectable shenanigan though. It worked great with mirrors, but since the Dart team started banning mirrors everywhere, the need for reflectable made UX horrible.

ctnguyen commented 6 years ago

Hi, also I try to create a single test in my project, with a simple call

var cipher = new StreamCipher( "Salsa20" );

I still have issue with Reflectable

I/flutter ( 1305): Bad state: Reflectable has not been initialized. Did you forget to add the main file to the reflectable transformer's entry_points in pubspec.yaml? I/flutter ( 1305): package:reflectable/src/reflectable_transformer_based.dart 173:5 data I/flutter ( 1305): package:reflectable/src/reflectable_transformer_based.dart 172:33 data I/flutter ( 1305): package:reflectable/src/reflectable_transformer_based.dart 2460:47 ReflectableImpl.annotatedClasses I/flutter ( 1305): package:pointycastle/src/registry/registry_reflectable.dart 106:41 _ReflectableFactoryRegistryImpl.initialize I/flutter ( 1305): package:pointycastle/src/registry/registry_reflectable.dart 101:7 _ReflectableFactoryRegistryImpl._checkInit I/flutter ( 1305): package:pointycastle/src/registry/registry_reflectable.dart 78:5 _ReflectableFactoryRegistryImpl.createConstructor I/flutter ( 1305): package:pointycastle/src/registry/registry_reflectable.d I/flutter ( 1305): 00:19 +0 -1: Some tests failed. I/flutter ( 1305): E/flutter ( 1305): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception: E/flutter ( 1305): Dummy exception to set exit code. E/flutter ( 1305): #0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1114:29) E/flutter ( 1305): #1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21) E/flutter ( 1305): #2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

Do you have any idea?

stevenroose commented 6 years ago

I have no idea about that, I'm sorry. It seems like reflectable is not working anymore in Flutter.

What you can always do to avoid using reflectable is to import the Salsa20 class directly:

import "package:pointycastle/stream/salsa20.dart";

void main() {
    var s20 = new Salsa20Engine();
}

You can find more info about using PointyCastle like that here: https://github.com/PointyCastle/pointycastle#without-the-registry

ctnguyen commented 6 years ago

Thanks a lot, it solve my concern since I used only Salsa20.

shaxxx commented 5 years ago

Any progress on this? Thanks!

yshrsmz commented 5 years ago

you can use rc version

stevenroose commented 5 years ago

I think I can publish 1.0.0 stable by now. Didn't hear about any problems with rc4. Will do tomorrow!

On Mon, Dec 17, 2018, 00:19 Yasuhiro Shimizu notifications@github.com wrote:

you can use rc version

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PointyCastle/pointycastle/issues/116#issuecomment-447686011, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0F3GVCLu-cKxo6yMaXKqWytZKak0wFks5u5tUNgaJpZM4SCOxS .