Skip to main content
Version: v1.0.0-beta.19

Hash methods

Many of the common hash methods have been moved outside of the Noir standard library and exist as independent libraries. You can find the complete list of libraries in the Hashes section of the awesome-noir repo, including:

  • keccak256
  • MiMC
  • Poseidon
  • RIPEMD160
  • sha256
  • sha512

sha256 compression

Performs a sha256 compression on an input and initial state, returning the resulting state.

warning

This is a different function than sha256. See this library for sha256 hashing.

#include_code sha256_compression noir_stdlib/src/hash/mod.nr rust

This is a black box function. Read this section to learn more about black box functions in Noir.

blake2s

Given an array of bytes, returns an array with the Blake2 hash

#include_code blake2s noir_stdlib/src/hash/mod.nr rust

example:

fn main() {
let x = [163, 117, 178, 149]; // some random bytes
let hash = std::hash::blake2s(x);
}

This is a black box function. Read this section to learn more about black box functions in Noir.

blake3

Given an array of bytes, returns an array with the Blake3 hash

#include_code blake3 noir_stdlib/src/hash/mod.nr rust

example:

fn main() {
let x = [163, 117, 178, 149]; // some random bytes
let hash = std::hash::blake3(x);
}

This is a black box function. Read this section to learn more about black box functions in Noir.

pedersen_hash

Given an array of Fields, returns the Pedersen hash.

#include_code pedersen_hash noir_stdlib/src/hash/mod.nr rust

example:

#include_code pedersen-hash test_programs/execution_success/pedersen_hash/src/main.nr rust

This is a black box function. Read this section to learn more about black box functions in Noir.

pedersen_commitment

Given an array of Fields, returns the Pedersen commitment.

#include_code pedersen_commitment noir_stdlib/src/hash/mod.nr rust

example:

#include_code pedersen-commitment test_programs/execution_success/pedersen_commitment/src/main.nr rust

This is a black box function. Read this section to learn more about black box functions in Noir.

keccakf1600

Given an initial [u64; 25] state, returns the state resulting from applying a keccakf1600 permutation ([u64; 25]).

#include_code keccakf1600 noir_stdlib/src/hash/mod.nr rust

This is a black box function. Read this section to learn more about black box functions in Noir.