1 /* Copyright (c) 2023, Google LLC 2 * 3 * Permission to use, copy, modify, and/or distribute this software for any 4 * purpose with or without fee is hereby granted, provided that the above 5 * copyright notice and this permission notice appear in all copies. 6 * 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ 14 15 #ifndef OPENSSL_HEADER_CRYPTO_SPX_MERKLE_H 16 #define OPENSSL_HEADER_CRYPTO_SPX_MERKLE_H 17 18 #include <openssl/base.h> 19 20 #include <sys/types.h> 21 22 #include "./params.h" 23 24 #if defined(__cplusplus) 25 extern "C" { 26 #endif 27 28 29 // Algorithm 8: Compute the root of a Merkle subtree of WOTS+ public keys. 30 void spx_treehash(uint8_t out_pk[SPX_N], const uint8_t sk_seed[SPX_N], 31 uint32_t i /*target node index*/, 32 uint32_t z /*target node height*/, 33 const uint8_t pk_seed[SPX_N], uint8_t addr[32]); 34 35 // Algorithm 9: Generate an XMSS signature. 36 void spx_xmss_sign(uint8_t *sig, const uint8_t msg[SPX_N], unsigned int idx, 37 const uint8_t sk_seed[SPX_N], const uint8_t pk_seed[SPX_N], 38 uint8_t addr[32]); 39 40 // Algorithm 10: Compute an XMSS public key from an XMSS signature. 41 void spx_xmss_pk_from_sig(uint8_t *root, const uint8_t *xmss_sig, 42 unsigned int idx, const uint8_t msg[SPX_N], 43 const uint8_t pk_seed[SPX_N], uint8_t addr[32]); 44 45 // Algorithm 11: Generate a hypertree signature. 46 void spx_ht_sign(uint8_t *sig, const uint8_t message[SPX_N], uint64_t idx_tree, 47 uint32_t idx_leaf, const uint8_t sk_seed[SPX_N], 48 const uint8_t pk_seed[SPX_N]); 49 50 // Algorithm 12: Verify a hypertree signature. 51 int spx_ht_verify(const uint8_t sig[SPX_D * SPX_XMSS_BYTES], 52 const uint8_t message[SPX_N], uint64_t idx_tree, 53 uint32_t idx_leaf, const uint8_t pk_root[SPX_N], 54 const uint8_t pk_seed[SPX_N]); 55 56 57 #if defined(__cplusplus) 58 } // extern C 59 #endif 60 61 #endif // OPENSSL_HEADER_CRYPTO_SPX_MERKLE_H 62