Skip to content

serokell/blake2-solidity

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BLAKE2 (blake2-solidity)

This is a Solidity library aiming to implement BLAKE2.

Ethereum only offers a precompiled contract that provides the “F” compression function, which is the central component of BLAKE2. Implementing BLAKE2 on top of it is relatively easy, but not completely straightforward, hence this library.

Currently only BLAKE2b is implemented.

Supported features:

  • Input data length between 0 and 2^24 - 1
  • Digest length between 1 and 64
  • Salt
  • Personalisation
  • Keyed MAC
  • Tree hashing

Usage

The library provides a single method: hash(out_len, data). Output length will typically be 64, as it is the most popular choice in the wild, but can be anything between 1 and 64.

Development

  1. Install Truffle.
  2. Install go-ethereum (version >= 1.9.3).
  3. Start dev node: geth --dev --rpc.
  4. Run truffle test.

API

  • Blake2b.hash(uint out_len, bytes data) -> bytes(out_len)

References

License

Apache 2.0 © @axic & Serokell

About

A Solidity library aiming to implement BLAKE2 (using EIP-152).

Topics

Resources

Stars

Watchers

Forks

Languages

  • Solidity 60.2%
  • JavaScript 39.8%