All Projects → i5ik → Discohash

i5ik / Discohash

Licence: mit
👯 Discohash - A super fast and simple hash. 5GB/s serial (depending on hardware). Also in NodeJS

Projects that are alternatives of or similar to Discohash

Bitcracker
BitCracker is the first open source password cracking tool for memory units encrypted with BitLocker
Stars: ✭ 463 (+125.85%)
Mutual labels:  hash, cryptography
Java Crypto Utils
Java Cryptographic, Encoding and Hash Utilities
Stars: ✭ 15 (-92.68%)
Mutual labels:  hash, cryptography
Chronicle
Public append-only ledger microservice built with Slim Framework
Stars: ✭ 429 (+109.27%)
Mutual labels:  hash, cryptography
Nsec
A modern and easy-to-use cryptographic library for .NET Core based on libsodium
Stars: ✭ 217 (+5.85%)
Mutual labels:  hash, cryptography
Node Sha3
SHA3 for JavaScript - The Keccak family of hash algorithms
Stars: ✭ 112 (-45.37%)
Mutual labels:  hash, cryptography
Merkle Tools
Tools for creating Merkle trees, generating merkle proofs, and verification of merkle proofs.
Stars: ✭ 54 (-73.66%)
Mutual labels:  hash, cryptography
Securitydriven.inferno
✅ .NET crypto done right. Professionally audited.
Stars: ✭ 501 (+144.39%)
Mutual labels:  hash, cryptography
Password4j
Password4j is a user-friendly cryptographic library that supports Argon2, Bcrypt, Scrypt, PBKDF2 and various cryptographic hash functions.
Stars: ✭ 124 (-39.51%)
Mutual labels:  hash, cryptography
Siphash Js
A Javascript implementation of SipHash-2-4
Stars: ✭ 90 (-56.1%)
Mutual labels:  hash, cryptography
Beamsplitter
💎 Beamsplitter - A new (possibly universal) hash that passes SMHasher. Built mainly with a random 10x64 S-box. Also in NodeJS
Stars: ✭ 83 (-59.51%)
Mutual labels:  hash, cryptography
Open Crypto
🔑 Hashing (BCrypt, SHA2, HMAC), encryption (AES), public-key (RSA), and random data generation.
Stars: ✭ 115 (-43.9%)
Mutual labels:  hash, cryptography
Jssha
A JavaScript/TypeScript implementation of the complete Secure Hash Standard (SHA) family (SHA-1, SHA-224/256/384/512, SHA3-224/256/384/512, SHAKE128/256, cSHAKE128/256, and KMAC128/256) with HMAC.
Stars: ✭ 2,089 (+919.02%)
Mutual labels:  hash, cryptography
Blockchain Crypto Mpc
Protecting cryptographic signing keys and seed secrets with Multi-Party Computation.
Stars: ✭ 193 (-5.85%)
Mutual labels:  cryptography
Iavl
Merkleized IAVL+ Tree implementation in Go
Stars: ✭ 197 (-3.9%)
Mutual labels:  cryptography
Awesome Iam
👤 Identity and Access Management Knowledge for Cloud Platforms
Stars: ✭ 186 (-9.27%)
Mutual labels:  cryptography
Ctf Tools
Useful CTF Tools
Stars: ✭ 190 (-7.32%)
Mutual labels:  cryptography
Encrypt
🔒 A set of high-level APIs over PointyCastle for two-way cryptography.
Stars: ✭ 199 (-2.93%)
Mutual labels:  cryptography
Firmware
❄️ Firmware and simulator for Coldcard Hardware Wallet
Stars: ✭ 198 (-3.41%)
Mutual labels:  cryptography
Ring
Safe, fast, small crypto using Rust
Stars: ✭ 2,553 (+1145.37%)
Mutual labels:  cryptography
Zips
Zcash Improvement Proposals
Stars: ✭ 188 (-8.29%)
Mutual labels:  cryptography

👯 Discohash

2-5GB/s, passed SMHasher version npm downloads

Discohash (also known as BEBB4185) is a super simple and super fast hash that passes all of SMHasher, and runs at 2-5GB/s (depending on hardware) in this naive, portable, serial implementation.

