Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
aztec_hash_policy.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
barretenberg/aztec/aztec_constants.hpp
"
4
#include "
barretenberg/crypto/merkle_tree/hash.hpp
"
5
#include "
barretenberg/crypto/merkle_tree/indexed_tree/indexed_leaf.hpp
"
6
7
namespace
bb::aztec
{
8
19
template
<u
int
64_t Separator>
struct
AztecMerkleHashPolicyT
:
public
crypto::merkle_tree::Poseidon2HashPolicy
{
20
static
bb::fr
hash_pair
(
const
bb::fr
& lhs,
const
bb::fr
& rhs)
21
{
22
return
Poseidon2HashPolicy::hash_pair_with_separator(Separator, lhs, rhs);
23
}
24
};
25
26
// Per-tree instantiations for the 4 indexed trees.
27
using
NullifierMerkleHashPolicy
=
AztecMerkleHashPolicyT<DOM_SEP__NULLIFIER_MERKLE>
;
28
using
PublicDataMerkleHashPolicy
=
AztecMerkleHashPolicyT<DOM_SEP__PUBLIC_DATA_MERKLE>
;
29
using
WrittenSlotsMerkleHashPolicy
=
AztecMerkleHashPolicyT<DOM_SEP__WRITTEN_SLOTS_MERKLE>
;
30
using
RetrievedBytecodesMerkleHashPolicy
=
AztecMerkleHashPolicyT<DOM_SEP__RETRIEVED_BYTECODES_MERKLE>
;
31
32
// Default policy, shared by the 3 append-only trees (note-hash, L1->L2, archive).
33
using
AztecMerkleHashPolicy
=
AztecMerkleHashPolicyT<DOM_SEP__MERKLE_HASH>
;
34
35
// Leaf-type -> hash policy trait. Lets generic world-state template code pick the right per-tree
36
// policy without hard-coding HashPolicy at every instantiation.
37
template
<
typename
Leaf>
struct
MerkleHashPolicyFor
;
38
template
<>
struct
MerkleHashPolicyFor
<crypto::merkle_tree::NullifierLeafValue> {
39
using
type
=
NullifierMerkleHashPolicy
;
40
};
41
template
<>
struct
MerkleHashPolicyFor
<crypto::merkle_tree::PublicDataLeafValue> {
42
using
type
=
PublicDataMerkleHashPolicy
;
43
};
44
// Append-only tree leaves are bare fr (hash directly stored); they use the baseline policy.
45
template
<>
struct
MerkleHashPolicyFor
<
bb
::
fr
> {
46
using
type
=
AztecMerkleHashPolicy
;
47
};
48
49
template
<
typename
Leaf>
using
MerkleHashPolicyForT
=
typename
MerkleHashPolicyFor<Leaf>::type
;
50
51
}
// namespace bb::aztec
aztec_constants.hpp
hash.hpp
indexed_leaf.hpp
bb::aztec
Definition
aztec_hash_policy.hpp:7
bb::aztec::AztecMerkleHashPolicy
AztecMerkleHashPolicyT< DOM_SEP__MERKLE_HASH > AztecMerkleHashPolicy
Definition
aztec_hash_policy.hpp:33
bb::aztec::NullifierMerkleHashPolicy
AztecMerkleHashPolicyT< DOM_SEP__NULLIFIER_MERKLE > NullifierMerkleHashPolicy
Definition
aztec_hash_policy.hpp:27
bb::aztec::MerkleHashPolicyForT
typename MerkleHashPolicyFor< Leaf >::type MerkleHashPolicyForT
Definition
aztec_hash_policy.hpp:49
bb::aztec::PublicDataMerkleHashPolicy
AztecMerkleHashPolicyT< DOM_SEP__PUBLIC_DATA_MERKLE > PublicDataMerkleHashPolicy
Definition
aztec_hash_policy.hpp:28
bb
Entry point for Barretenberg command-line interface.
Definition
api.hpp:5
bb::aztec::AztecMerkleHashPolicyT
Aztec-specific hash policy for Merkle trees, parameterised by a tree-specific domain separator for in...
Definition
aztec_hash_policy.hpp:19
bb::aztec::AztecMerkleHashPolicyT::hash_pair
static bb::fr hash_pair(const bb::fr &lhs, const bb::fr &rhs)
Definition
aztec_hash_policy.hpp:20
bb::aztec::MerkleHashPolicyFor
Definition
aztec_hash_policy.hpp:37
bb::crypto::merkle_tree::Poseidon2HashPolicy
Definition
hash.hpp:13
bb::field< Bn254FrParams >
src
barretenberg
aztec
aztec_hash_policy.hpp
Generated by
1.9.8