Git Product home page Git Product logo

Comments (8)

Jay-Tezsure avatar Jay-Tezsure commented on August 11, 2024 1

Thanks for the quick reply @Skycoder42 , This resolved my issue

from libsodium_dart_bindings.

Jay-Tezsure avatar Jay-Tezsure commented on August 11, 2024 1

Thanks for your help @Skycoder42 ,
It worked for sodium sumo too after replacing package:sodium/sodium.dart with package:sodium/sodium_sumo.dart

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 11, 2024

Hi. These methods are indeed implemented in the packages. However, the are part of the "Sumo" variant, as those APIs are not available in the standard sodium.js bindings. However, when working with the dart-vm, they are always available. Here are some docs you can read more about that:

Currently, the dart APIs only allow you to access the default implementations/algorithms of the different cryptographic concepts. However, the naming closely follows the official names. In your example, after loading the sumo variant of sodium, you can access the crypto_sign_ed25519_sk_to_seed method as follows:

final sodium = await SodiumSumoInit.init();
// ...
final seed = sodium.crypto.sign.skToSeed(secureKey)

The ed25519 part is omitted.

from libsodium_dart_bindings.

Jay-Tezsure avatar Jay-Tezsure commented on August 11, 2024

@Skycoder42 When i try to init SodiumSumo on mac m1, i am getting the below errors.

LateInitializationError: Field '_instance@154288322' has not been initialized.
package:sodium_libs/src/sodium_platform.dart                          SodiumPlatform._instance
sodium_platform.dart:1
SodiumPlatform.instance
sodium_platform.dart:23
SodiumSumoInit.init.<fn>
sodium_sumo_init.dart:38
BasicLock.synchronized
basic_lock.dart:31
SodiumSumoInit.init
sodium_sumo_init.dart:33
SodiumUtilsImpl.init
sodium_utils_io.dart:10
SodiumUtils.init
sodium_utils.dart:13 

This is the code i am trying to run

await SodiumSumoInit.init()

Let me know if any other details you need for the issues

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 11, 2024

This looks like you did not initialize the widget bindings. Make sure to call WidgetsFlutterBinding.ensureInitialized(); when using the library before flutter has rendered the first frame

from libsodium_dart_bindings.

Jay-Tezsure avatar Jay-Tezsure commented on August 11, 2024

I am calling it from one of the test cases and it's dart project.
Also tried calling it with WidgetsFlutterBinding.ensureInitialized(); still getting the same error

  setUpAll(() async {
     sodium = await SodiumSumoInit.init();
  });

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 11, 2024

Ah, I see. That is expected behavior - the library does not automatically load the native libraries in unit tests, only in integration tests. This is dictated by flutter and nothing I have control over. You should mock it in your tests, using for example mocktail.

If you do not want to mock it for whatever reason, you can import sodium/sodium.dart instead and load the library manually for your test cases. On macOS, you need install libsodium from homebrew and then reference the distributed dylib. See https://github.com/Skycoder42/libsodium_dart_bindings/tree/main/packages/sodium#vm---loading-the-dynamic-library

from libsodium_dart_bindings.

Jay-Tezsure avatar Jay-Tezsure commented on August 11, 2024

Ok got it, This seems to work, now the issue is the below code give me sodium instance how can i get SodiumSumo, to use the crypto_sign_ed25519_sk_to_seed, i cannot find the same init2 function in SodiumSumoInit

await SodiumInit.init2(() => DynamicLibrary.open("/usr/local/lib/libsodium.dylib"))

from libsodium_dart_bindings.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.