MCEL anchor support header.
More...
#include "mcelcommon.h"
Go to the source code of this file.
|
|
#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.
|
|
|
typedef MCEL_EXPORT_API struct mcel_anchor_reference | mcel_anchor_reference |
|
| 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.
|
MCEL anchor support header.
◆ 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)
◆ 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
-
| output | A 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. |
| reflen | The 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
-
| output | A pointer to the output buffer. |
| outlen | The 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
-
| cidlen | The chain identifier length in bytes. |
| reflen | The 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
-
| flags | A pointer to the returned flags value, can be NULL. |
| type | A pointer to the returned type value, can be NULL. |
| chainid | A pointer to the returned chain identifier pointer, can be NULL. |
| chainidlen | A pointer to the returned chain identifier length, can be NULL. |
| reference | A pointer to the returned reference pointer, can be NULL. |
| reflen | A pointer to the returned reference length, can be NULL. |
| input | [const] A pointer to the encoded anchor reference bytes. |
| inlen | The length of the encoded anchor reference in bytes. |
- Returns
- Returns true if the encoding is valid and canonical.