Link to the SUPERCOP ECRYPT benchmark for bebb4185

The ECRYPT benchmark is 4x faster than BLAKE3

Also there's an unofficial Golang port

Cryptanalysis

Cryptanalysis Open

Inviting all budding hashbreakers to attack the 128-bit version. Should be easy, right?

If you'd like something a little more challenging, try breaking beamsplitter-128

Submit your results as PR requests updating the README to a link to your analysis, or contact Cris directly.

Important Note The 128-bit variants must be modified from the existing source C/C++ files. Find the commented out lines at the end of the main hash function, and return 128-bits, instead of 64.

CLI app included


Quick Facts

  • A super-fast 64-bit hash.
  • one of the fastest hashes ever benchmarked at ecrypt
  • ECRYPT benchmark is 4x faster than BLAKE3
  • Mix is super simple.
  • Tested at ~ 5GB/s @ 3Gz, (Google Cloud Platform, N1 CPU)
  • Passes all SMHasher tests.
  • Also known as: BEBB4185
  • Implemented in C++, and also a port to JS
  • This repo includes a simple CLI app for hashing files or stdin from the command line.

Simplicity

The main 128-bit-to-128-bit mixing function is just this:

  mix(const int A)
    {
      const int B = A+1;
      
      ds[A] *= P;
      ds[A] = rot(ds[A], 23);
      ds[A] *= Q;
      
      ds[B] ^= ds[A];

      ds[B] *= P;
      ds[B] = rot(ds[B], 23);
      ds[B] *= Q;
    }

which is just multiplications by two 64-bit primes, P and Q, bit rotation, and xor.

P, and Q are:

  • P = 0xFFFFFFFFFFFFFFFF - 58 (largest 64-bit prime)
  • Q = 13166748625691186689 (random prime, 2^9×3×19×73×773×35149×227467 + 1)

More about P and Q

Binary

  • 1111111111111111111111111111111111111111111111111111111111000101
  • 1011011010111001101100000001110101011001001011111001011000000001

The difference is particularly interesting:

  • P - Q + 1 = 5279995448018364869 = 16445111 × 321067790179
  • P - Q = 2^2 × 31 × 107 × 397949611698701
  • P - Q - 1 = 3 × 17 × 289086659 × 358125563
  • P - Q == P ^ Q (difference equals xor, not true for most pairs)

The count of numbers less than some n whose difference equals their xor is also known as Gould's sequence, and is equal to the number of odd entries in row n of Pascal's triangle, while the binary exponents of this give the number of non-zero bits in n, and taking the mod 2 remainders of those values, gives the Thue-Morse sequence. See A001316 for more.

Standard Version

The standard internal state is 256-bits and the mixing function windows across that.

The standard digest is 64-bits, but you can modify it to yield 128-bits or more if you want a cryptographically secure hash.

Using

Use the C code from this repository, either in your project or as a CL-app (included):

cd src
./build.sh
./bin/bebbsum < 0xa2a647993898a3df.txt
> 0xa2a647993898a3df
./bin/bebbsum 0xa2a647993898a3df.txt
> 0xa2a647993898a3df

or, for a JS implementation:

npm i --save bebb4185
// or
npm i --save @dosy/discohash

Use in Node.JS:

import {discohash} from 'bebb4185'

Or using Snowpack as a webmodule:

import {discohash} from './web_modules/bebb4185.js';

Then call it:

const hash = discohash(string_or_typed_array_key, optional_seed);

JS Implementation

  • The JS Implementation produces the same value hashes as the C++ implementation.
  • The JS implementation is ~ 500x slower than the C++ implementation.
  • This is probably because of the use of BigInts to stand in for uint64_t
  • It's possible to implement a 64-bit mult using 32-bit view which would remove the need for BigInt. I have no plan to do this.

Golang port

There's an unofficial go port.

SMHasher verification value

The value was: BEBB4185 but SMHasher has since updated how it calculates that, so now it's different!

Possible future work

  • Make a parallel version using Merkle tree
  • Make a note about how internal state can be extended
  • Implement a variable-output variant using a sponge construction
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].