Code Monkey home page Code Monkey logo

geralt's Introduction

Geralt

Maintained License NuGet

Geralt is a modern cryptographic library for .NET 6+ based on libsodium and inspired by Monocypher.

  • Simple: an easy-to-learn API with descriptive naming. Only one algorithm for each task is provided when possible.
  • Modern: the latest and greatest cryptographic algorithms, such as AEGIS-128L/AEGIS-256, (X)ChaCha20-Poly1305, BLAKE2b, Argon2id, X25519, and Ed25519.
  • Secure: libsodium was audited in 2017 and is the library of choice for lots of projects and even large companies.
  • Fast: libsodium is faster than many other cryptographic libraries. Furthermore, Geralt uses Span<T> buffers to avoid memory allocations.

For more information, please visit these links:

Documentation: https://www.geralt.xyz/
Installation: https://www.geralt.xyz/#installation
Open issues: https://github.com/samuel-lucas6/Geralt/issues
Pull requests: https://github.com/samuel-lucas6/Geralt/pulls

geralt's People

Contributors

jack-edwards avatar samuel-lucas6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

geralt's Issues

Inter-process compatibility?

Does the library do some magic that would break in the event of inter-process communication between different clients/companies whom use their own libraries/implementations for encryption/decryption?

The concrete case I'm wondering specifically about, is signing data with your Ed25519 implementation.

MAUI/Android/iOS support

Love that this targets .NET 6/7 but it seems when trying to use this on Android it just fails to load:

Loaded assembly: /data/data/test/files/.__override__/Geralt.dll [External]
[monodroid-assembly] Shared library 'libsodium' not loaded, p/invoke 'randombytes_buf' may fail
[monodroid-assembly] Shared library 'libsodium' not loaded, p/invoke 'sodium_library_version_major' may fail
[monodroid-assembly] Shared library 'libsodium' not loaded, p/invoke 'sodium_library_version_minor' may fail
[monodroid-assembly] Shared library 'libsodium' not loaded, p/invoke 'sodium_version_string' may fail
[monodroid-assembly] Shared library 'libsodium' not loaded, p/invoke 'sodium_set_misuse_handler' may fail
[monodroid-assembly] Shared library 'libsodium' not loaded, p/invoke 'sodium_init' may fail
[monodroid-assembly] Shared library 'libsodium' not loaded, p/invoke 'sodium_library_version_major' may fail
**System.PlatformNotSupportedException:** 'Unable to access the libsodium DLL. Geralt may not be supported on this platform, or this machine may be missing the Visual C++ Redistributable on Windows.'

What do I need to do to get this working on Android?

Clarify documentation on IncrementalXChaCha20Poly1305

For encryption, the header is filled with a random nonce. It MUST be prepended to the first ciphertext chunk.

It's my understanding the header should remain detached from the ciphertext. This is how the unit tests behave.

Different Output with other library

I was using geralt because it uses libsodium implementation but it seems it produce different output with other library such as Isopoh.Cryptography.Argon2 .

       public IActionResult Test(string password)
       {
           byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
           // salting is hex string
           string salting = "6c6f62616c6f62613264616477696639"; // plain text : lobaloba2dadwif9
           byte[] salt = Convert.FromHexString(salting);

           var config = new Argon2Config
           {
               Type = Argon2Type.HybridAddressing, //argon2id
               Version = Argon2Version.Nineteen,
               TimeCost = 2, // iterations
               MemoryCost = 8192, // memory
               Lanes = 1,  // paralism
               Threads = Environment.ProcessorCount,
               Password = passwordBytes,
               Salt = salt, 
           };
           using var argon2client = new Argon2(config);
           using var hash = argon2client.Hash();
           string hashstring = config.EncodeString(hash.Buffer);

           Span<byte> okm = new byte[32];
           Argon2id.DeriveKey(okm, passwordBytes, salt, 2, 8192);

            string geraltString = Convert.ToHexString(okm);
            string IsopohCryptographString = Convert.ToHexString(hash.Buffer);

           return Ok(new{ IsopohCryptographString, geraltString });
       }

If i call the function with password = "string" , the output is :
isopohCryptographString: "E6274D67634B68F62F8764F7DD011E34F9B208003B153AAD69E03185BAB963C3" (correct)
geraltString: "295C6D6889530B62F28980FA79208C869E0835D4F3D632F008D08C5447169E63" (false)

whats wrong with my code ?

Salt in KDF

I hope it's OK to ask questions here. Thanks again for your help in previous threads. I have gone through the flow you outline here for my purposes of creating messages for a specific wallet owner. I'm wondering if it makes sense to prepend the salt for the KDF (Blake2) to the message since it's not known by the receiving party prior. For personalization, I was thinking of keeping blank as I don't think there is much benefit.

Given the need to include the salt in the messages, I'm wondering if this is the correct flow for my use case which is to encrypt a message, write to a block, and then notify the wallet owner that there is a message for their consumption.

If you'd prefer to discuss elsewhere, please let me know! Appreciate the discussion.

Different shared secrets

I have two public/private key pairs that do not generate the same shared secret when calling into X25519.ComputeSharedKey(). I may not have a firm understanding of limitations with the type of keys I can use, but these keys are both used in blockchain signing and verification. They are both 32 bytes.

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.