You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xmss_core_fast.h 3.2 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef XMSS_CORE_H
  2. #define XMSS_CORE_H
  3. #include "params.h"
  4. typedef struct{
  5. unsigned int h;
  6. unsigned int next_idx;
  7. unsigned int stackusage;
  8. unsigned char completed;
  9. unsigned char *node;
  10. } treehash_inst;
  11. typedef struct {
  12. unsigned char *stack;
  13. unsigned int stackoffset;
  14. unsigned char *stacklevels;
  15. unsigned char *auth;
  16. unsigned char *keep;
  17. treehash_inst *treehash;
  18. unsigned char *retain;
  19. unsigned int next_leaf;
  20. } bds_state;
  21. /**
  22. * Initialize BDS state struct
  23. * parameter names are the same as used in the description of the BDS traversal
  24. */
  25. void xmss_set_bds_state(bds_state *state, unsigned char *stack,
  26. int stackoffset, unsigned char *stacklevels,
  27. unsigned char *auth, unsigned char *keep,
  28. treehash_inst *treehash, unsigned char *retain,
  29. int next_leaf);
  30. /**
  31. * Generates a XMSS key pair for a given parameter set.
  32. * Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root]
  33. * Format pk: [root || PUB_SEED] omitting algo oid.
  34. */
  35. int xmss_core_keypair(const xmss_params *params,
  36. unsigned char *pk, unsigned char *sk, bds_state *state);
  37. /**
  38. * Signs a message.
  39. * Returns
  40. * 1. an array containing the signature followed by the message AND
  41. * 2. an updated secret key!
  42. */
  43. int xmss_core_sign(const xmss_params *params,
  44. unsigned char *sk, bds_state *state,
  45. unsigned char *sm, unsigned long long *smlen,
  46. const unsigned char *m, unsigned long long mlen);
  47. /**
  48. * Verifies a given message signature pair under a given public key.
  49. *
  50. * Note: msg and mlen are pure outputs which carry the message in case verification succeeds. The (input) message is assumed to be within sm which has the form (sig||msg).
  51. */
  52. int xmss_core_sign_open(const xmss_params *params,
  53. unsigned char *m, unsigned long long *mlen,
  54. const unsigned char *sm, unsigned long long smlen,
  55. const unsigned char *pk);
  56. /*
  57. * Generates a XMSSMT key pair for a given parameter set.
  58. * Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root]
  59. * Format pk: [root || PUB_SEED] omitting algo oid.
  60. */
  61. int xmssmt_core_keypair(const xmss_params *params,
  62. unsigned char *pk, unsigned char *sk,
  63. bds_state *states, unsigned char *wots_sigs);
  64. /**
  65. * Signs a message.
  66. * Returns
  67. * 1. an array containing the signature followed by the message AND
  68. * 2. an updated secret key!
  69. */
  70. int xmssmt_core_sign(const xmss_params *params,
  71. unsigned char *sk,
  72. bds_state *states, unsigned char *wots_sigs,
  73. unsigned char *sm, unsigned long long *smlen,
  74. const unsigned char *m, unsigned long long mlen);
  75. /**
  76. * Verifies a given message signature pair under a given public key.
  77. */
  78. int xmssmt_core_sign_open(const xmss_params *params,
  79. unsigned char *m, unsigned long long *mlen,
  80. const unsigned char *sm, unsigned long long smlen,
  81. const unsigned char *pk);
  82. #endif