MCEL: Merkle-Chaining Event Ledger 1.0.0.0a (A1)
A post-quantum secure block-chain ledger system
anchor.h File Reference

MCEL anchor support header. More...

#include "mcelcommon.h"

Go to the source code of this file.

Data Structures

struct  mcel_anchor_reference
 The MCEL anchor reference container. More...

Macros

#define MCEL_ANCHOR_HASH_SIZE   32U
 The MCEL anchor hash size.
#define MCEL_ANCHOR_REFERENCE_VERSION   0x01U
 The MCEL anchor reference format version.
#define MCEL_ANCHOR_REFERENCE_HEADER_SIZE   8U
 The fixed-size header portion of an encoded MCEL anchor reference in bytes.

Typedefs

typedef MCEL_EXPORT_API struct mcel_anchor_reference mcel_anchor_reference

Functions

MCEL_EXPORT_API bool mcel_anchor_commit (uint8_t *output, const uint8_t *chkcommit, const uint8_t *anchref, size_t reflen)
 Compute a MCEL anchor commitment.
MCEL_EXPORT_API bool mcel_anchor_reference_encode (uint8_t *output, size_t outlen, const mcel_anchor_reference *anchor)
 Serialize an anchor reference into a canonical byte string.
MCEL_EXPORT_API size_t mcel_anchor_reference_encoded_size (size_t cidlen, size_t reflen)
 Get the required buffer size for an encoded MCEL anchor reference.
MCEL_EXPORT_API bool mcel_anchor_reference_verify (uint8_t *flags, uint8_t *type, const uint8_t **chainid, uint16_t *chainidlen, const uint8_t **reference, uint16_t *reflen, const uint8_t *input, size_t inlen)
 Verify a serialized MCEL anchor reference encoding.

Detailed Description

MCEL anchor support header.

Macro Definition Documentation

◆ MCEL_ANCHOR_REFERENCE_HEADER_SIZE

#define MCEL_ANCHOR_REFERENCE_HEADER_SIZE   8U

The fixed-size header portion of an encoded MCEL anchor reference in bytes.

version(1) | flags(1) | type(1) | reserved(1) | chain_len(2) | ref_len(2)

Function Documentation

◆ mcel_anchor_commit()

MCEL_EXPORT_API bool mcel_anchor_commit ( uint8_t * output,
const uint8_t * chkcommit,
const uint8_t * anchref,
size_t reflen )

Compute a MCEL anchor commitment.

The anchor commitment binds a checkpoint commitment to an opaque external anchor reference that is canonically encoded by the caller.

Parameters
outputA pointer to the output commitment array of size MCEL_BLOCK_HASH_SIZE.
chkcommit[const] A pointer to the checkpoint commitment array of size MCEL_BLOCK_HASH_SIZE.
anchref[const] A pointer to the serialized anchor reference bytes.
reflenThe length of the anchor reference in bytes.
Returns
Returns true if the commitment was generated successfully, false on failure.

◆ mcel_anchor_reference_encode()

MCEL_EXPORT_API bool mcel_anchor_reference_encode ( uint8_t * output,
size_t outlen,
const mcel_anchor_reference * anchor )

Serialize an anchor reference into a canonical byte string.

Parameters
outputA pointer to the output buffer.
outlenThe length of the output buffer in bytes.
anchor[const] A pointer to the anchor reference structure.
Returns
Returns true if the reference was encoded successfully, false on failure.

◆ mcel_anchor_reference_encoded_size()

MCEL_EXPORT_API size_t mcel_anchor_reference_encoded_size ( size_t cidlen,
size_t reflen )

Get the required buffer size for an encoded MCEL anchor reference.

Parameters
cidlenThe chain identifier length in bytes.
reflenThe reference length in bytes.
Returns
The required encoded size in bytes, or 0 on error.

◆ mcel_anchor_reference_verify()

MCEL_EXPORT_API bool mcel_anchor_reference_verify ( uint8_t * flags,
uint8_t * type,
const uint8_t ** chainid,
uint16_t * chainidlen,
const uint8_t ** reference,
uint16_t * reflen,
const uint8_t * input,
size_t inlen )

Verify a serialized MCEL anchor reference encoding.

This function verifies that an encoded anchor reference is well-formed and canonical. It does not perform any network or chain validation.

Parameters
flagsA pointer to the returned flags value, can be NULL.
typeA pointer to the returned type value, can be NULL.
chainidA pointer to the returned chain identifier pointer, can be NULL.
chainidlenA pointer to the returned chain identifier length, can be NULL.
referenceA pointer to the returned reference pointer, can be NULL.
reflenA pointer to the returned reference length, can be NULL.
input[const] A pointer to the encoded anchor reference bytes.
inlenThe length of the encoded anchor reference in bytes.
Returns
Returns true if the encoding is valid and canonical.