Grid Community Toolkit  6.2.1629922860 (tag: v6.2.20210826)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
xmss_fast.h
1 #ifdef WITH_XMSS
2 /* $OpenBSD: xmss_fast.h,v 1.2 2018/02/26 03:56:44 dtucker Exp $ */
3 /*
4 xmss_fast.h version 20160722
5 Andreas Hülsing
6 Joost Rijneveld
7 Public domain.
8 */
9 
10 #include "xmss_wots.h"
11 
12 #ifndef XMSS_H
13 #define XMSS_H
14 typedef struct{
15  unsigned int level;
16  unsigned long long subtree;
17  unsigned int subleaf;
18 } leafaddr;
19 
20 typedef struct{
21  wots_params wots_par;
22  unsigned int n;
23  unsigned int h;
24  unsigned int k;
25 } xmss_params;
26 
27 typedef struct{
28  xmss_params xmss_par;
29  unsigned int n;
30  unsigned int h;
31  unsigned int d;
32  unsigned int index_len;
33 } xmssmt_params;
34 
35 typedef struct{
36  unsigned int h;
37  unsigned int next_idx;
38  unsigned int stackusage;
39  unsigned char completed;
40  unsigned char *node;
41 } treehash_inst;
42 
43 typedef struct {
44  unsigned char *stack;
45  unsigned int stackoffset;
46  unsigned char *stacklevels;
47  unsigned char *auth;
48  unsigned char *keep;
49  treehash_inst *treehash;
50  unsigned char *retain;
51  unsigned int next_leaf;
52 } bds_state;
53 
58 void xmss_set_bds_state(bds_state *state, unsigned char *stack, int stackoffset, unsigned char *stacklevels, unsigned char *auth, unsigned char *keep, treehash_inst *treehash, unsigned char *retain, int next_leaf);
63 int xmss_set_params(xmss_params *params, int n, int h, int w, int k);
70 int xmssmt_set_params(xmssmt_params *params, int n, int h, int d, int w, int k);
76 int xmss_keypair(unsigned char *pk, unsigned char *sk, bds_state *state, xmss_params *params);
84 int xmss_sign(unsigned char *sk, bds_state *state, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg,unsigned long long msglen, const xmss_params *params);
90 int xmss_sign_open(unsigned char *msg,unsigned long long *msglen, const unsigned char *sig_msg,unsigned long long sig_msg_len, const unsigned char *pk, const xmss_params *params);
91 
92 /*
93  * Generates a XMSSMT key pair for a given parameter set.
94  * Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root]
95  * Format pk: [root || PUB_SEED] omitting algo oid.
96  */
97 int xmssmt_keypair(unsigned char *pk, unsigned char *sk, bds_state *states, unsigned char *wots_sigs, xmssmt_params *params);
105 int xmssmt_sign(unsigned char *sk, bds_state *state, unsigned char *wots_sigs, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen, const xmssmt_params *params);
109 int xmssmt_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk, const xmssmt_params *params);
110 #endif
111 #endif /* WITH_XMSS */