MCEL merkle support header.
More...
#include "mcelcommon.h"
#include "domain.h"
Go to the source code of this file.
|
|
#define | MCEL_MERKLE_HASH_SIZE 32U |
| | The Merkle hash element size in bytes.
|
|
#define | MCEL_MERKLE_NODE_SIZE (MCEL_MERKLE_HASH_SIZE * 2U) |
| | The Merkle internal node input size in bytes (left hash plus right hash).
|
| #define | MCEL_MERKLE_PROOF_HASHES_MAX 32U |
| | The maximum number of sibling hashes in a MCEL Merkle membership proof.
|
|
| MCEL_EXPORT_API size_t | mcel_merkle_consistency_proof_size (size_t oldcount, size_t newcount) |
| | Get the required buffer size for a MCEL Merkle consistency proof.
|
| MCEL_EXPORT_API size_t | mcel_merkle_proof_size (size_t count) |
| | Get the required buffer size for a MCEL Merkle membership proof.
|
| MCEL_EXPORT_API bool | mcel_merkle_prove_member (uint8_t *proof, size_t prooflen, const uint8_t *leaves, size_t count, size_t index) |
| | Generate a MCEL Merkle membership proof for a leaf index.
|
| MCEL_EXPORT_API bool | mcel_merkle_member_verify (const uint8_t *root, const uint8_t *leaf, const uint8_t *proof, size_t prooflen, size_t count, size_t index) |
| | Verify a MCEL Merkle membership proof for a leaf hash.
|
| MCEL_EXPORT_API bool | mcel_merkle_root (uint8_t *root, const uint8_t *leaves, size_t count) |
| | Compute the MCEL Merkle root from an ordered list of leaf hashes.
|
| MCEL_EXPORT_API bool | mcel_merkle_root_hash (uint8_t *output, mcel_domain_types domain) |
| | Compute the MCEL Merkle root hash.
|
| MCEL_EXPORT_API bool | mcel_merkle_node_hash (uint8_t *output, const uint8_t *left, const uint8_t *right) |
| | Compute the MCEL Merkle node hash.
|
MCEL merkle support header.
◆ MCEL_MERKLE_PROOF_HASHES_MAX
| #define MCEL_MERKLE_PROOF_HASHES_MAX 32U |
The maximum number of sibling hashes in a MCEL Merkle membership proof.
This bound supports up to 2^MCEL_MERKLE_PROOF_HASHES_MAX leaves.
◆ mcel_merkle_consistency_proof_size()
| MCEL_EXPORT_API size_t mcel_merkle_consistency_proof_size |
( |
size_t | oldcount, |
|
|
size_t | newcount ) |
Get the required buffer size for a MCEL Merkle consistency proof.
- Parameters
-
| oldcount | The leaf count of the older tree. |
| newcount | The leaf count of the newer tree. |
- Returns
- The required proof size in bytes or 0 on error.
◆ mcel_merkle_member_verify()
| MCEL_EXPORT_API bool mcel_merkle_member_verify |
( |
const uint8_t * | root, |
|
|
const uint8_t * | leaf, |
|
|
const uint8_t * | proof, |
|
|
size_t | prooflen, |
|
|
size_t | count, |
|
|
size_t | index ) |
Verify a MCEL Merkle membership proof for a leaf hash.
- Parameters
-
| root | A pointer to the Merkle root array of size MCEL_BLOCK_HASH_SIZE. |
| leaf | [const] A pointer to the leaf hash array of size MCEL_BLOCK_HASH_SIZE. |
| proof | [const] A pointer to the proof buffer containing sibling hashes. |
| prooflen | The length of the proof buffer in bytes. |
| count | The number of leaves in the tree. |
| index | The leaf index being proven (0..count-1). |
- Returns
- Returns true if the proof is valid.
◆ mcel_merkle_node_hash()
| MCEL_EXPORT_API bool mcel_merkle_node_hash |
( |
uint8_t * | output, |
|
|
const uint8_t * | left, |
|
|
const uint8_t * | right ) |
Compute the MCEL Merkle node hash.
- Parameters
-
| output | A pointer to the output node hash array of size MCEL_BLOCK_HASH_SIZE. |
| left | A pointer to left node hash MCEL_BLOCK_HASH_SIZE. |
| right | A pointer to right node hash MCEL_BLOCK_HASH_SIZE. |
- Returns
- Returns true if the Merkle root was computed successfully.
◆ mcel_merkle_proof_size()
| MCEL_EXPORT_API size_t mcel_merkle_proof_size |
( |
size_t | count | ) |
|
Get the required buffer size for a MCEL Merkle membership proof.
- Parameters
-
| count | The number of leaves in the tree. |
- Returns
- The required proof size in bytes, or 0 on error.
◆ mcel_merkle_prove_member()
| MCEL_EXPORT_API bool mcel_merkle_prove_member |
( |
uint8_t * | proof, |
|
|
size_t | prooflen, |
|
|
const uint8_t * | leaves, |
|
|
size_t | count, |
|
|
size_t | index ) |
Generate a MCEL Merkle membership proof for a leaf index.
- Parameters
-
| proof | A pointer to the output proof buffer. |
| prooflen | The length of the output proof buffer in bytes. |
| leaves | [const] A pointer to the leaf hash array (count * MCEL_BLOCK_HASH_SIZE). |
| count | The number of leaves in the array. |
| index | The leaf index to prove (0..count-1). |
- Returns
- Returns true if the proof was generated successfully.
◆ mcel_merkle_root()
| MCEL_EXPORT_API bool mcel_merkle_root |
( |
uint8_t * | root, |
|
|
const uint8_t * | leaves, |
|
|
size_t | count ) |
Compute the MCEL Merkle root from an ordered list of leaf hashes.
- Parameters
-
| root | A pointer to the output root hash array of size MCEL_BLOCK_HASH_SIZE. |
| leaves | [const] A pointer to an array of leaf hashes, each of size MCEL_BLOCK_HASH_SIZE. |
| count | The number of leaves in the array. |
- Returns
- Returns true if the Merkle root was computed successfully.
◆ mcel_merkle_root_hash()
| MCEL_EXPORT_API bool mcel_merkle_root_hash |
( |
uint8_t * | output, |
|
|
mcel_domain_types | domain ) |
Compute the MCEL Merkle root hash.
- Parameters
-
| output | A pointer to the output root hash array of size MCEL_BLOCK_HASH_SIZE. |
| domain | The MCEL domain identifier. |
- Returns
- Returns true if the Merkle root was computed successfully.