Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

110 rindas
6.2 KiB

  1. /********************************************************************************************
  2. * Supersingular Isogeny Key Encapsulation Library
  3. *
  4. * Abstract: API header file for P751
  5. *********************************************************************************************/
  6. #ifndef __P751_API_H__
  7. #define __P751_API_H__
  8. #include "config.h"
  9. /*********************** Key encapsulation mechanism API ***********************/
  10. #define CRYPTO_SECRETKEYBYTES 644 // MSG_BYTES + SECRETKEY_B_BYTES + CRYPTO_PUBLICKEYBYTES bytes
  11. #define CRYPTO_PUBLICKEYBYTES 564
  12. #define CRYPTO_BYTES 24
  13. #define CRYPTO_CIPHERTEXTBYTES 596 // CRYPTO_PUBLICKEYBYTES + MSG_BYTES bytes
  14. // Algorithm name
  15. #define CRYPTO_ALGNAME "SIKEp751"
  16. // SIKE's key generation
  17. // It produces a private key sk and computes the public key pk.
  18. // Outputs: secret key sk (CRYPTO_SECRETKEYBYTES = 644 bytes)
  19. // public key pk (CRYPTO_PUBLICKEYBYTES = 564 bytes)
  20. int crypto_kem_keypair(unsigned char *pk, unsigned char *sk);
  21. // SIKE's encapsulation
  22. // Input: public key pk (CRYPTO_PUBLICKEYBYTES = 564 bytes)
  23. // Outputs: shared secret ss (CRYPTO_BYTES = 24 bytes)
  24. // ciphertext message ct (CRYPTO_CIPHERTEXTBYTES = 596 bytes)
  25. int crypto_kem_enc(unsigned char *ct, unsigned char *ss, const unsigned char *pk);
  26. // SIKE's decapsulation
  27. // Input: secret key sk (CRYPTO_SECRETKEYBYTES = 644 bytes)
  28. // ciphertext message ct (CRYPTO_CIPHERTEXTBYTES = 596 bytes)
  29. // Outputs: shared secret ss (CRYPTO_BYTES = 24 bytes)
  30. int crypto_kem_dec(unsigned char *ss, const unsigned char *ct, const unsigned char *sk);
  31. // Encoding of keys for KEM-based isogeny system "SIKEp751" (wire format):
  32. // ----------------------------------------------------------------------
  33. // Elements over GF(p751) are encoded in 94 octets in little endian format (i.e., the least significant octet is located in the lowest memory address).
  34. // Elements (a+b*i) over GF(p751^2), where a and b are defined over GF(p751), are encoded as {a, b}, with a in the lowest memory portion.
  35. //
  36. // Private keys sk consist of the concatenation of a 32-byte random value, a value in the range [0, 2^378-1] and the public key pk. In the SIKE API,
  37. // private keys are encoded in 644 octets in little endian format.
  38. // Public keys pk consist of 3 elements in GF(p751^2). In the SIKE API, pk is encoded in 564 octets.
  39. // Ciphertexts ct consist of the concatenation of a public key value and a 32-byte value. In the SIKE API, ct is encoded in 564 + 32 = 596 octets.
  40. // Shared keys ss consist of a value of 24 octets.
  41. /*********************** Ephemeral key exchange API ***********************/
  42. #define SIDH_SECRETKEYBYTES 48
  43. #define SIDH_PUBLICKEYBYTES 564
  44. #define SIDH_BYTES 188
  45. // SECURITY NOTE: SIDH supports ephemeral Diffie-Hellman key exchange. It is NOT secure to use it with static keys.
  46. // See "On the Security of Supersingular Isogeny Cryptosystems", S.D. Galbraith, C. Petit, B. Shani and Y.B. Ti, in ASIACRYPT 2016, 2016.
  47. // Extended version available at: http://eprint.iacr.org/2016/859
  48. // Generation of Alice's secret key
  49. // Outputs random value in [0, 2^372 - 1] to be used as Alice's private key
  50. void random_mod_order_A(unsigned char* random_digits);
  51. // Generation of Bob's secret key
  52. // Outputs random value in [0, 2^Floor(Log(2,3^239)) - 1] to be used as Bob's private key
  53. void random_mod_order_B(unsigned char* random_digits);
  54. // Alice's ephemeral public key generation
  55. // Input: a private key PrivateKeyA in the range [0, 2^372 - 1], stored in 47 bytes.
  56. // Output: the public key PublicKeyA consisting of 3 GF(p751^2) elements encoded in 564 bytes.
  57. int EphemeralKeyGeneration_A(const unsigned char* PrivateKeyA, unsigned char* PublicKeyA);
  58. // Bob's ephemeral key-pair generation
  59. // It produces a private key PrivateKeyB and computes the public key PublicKeyB.
  60. // The private key is an integer in the range [0, 2^Floor(Log(2,3^239)) - 1], stored in 48 bytes.
  61. // The public key consists of 3 GF(p751^2) elements encoded in 564 bytes.
  62. int EphemeralKeyGeneration_B(const unsigned char* PrivateKeyB, unsigned char* PublicKeyB);
  63. // Alice's ephemeral shared secret computation
  64. // It produces a shared secret key SharedSecretA using her secret key PrivateKeyA and Bob's public key PublicKeyB
  65. // Inputs: Alice's PrivateKeyA is an integer in the range [0, 2^372 - 1], stored in 47 bytes.
  66. // Bob's PublicKeyB consists of 3 GF(p751^2) elements encoded in 564 bytes.
  67. // Output: a shared secret SharedSecretA that consists of one element in GF(p751^2) encoded in 188 bytes.
  68. int EphemeralSecretAgreement_A(const unsigned char* PrivateKeyA, const unsigned char* PublicKeyB, unsigned char* SharedSecretA);
  69. // Bob's ephemeral shared secret computation
  70. // It produces a shared secret key SharedSecretB using his secret key PrivateKeyB and Alice's public key PublicKeyA
  71. // Inputs: Bob's PrivateKeyB is an integer in the range [0, 2^Floor(Log(2,3^239)) - 1], stored in 48 bytes.
  72. // Alice's PublicKeyA consists of 3 GF(p751^2) elements encoded in 564 bytes.
  73. // Output: a shared secret SharedSecretB that consists of one element in GF(p751^2) encoded in 188 bytes.
  74. int EphemeralSecretAgreement_B(const unsigned char* PrivateKeyB, const unsigned char* PublicKeyA, unsigned char* SharedSecretB);
  75. // Encoding of keys for KEX-based isogeny system "SIDHp751" (wire format):
  76. // ----------------------------------------------------------------------
  77. // Elements over GF(p751) are encoded in 94 octets in little endian format (i.e., the least significant octet is located in the lowest memory address).
  78. // Elements (a+b*i) over GF(p751^2), where a and b are defined over GF(p751), are encoded as {a, b}, with a in the lowest memory portion.
  79. //
  80. // Private keys PrivateKeyA and PrivateKeyB can have values in the range [0, 2^372-1] and [0, 2^378-1], resp. In the SIDH API, private keys are encoded
  81. // in 48 octets in little endian format.
  82. // Public keys PublicKeyA and PublicKeyB consist of 3 elements in GF(p751^2). In the SIDH API, they are encoded in 564 octets.
  83. // Shared keys SharedSecretA and SharedSecretB consist of one element in GF(p751^2). In the SIDH API, they are encoded in 188 octets.
  84. #endif