README.md 4.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Decaf elliptic curve library
  2. This library is for elliptic curve research and practical application.
  3. It currently supports Ed448-Goldilocks and Curve25519.
  4. ## Mailing lists
  5. Because this is new software, please expect it to have bugs, perhaps
  6. even critical security bugs. If you are using it, please sign up for
  7. updates:
  8. * Security-critical announcements (very low volume, God willing): decaf-security@googlegroups.com
  9. * New version announcements (low volume): decaf-announce@googlegroups.com
  10. * Library discussion (potentially more volume): decaf-discuss@googlegroups.com
  11. ## General elliptic curve operations.
  12. This is a multi-purpose elliptic curve library. There is a C library,
  13. and a set of C++ wrapper headers. The C++ code consists entirely of
  14. inline calls, and has no compiled component.
  15. The library implements a fairly complete suite of operations on the
  16. supported curves:
  17. * Point and scalar serialization and deserialization.
  18. * Point addition, subtraction, doubling, and equality.
  19. * Point multiplication by scalars. Accelerated double- and dual-scalar multiply.
  20. * Scalar addition, subtraction, multiplication, division, and equality.
  21. * Construction of precomputed tables from points. Precomputed scalarmul.
  22. * Hashing to the curve with an Elligator variant. Inverse of elligator
  23. for steganography. These are useful eg for PAKE.
  24. Internally, the library uses twisted Edwards curves with the "decaf"
  25. technique to remove the curve's cofactor of 4 or 8. More about that
  26. later. The upshot is that systems using the "decaf" interface will
  27. be using a prime-order group, which mitigates one of the few
  28. disadvantages of Edwards curves. However, this means that it is not
  29. able to implement systems which care about cofactor information.
  30. The goal of this library is not only to follow best practices, but to
  31. make it easier for clients of the library to follow best practices.
  32. With a few well-marked exceptions, the functions in this library should
  33. be strongly constant-time: they do not allow secret data to flow to
  34. array indices, nor to control decisions except for a final failure
  35. check. Furthermore, the C++ wrapping uses RAII to automatically clear
  36. sensitive data, and has interfaces designed to prevent certain mistakes.
  37. ## CFRG cryptosystems.
  38. The library additionally supports two cryptosystems defined by the
  39. Crypto Forum Research Group (CFRG): the X448/X25519 Diffie-Hellman
  40. functions, and the EdDSA signature scheme. Future versions might
  41. support additional operations on these curves, such as precomputed
  42. signature verification or conversion of Ed25519 keys to Curve25519
  43. keys. (Or they might not. We'll see.)
  44. ## Symmetric crypto and hashing
  45. The Decaf library doesn't implement much symmetric crypto, but it does
  46. contain the hash functions required by the CFRG cryptosystems: SHA512,
  47. SHA-3 and SHAKE.
  48. ## Internals
  49. The "decaf" technique is described in https://eprint.iacr.org/2015/673
  50. While the title of that paper is "removing cofactors through point
  51. compression", it might be more accurate to say "through quotients and
  52. isogenies". The internal representation of points is as "even" elements
  53. of a twisted Edwards curve with a=-1. Using this subgroup removes a
  54. factor of 2 from the cofactor. The remaining factor of 2 or 4 is
  55. removed with a quotient group: any two points which differ by an element
  56. of the 2- or 4-torsion subgroup are considered equal to each other.
  57. When a point is written out to wire format, it is converted (by isogeny)
  58. to a Jacobi quartic curve, which is halfway between an Edwards curve
  59. and a Montgomery curve. One of the 4 or 8 equivalent points on the
  60. Jacobi quartic is chosen (it is "distinguished" according to certain
  61. criteria, such as having a positive x-coordinate). The x-coordinate of
  62. this point is written out. The y-coordinate is not written out, but the
  63. decoder knows which of the two possible y-coordinates is correct because
  64. of the distinguishing rules. See the paper for more details.
  65. ## Licensing
  66. Most of the source files here are by Mike Hamburg. Those files are (c)
  67. 2014-2016 Cryptography Research, Inc (a division of Rambus). All of these
  68. files are usable under the MIT license contained in LICENSE.txt.
  69. ## Caveats
  70. As mentioned in the license, there is absolutely NO WARRANTY on any of this
  71. code. This is an early release, and is likely to have security-critical
  72. bugs despite my best efforts.
  73. I've attempted to protect against timing attacks and invalid point attacks,
  74. but as of yet I've made no attempt to protect against power analysis.
  75. Cheers,
  76. -- Mike Hamburg