UDIF: Universal Digital Identification Framework 1.1.0.0a (A1)
A quantum-secure cryptographic identification
mcelmanager.h
1/* 2025-2026 Quantum Resistant Cryptographic Solutions Corporation
2 * All Rights Reserved.
3 *
4 * NOTICE:
5 * This software and all accompanying materials are the exclusive property of
6 * Quantum Resistant Cryptographic Solutions Corporation (QRCS). The intellectual
7 * and technical concepts contained herein are proprietary to QRCS and are
8 * protected under applicable Canadian, U.S., and international copyright,
9 * patent, and trade secret laws.
10 *
11 * CRYPTOGRAPHIC ALGORITHMS AND IMPLEMENTATIONS:
12 * - This software includes implementations of cryptographic primitives and
13 * algorithms that are standardized or in the public domain, such as AES
14 * and SHA-3, which are not proprietary to QRCS.
15 * - This software also includes cryptographic primitives, constructions, and
16 * algorithms designed by QRCS, including but not limited to RCS, SCB, CSX, QMAC, and
17 * related components, which are proprietary to QRCS.
18 * - All source code, implementations, protocol compositions, optimizations,
19 * parameter selections, and engineering work contained in this software are
20 * original works of QRCS and are protected under this license.
21 *
22 * LICENSE AND USE RESTRICTIONS:
23 * - This software is licensed under the Quantum Resistant Cryptographic Solutions
24 * Public Research and Evaluation License (QRCS-PREL), 2025-2026.
25 * - Permission is granted solely for non-commercial evaluation, academic research,
26 * cryptographic analysis, interoperability testing, and feasibility assessment.
27 * - Commercial use, production deployment, commercial redistribution, or
28 * integration into products or services is strictly prohibited without a
29 * separate written license agreement executed with QRCS.
30 * - Licensing and authorized distribution are solely at the discretion of QRCS.
31 *
32 * EXPERIMENTAL CRYPTOGRAPHY NOTICE:
33 * Portions of this software may include experimental, novel, or evolving
34 * cryptographic designs. Use of this software is entirely at the user's risk.
35 *
36 * DISCLAIMER:
37 * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38 * IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
39 * FOR A PARTICULAR PURPOSE, SECURITY, OR NON-INFRINGEMENT. QRCS DISCLAIMS ALL
40 * LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
41 * ARISING FROM THE USE OR MISUSE OF THIS SOFTWARE.
42 *
43 * FULL LICENSE:
44 * This software is subject to the Quantum Resistant Cryptographic Solutions
45 * Public Research and Evaluation License (QRCS-PREL), 2025-2026. The complete license terms
46 * are provided in the accompanying LICENSE file or at https://www.qrcscorp.ca.
47 *
48 * Written by: John G. Underhill
49 * Contact: contact@qrcscorp.ca
50 */
51
52#ifndef UDIF_MCEL_MANAGER_H
53#define UDIF_MCEL_MANAGER_H
54
55#include "storage.h"
56#include "anchor.h"
57#include "mcel.h"
58
73
74 /* MCEL constants */
75#define UDIF_MCEL_BLOCK_HASH_SIZE 32U
76#define UDIF_MCEL_KEYID_SIZE 32U
77#define UDIF_MCEL_DEFAULT_BLOCK_SIZE 100U
78
91
97{
98 uint8_t membcommit[UDIF_MCEL_BLOCK_HASH_SIZE];
99 uint8_t regcommit[UDIF_MCEL_BLOCK_HASH_SIZE];
100 uint8_t transcommit[UDIF_MCEL_BLOCK_HASH_SIZE];
101 uint64_t height;
102 uint64_t membershipseq;
103 uint64_t registryseq;
104 uint64_t timestamp;
105 uint64_t transactionseq;
107
112typedef struct udif_mcel_ledger
113{
114 mcel_ledger_state mcelstate;
116 uint8_t lastblockroot[MCEL_BLOCK_HASH_SIZE];
117 uint8_t lastblockcommit[MCEL_BLOCK_HASH_SIZE];
118 char namespaceid[64U];
119 uint64_t nextblockseq;
123 uint64_t nextrecordseq;
124 uint8_t* reccommits;
125 uint64_t totalblocks;
127 uint64_t totalrecords;
128 size_t commitscap;
132
151
163udif_mcel_manager* udif_mcel_initialize(const char* basepath, const udif_checkpoint_config* config);
164
177udif_mcel_manager* udif_mcel_open(const char* basepath, bool readonly, const uint8_t* sigkey, const uint8_t* verkey);
178
186void udif_mcel_dispose(udif_mcel_manager* mgr);
187
198bool udif_mcel_set_active_ledger(udif_mcel_manager* mgr, udif_ledger_type ledger);
199
207udif_ledger_type udif_mcel_get_active_ledger(const udif_mcel_manager* mgr);
208
223bool udif_mcel_add_record(udif_mcel_manager* mgr, const uint8_t* data, size_t datalen, bool encrypted, uint64_t* outseq);
224
238bool udif_mcel_read_record(udif_mcel_manager* mgr, uint64_t sequence, uint8_t* data, size_t datalen, size_t* outread);
239
250bool udif_mcel_get_ledger_size(const udif_mcel_manager* mgr, uint64_t* outcount);
251
252/* Block and Checkpoint Operations */
253
264bool udif_mcel_flush_block(udif_mcel_manager* mgr);
265
276bool udif_mcel_create_checkpoint(udif_mcel_manager* mgr);
277
289bool udif_mcel_create_checkpoint_group(udif_mcel_manager* mgr, udif_checkpoint_group* outgroup);
290
308bool udif_mcel_create_anchor(udif_mcel_manager* mgr, udif_anchor_record* anchor, const uint8_t* childser, uint64_t sequence, const uint8_t* sigkey, bool (*rng_generate)(uint8_t*, size_t));
309
317void udif_mcel_get_default_config(udif_checkpoint_config* config);
318
328bool udif_mcel_flush_all(udif_mcel_manager* mgr);
329
341bool udif_mcel_get_keypair(const udif_mcel_manager* mgr, uint8_t* sigkey, uint8_t* verkey);
342
343#endif
UDIF anchor record operations.
UDIF file-based storage backend for MCEL integration.
udif_ledger_type
Ledger namespace identifiers.
Definition storage.h:108
Anchor record.
Definition anchor.h:158
Configuration for automatic checkpoint creation.
Definition mcelmanager.h:84
uint64_t membinterval
Definition mcelmanager.h:85
bool autocheckpointenabled
Definition mcelmanager.h:89
uint32_t blocksize
Definition mcelmanager.h:88
uint64_t transinterval
Definition mcelmanager.h:86
uint64_t reginterval
Definition mcelmanager.h:87
Coordinated checkpoint across all three ledgers.
Definition mcelmanager.h:97
uint64_t membershipseq
Definition mcelmanager.h:102
uint8_t membcommit[UDIF_MCEL_BLOCK_HASH_SIZE]
Definition mcelmanager.h:98
uint64_t timestamp
Definition mcelmanager.h:104
uint64_t height
Definition mcelmanager.h:101
uint64_t transactionseq
Definition mcelmanager.h:105
uint8_t transcommit[UDIF_MCEL_BLOCK_HASH_SIZE]
Definition mcelmanager.h:100
uint8_t regcommit[UDIF_MCEL_BLOCK_HASH_SIZE]
Definition mcelmanager.h:99
uint64_t registryseq
Definition mcelmanager.h:103
Per-ledger state tracking.
Definition mcelmanager.h:113
mcel_ledger_state mcelstate
Definition mcelmanager.h:114
uint64_t firstrecordincheckpoint
Definition mcelmanager.h:122
uint64_t nextblockseq
Definition mcelmanager.h:119
udif_ledger_type type
Definition mcelmanager.h:115
size_t commitscount
Definition mcelmanager.h:129
uint64_t firstrecordinblock
Definition mcelmanager.h:121
uint8_t * reccommits
Definition mcelmanager.h:124
uint8_t lastblockroot[MCEL_BLOCK_HASH_SIZE]
Definition mcelmanager.h:116
uint64_t totalcheckpoints
Definition mcelmanager.h:126
uint64_t nextrecordseq
Definition mcelmanager.h:123
uint64_t totalrecords
Definition mcelmanager.h:127
uint64_t nextcheckpointseq
Definition mcelmanager.h:120
uint8_t lastblockcommit[MCEL_BLOCK_HASH_SIZE]
Definition mcelmanager.h:117
size_t commitscap
Definition mcelmanager.h:128
char namespaceid[64U]
Definition mcelmanager.h:118
uint64_t totalblocks
Definition mcelmanager.h:125
bool haveblockroot
Definition mcelmanager.h:130
MCEL manager implementation.
Definition mcelmanager.h:138
udif_mcel_ledger * transaction
Definition mcelmanager.h:144
udif_mcel_ledger * registry
Definition mcelmanager.h:143
udif_ledger_type actledger
Definition mcelmanager.h:139
uint8_t sigkey[MCEL_ASYMMETRIC_SIGNING_KEY_SIZE]
Definition mcelmanager.h:146
udif_mcel_ledger * membership
Definition mcelmanager.h:142
uint8_t verkey[MCEL_ASYMMETRIC_VERIFY_KEY_SIZE]
Definition mcelmanager.h:147
uint8_t keyid[UDIF_MCEL_KEYID_SIZE]
Definition mcelmanager.h:145
udif_storage_context storage
Definition mcelmanager.h:141
bool readonly
Definition mcelmanager.h:149
bool initialized
Definition mcelmanager.h:148
udif_checkpoint_config checkconfig
Definition mcelmanager.h:140
File-based storage context for MCEL integration.
Definition storage.h:134