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.h 2.9 KiB

9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef XMSS_CORE_H
  2. #define XMSS_CORE_H
  3. #include "params.h"
  4. /**
  5. * Given a set of parameters, this function returns the size of the secret key.
  6. * This is implementation specific, as varying choices in tree traversal will
  7. * result in varying requirements for state storage.
  8. *
  9. * This function handles both XMSS and XMSSMT parameter sets.
  10. */
  11. unsigned long long xmss_xmssmt_core_sk_bytes(const xmss_params *params);
  12. /*
  13. * Generates a XMSS key pair for a given parameter set.
  14. * Format sk: [(32bit) index || SK_SEED || SK_PRF || PUB_SEED || root]
  15. * Format pk: [root || PUB_SEED], omitting algorithm OID.
  16. */
  17. int xmss_core_keypair(const xmss_params *params,
  18. unsigned char *pk, unsigned char *sk);
  19. /**
  20. * Signs a message. Returns an array containing the signature followed by the
  21. * message and an updated secret key.
  22. */
  23. int xmss_core_sign(const xmss_params *params,
  24. unsigned char *sk,
  25. unsigned char *sm, unsigned long long *smlen,
  26. const unsigned char *m, unsigned long long mlen);
  27. /**
  28. * Verifies a given message signature pair under a given public key.
  29. * Note that this assumes a pk without an OID, i.e. [root || PUB_SEED]
  30. */
  31. int xmss_core_sign_open(const xmss_params *params,
  32. unsigned char *m, unsigned long long *mlen,
  33. const unsigned char *sm, unsigned long long smlen,
  34. const unsigned char *pk);
  35. /*
  36. * Generates a XMSSMT key pair for a given parameter set.
  37. * Format sk: [(ceil(h/8) bit) index || SK_SEED || SK_PRF || PUB_SEED || root]
  38. * Format pk: [root || PUB_SEED] omitting algorithm OID.
  39. */
  40. int xmssmt_core_keypair(const xmss_params *params,
  41. unsigned char *pk, unsigned char *sk);
  42. /*
  43. * Derives a XMSSMT key pair for a given parameter set.
  44. * Seed must be 3*n long.
  45. * Format sk: [(ceil(h/8) bit) index || SK_SEED || SK_PRF || root || PUB_SEED]
  46. * Format pk: [root || PUB_SEED] omitting algorithm OID.
  47. */
  48. int xmssmt_core_seed_keypair(const xmss_params *params,
  49. unsigned char *pk, unsigned char *sk,
  50. unsigned char *seed);
  51. /**
  52. * Signs a message. Returns an array containing the signature followed by the
  53. * message and an updated secret key.
  54. */
  55. int xmssmt_core_sign(const xmss_params *params,
  56. unsigned char *sk,
  57. unsigned char *sm, unsigned long long *smlen,
  58. const unsigned char *m, unsigned long long mlen);
  59. /**
  60. * Verifies a given message signature pair under a given public key.
  61. * Note that this assumes a pk without an OID, i.e. [root || PUB_SEED]
  62. */
  63. int xmssmt_core_sign_open(const xmss_params *params,
  64. unsigned char *m, unsigned long long *mlen,
  65. const unsigned char *sm, unsigned long long smlen,
  66. const unsigned char *pk);
  67. #endif