Takes 2 SIKE/SIDH implementations and runs them against each other until something goes wrong
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

107 líneas
6.3 KiB

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