libsodium-crypto 0.1.0

Libsodium-based cryptographic primitives, including Cruve25519, Blake2b, and Schnorr signatures


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Crypto

A library to perform cryptographic operations for the BOA blockchain. The library relies on libsodium for cryptographic primitives, and the bitblob package for convenience.

agora.crypto.Hash

This module exposes a thin wrapper on top of libsodiumd's Blake2b bindings, combining it with bitblob to provide a more user-friendly experience. The Hash type is a fully @nogc value type, and passing it to a string printing function that supports toString sink is guaranteed not to allocate.

agora.crypto.ECC

This module exposes thin wrappers on top of libsodium's cryptographic primitives, allowing to use more convenient syntax (e.g. operator overload) when manipulating scalar (numbers on finite field, usually used as private keys) and points (usually used as public key).

agora.crypto.Schnorr

This module glues together ECC and Hash to generate signatures. In order to generate a signature, both the Scalar and the Point are used, so in order to avoid re-generating the Point every time, a convenience Pair struct is exposed.

The signature generated is stored in a Sig structure, however, to separate the chain's data structures from the crypto code, Sig can convert to a Signature (see agora.crypto.Types) via the toBlob method.

The main interface for this module are the various sign functions, which can be used in a pedestrian way (e.g. Pair kp = Pair.random(); sign(kp, "Message");), or in a more complex fashion (using a specific r, or even different scalar and points altogether, to allow for multisig schemes).

agora.crypto.Types

This module exposes types which can be used by client code, without importing the types from other modules directly (in other words, it's a leaf module). The aim is to reduce dependencies by allowing a data structure to include a type without gaining knowledge of the hashing or signing routines.

Required features

This library require usage of -preview=in, hence the following minimum versions:

  • dub >= 1.24
  • dmd >= 2.095.0
  • ldc >= 1.25.0

Your dub.json must include dflags: [ "-preview=in" ]. If it does not, linker error might be triggered in cases where ref is inferred.

Authors:
  • BOS Platform Foundation
Dependencies:
bitblob, libsodiumd
Versions:
0.1.0 2023-Sep-01
~v0.x.x 2023-Sep-01
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 1 downloads this month

  • 46 downloads total

Score:
0.5
Short URL:
libsodium-crypto.dub.pm