UDIF: Universal Digital Identification Framework 1.0.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 "mcel.h"
57
72
73 /* MCEL constants */
74#define UDIF_MCEL_BLOCK_HASH_SIZE 32U
75#define UDIF_MCEL_KEYID_SIZE 32U
76#define UDIF_MCEL_DEFAULT_BLOCK_SIZE 100U
77
90
96{
97 uint8_t membcommit[UDIF_MCEL_BLOCK_HASH_SIZE];
98 uint8_t regcommit[UDIF_MCEL_BLOCK_HASH_SIZE];
99 uint8_t transcommit[UDIF_MCEL_BLOCK_HASH_SIZE];
100 uint64_t height;
101 uint64_t membershipseq;
102 uint64_t registryseq;
103 uint64_t timestamp;
104 uint64_t transactionseq;
106
111typedef struct udif_mcel_ledger
112{
113 mcel_ledger_state mcelstate;
115 uint8_t lastblockroot[MCEL_BLOCK_HASH_SIZE];
116 uint8_t lastblockcommit[MCEL_BLOCK_HASH_SIZE];
117 char namespaceid[64U];
118 uint64_t nextblockseq;
122 uint64_t nextrecordseq;
123 uint8_t* reccommits;
124 uint64_t totalblocks;
126 uint64_t totalrecords;
127 size_t commitscap;
131
150
162udif_mcel_manager* udif_mcel_initialize(const char* basepath, const udif_checkpoint_config* config);
163
176udif_mcel_manager* udif_mcel_open(const char* basepath, bool readonly, const uint8_t* sigkey, const uint8_t* verkey);
177
185void udif_mcel_dispose(udif_mcel_manager* mgr);
186
197bool udif_mcel_set_active_ledger(udif_mcel_manager* mgr, udif_ledger_type ledger);
198
206udif_ledger_type udif_mcel_get_active_ledger(const udif_mcel_manager* mgr);
207
222bool udif_mcel_add_record(udif_mcel_manager* mgr, const uint8_t* data, size_t datalen, bool encrypted, uint64_t* outseq);
223
237bool udif_mcel_read_record(udif_mcel_manager* mgr, uint64_t sequence, uint8_t* data, size_t datalen, size_t* outread);
238
249bool udif_mcel_get_ledger_size(const udif_mcel_manager* mgr, uint64_t* outcount);
250
251/* === Block & Checkpoint Operations === */
252
263bool udif_mcel_flush_block(udif_mcel_manager* mgr);
264
275bool udif_mcel_create_checkpoint(udif_mcel_manager* mgr);
276
288bool udif_mcel_create_checkpoint_group(udif_mcel_manager* mgr, udif_checkpoint_group* outgroup);
289
297void udif_mcel_get_default_config(udif_checkpoint_config* config);
298
308bool udif_mcel_flush_all(udif_mcel_manager* mgr);
309
321bool udif_mcel_get_keypair(const udif_mcel_manager* mgr, uint8_t* sigkey, uint8_t* verkey);
322
323#endif
UDIF file-based storage backend for MCEL integration.
udif_ledger_type
Ledger namespace identifiers.
Definition storage.h:108
Configuration for automatic checkpoint creation.
Definition mcelmanager.h:83
uint64_t membinterval
Definition mcelmanager.h:84
bool autocheckpointenabled
Definition mcelmanager.h:88
uint32_t blocksize
Definition mcelmanager.h:87
uint64_t transinterval
Definition mcelmanager.h:85
uint64_t reginterval
Definition mcelmanager.h:86
Coordinated checkpoint across all three ledgers.
Definition mcelmanager.h:96
uint64_t membershipseq
Definition mcelmanager.h:101
uint8_t membcommit[UDIF_MCEL_BLOCK_HASH_SIZE]
Definition mcelmanager.h:97
uint64_t timestamp
Definition mcelmanager.h:103
uint64_t height
Definition mcelmanager.h:100
uint64_t transactionseq
Definition mcelmanager.h:104
uint8_t transcommit[UDIF_MCEL_BLOCK_HASH_SIZE]
Definition mcelmanager.h:99
uint8_t regcommit[UDIF_MCEL_BLOCK_HASH_SIZE]
Definition mcelmanager.h:98
uint64_t registryseq
Definition mcelmanager.h:102
Per-ledger state tracking.
Definition mcelmanager.h:112
mcel_ledger_state mcelstate
Definition mcelmanager.h:113
uint64_t firstrecordincheckpoint
Definition mcelmanager.h:121
uint64_t nextblockseq
Definition mcelmanager.h:118
udif_ledger_type type
Definition mcelmanager.h:114
size_t commitscount
Definition mcelmanager.h:128
uint64_t firstrecordinblock
Definition mcelmanager.h:120
uint8_t * reccommits
Definition mcelmanager.h:123
uint8_t lastblockroot[MCEL_BLOCK_HASH_SIZE]
Definition mcelmanager.h:115
uint64_t totalcheckpoints
Definition mcelmanager.h:125
uint64_t nextrecordseq
Definition mcelmanager.h:122
uint64_t totalrecords
Definition mcelmanager.h:126
uint64_t nextcheckpointseq
Definition mcelmanager.h:119
uint8_t lastblockcommit[MCEL_BLOCK_HASH_SIZE]
Definition mcelmanager.h:116
size_t commitscap
Definition mcelmanager.h:127
char namespaceid[64U]
Definition mcelmanager.h:117
uint64_t totalblocks
Definition mcelmanager.h:124
bool haveblockroot
Definition mcelmanager.h:129
MCEL manager implementation.
Definition mcelmanager.h:137
udif_mcel_ledger * transaction
Definition mcelmanager.h:143
udif_mcel_ledger * registry
Definition mcelmanager.h:142
udif_ledger_type actledger
Definition mcelmanager.h:138
uint8_t sigkey[MCEL_ASYMMETRIC_SIGNING_KEY_SIZE]
Definition mcelmanager.h:145
udif_mcel_ledger * membership
Definition mcelmanager.h:141
uint8_t verkey[MCEL_ASYMMETRIC_VERIFY_KEY_SIZE]
Definition mcelmanager.h:146
uint8_t keyid[UDIF_MCEL_KEYID_SIZE]
Definition mcelmanager.h:144
udif_storage_context storage
Definition mcelmanager.h:140
bool readonly
Definition mcelmanager.h:148
bool initialized
Definition mcelmanager.h:147
udif_checkpoint_config checkconfig
Definition mcelmanager.h:139
File-based storage context for MCEL integration.
Definition storage.h:134