Skip to content

Geod24/libsodium-crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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.

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).

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).

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages