firstfloorsoftware / flutter_sodium

Flutter bindings for libsodium
BSD 3-Clause "New" or "Revised" License
102 stars 46 forks source link

cryptoBoxSeal not returning anything. #3

Closed pneves001 closed 5 years ago

pneves001 commented 5 years ago

This is a bit of a strange issue. I'm not getting an error, or any kind of response from the function what so ever. It just does nothing. The following code is what I'm using to call the function. The execution just stops when the function is called although my flutter app continues to operate.

var encoder = new JsonEncoder();

var jsonencoded = encoder.convert(data);

var jsonBeforeSeal = utf8.encode(jsonencoded);

        print("Data before seal.");
        print(jsonBeforeSeal);

        print("Public Key");
        print(_publicKey);

        Uint8List response = await Sodium.cryptoBoxSeal(jsonBeforeSeal, utf8.encode(_publicKey));

The public key is returned from my server in hex format and worked in my ionic version of my app.

kozw commented 5 years ago

Interesting, Android or iOS, or both?

pneves001 commented 5 years ago

I haven't tried ios. So right now android. But I will let you know about IOS.

pneves001 commented 5 years ago

I can confirm I get the exact same result in both. Although to get the IOS version to compile I had to add the following line to the podfile:

use_frameworks!

I'm using a newer version of swift 3.2 so when I put the following line in it didn't compile: config.build_settings['SWIFT_VERSION'] = '3.2'

But the behavior is the same in both IOS and Android at this time.

pneves001 commented 5 years ago

I also tried using the .then function and even the .catchError and the result was the same. So its not even generating an error.

pneves001 commented 5 years ago

I have been looking into this issue a bit because it's a bit of a show stopper for me. I really need to get this package working. More specifically when comparing this package with the cordova-plugin-minisodium package for cordova. The two packages are similar. The cordova plugin has both the libsodium-jni project and the libsodium project as dependencies.

As far as I can tell. The flutter_sodium plugin is not installing libsodiumjni at all or the libsodium library. I can't find it anywhere in my build tree. Nor do I find it in my .pub-cache folder. As far as I can tell its not there. I think this might be the source of my problem. Although I've been trying to fix it manually however, I'm still quite new to flutter.

kozw commented 5 years ago

I'm not sure the libsodium dependency is required for Android. For iOS the binary is included. I'm running both Android and iOS, and both work fine.

Are you running in an emulator or an actual device? Have you tried running the example app that is included in GitHub?

kozw commented 5 years ago

Looking at your code snippet: you're doing an utf8.encode on a string in hex-format. You probably do want to do hex.decode (instead of utf8.encode). Also, make sure you pubkey consists of 32 bytes.

pneves001 commented 5 years ago

Thank you. I will try this. I am currently running it on an actual device with the latest version of Android.

pneves001 commented 5 years ago

Thank you this worked. I have it working now.