QSC Post Quantum Cryptographic Library 1.3.0.0 (C1)
A post quantum secure library written in Ansi C
Loading...
Searching...
No Matches
ed448.h
1/* 2020-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 QSC_ED448_H
53#define QSC_ED448_H
54
55#include "qsccommon.h"
56
57/* \cond NO_DOCUMENT */
58
59QSC_CPLUSPLUS_ENABLED_START
60
95
100#define ED448_SEED_SIZE 57U
101
106#define ED448_SIGNATURE_SIZE 114U
107
112#define ED448_PUBLICKEY_SIZE 57U
113
118#define ED448_PRIVATEKEY_SIZE 114U
119
124#define ED448_CURVE_SIZE 56U
125
130typedef int32_t qsc_fe448[16U];
131
138typedef struct
139{
140 qsc_fe448 x;
141 qsc_fe448 y;
142 qsc_fe448 z;
143} qsc_ge448_p2;
144
152typedef struct
153{
154 qsc_fe448 x;
155 qsc_fe448 y;
156 qsc_fe448 z;
157 qsc_fe448 t;
158} qsc_ge448_p3;
159
166typedef struct
167{
168 qsc_fe448 x;
169 qsc_fe448 y;
170 qsc_fe448 z;
171 qsc_fe448 t;
172} qsc_ge448_p1p1;
173
180typedef struct
181{
182 qsc_fe448 yplusx;
183 qsc_fe448 yminusx;
184 qsc_fe448 xy2d;
185} qsc_ge448_precomp;
186
193typedef struct
194{
195 qsc_fe448 yplusx;
196 qsc_fe448 yminusx;
197 qsc_fe448 z;
198 qsc_fe448 t2d;
199} qsc_ge448_cached;
200
201/* ------------------------------------------------------------------ */
202/* Field element arithmetic */
203/* ------------------------------------------------------------------ */
204
210void qsc_fe448_0(qsc_fe448 h);
211
217void qsc_fe448_1(qsc_fe448 h);
218
225void qsc_fe448_copy(qsc_fe448 h, const qsc_fe448 f);
226
236void qsc_fe448_add(qsc_fe448 h, const qsc_fe448 f, const qsc_fe448 g);
237
247void qsc_fe448_sub(qsc_fe448 h, const qsc_fe448 f, const qsc_fe448 g);
248
257void qsc_fe448_neg(qsc_fe448 h, const qsc_fe448 f);
258
266void qsc_fe448_cswap(qsc_fe448 f, qsc_fe448 g, uint32_t b);
267
277void qsc_fe448_cmov(qsc_fe448 f, const qsc_fe448 g, uint32_t b);
278
285int32_t qsc_fe448_is_negative(const qsc_fe448 f);
286
293int32_t qsc_fe448_is_zero(const qsc_fe448 f);
294
304void qsc_fe448_mul(qsc_fe448 h, const qsc_fe448 f, const qsc_fe448 g);
305
315void qsc_fe448_mul32(qsc_fe448 h, const qsc_fe448 f, uint32_t n);
316
325void qsc_fe448_sq(qsc_fe448 h, const qsc_fe448 f);
326
335void qsc_fe448_sq2(qsc_fe448 h, const qsc_fe448 f);
336
343void qsc_fe448_from_bytes(qsc_fe448 h, const uint8_t* s);
344
351void qsc_fe448_reduce(qsc_fe448 h, const qsc_fe448 f);
352
359void qsc_fe448_to_bytes(uint8_t* s, const qsc_fe448 h);
360
369void qsc_fe448_invert(qsc_fe448 out, const qsc_fe448 z);
370
371/* ------------------------------------------------------------------ */
372/* Group element operations */
373/* ------------------------------------------------------------------ */
374
381void qsc_ge448_p1p1_to_p3(qsc_ge448_p3* r, const qsc_ge448_p1p1* p);
382
389void qsc_ge448_p1p1_to_p2(qsc_ge448_p2* r, const qsc_ge448_p1p1* p);
390
399void qsc_ge448_scalarmult_base(qsc_ge448_p3* h, const uint8_t* a);
400
407void qsc_ge448_p3_to_bytes(uint8_t* s, const qsc_ge448_p3* h);
408
415int32_t qsc_ge448_is_canonical(const uint8_t* s);
416
423int32_t qsc_ge448_has_small_order(const uint8_t s[57U]);
424
435int32_t qsc_ge448_from_bytes_negate_vartime(qsc_ge448_p3* h, const uint8_t* s);
436
443void qsc_ge448_p3_to_cached(qsc_ge448_cached* r, const qsc_ge448_p3* p);
444
454void qsc_ge448_add_cached(qsc_ge448_p1p1* r, const qsc_ge448_p3* p, const qsc_ge448_cached* q);
455
465void qsc_ge448_sub_cached(qsc_ge448_p1p1* r, const qsc_ge448_p3* p, const qsc_ge448_cached* q);
466
476void qsc_ge448_add_precomp(qsc_ge448_p1p1* r, const qsc_ge448_p3* p, const qsc_ge448_precomp* q);
477
487void qsc_ge448_sub_precomp(qsc_ge448_p1p1* r, const qsc_ge448_p3* p, const qsc_ge448_precomp* q);
488
499void qsc_ge448_double_scalarmult_vartime(qsc_ge448_p2* r, const uint8_t* a,
500 const qsc_ge448_p3* A, const uint8_t* b);
501
508void qsc_ge448_to_bytes(uint8_t* s, const qsc_ge448_p2* h);
509
510/* ------------------------------------------------------------------ */
511/* Scalar arithmetic */
512/* ------------------------------------------------------------------ */
513
522void qsc_sc448_clamp(uint8_t* k);
523
530int32_t qsc_ed448_small_order(const uint8_t s[57U]);
531
538int32_t qsc_sc448_is_canonical(const uint8_t s[57U]);
539
548void qsc_sc448_muladd(uint8_t s[57U], const uint8_t a[57U], const uint8_t b[57U],
549 const uint8_t c[57U]);
550
556void qsc_sc448_reduce(uint8_t s[114U]);
557
566int32_t qsc_sc448_verify(const uint8_t* x, const uint8_t* y, size_t n);
567
568QSC_CPLUSPLUS_ENABLED_END
569
570/* \endcond NO_DOCUMENT */
571
572#endif
Contains common definitions for the Quantum Secure Cryptographic (QSC) library.