Software APIs
fors.h
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // Derived from code in the SPHINCS+ reference implementation (CC0 license):
6 // https://github.com/sphincs/sphincsplus/blob/ed15dd78658f63288c7492c00260d86154b84637/ref/fors.h
7 
8 #ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_SIGVERIFY_SPHINCSPLUS_FORS_H_
9 #define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_SIGVERIFY_SPHINCSPLUS_FORS_H_
10 
12 #include "sw/device/silicon_creator/lib/error.h"
13 #include "sw/device/silicon_creator/lib/sigverify/sphincsplus/address.h"
14 #include "sw/device/silicon_creator/lib/sigverify/sphincsplus/context.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /**
21  * Derives the FORS public key from a signature.
22  *
23  * This can be used for verification by comparing to a known public key, or to
24  * subsequently verify a signature on the derived public key. The latter is the
25  * typical use-case when used as an FTS below an OTS in a hypertree. Assumes m
26  * contains at least kSpxForsHeight * kSpxForsTrees bits.
27  *
28  * @param sig FORS signature.
29  * @param m Message corresponding to the signature.
30  * @param ctx Context object.
31  * @param fors_addr A FORS tree address.
32  * @param[out] pk Resulting public key.
33  */
34 void fors_pk_from_sig(const uint32_t *sig, const uint8_t *m,
35  const spx_ctx_t *ctx, const spx_addr_t *fors_addr,
36  uint32_t *pk);
37 
38 #ifdef __cplusplus
39 }
40 #endif
41 
42 #endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_SIGVERIFY_SPHINCSPLUS_FORS_H_