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.
 
 
 
 
 

361 lines
16 KiB

  1. March 23, 2015:
  2. I've been fleshing out Decaf, and hopefully the API is somewhere
  3. near final. I will probably move a few things around and add a
  4. scalar inversion command (for AugPAKE and such).
  5. I've built a "decaf_fast" implementation which is about as fast as
  6. Goldilocks, except that verification still isn't as fast, because
  7. it needs a precomputed wNAF table which I haven't implemented yet.
  8. Precomputation is noticeably faster than in Goldilocks; while
  9. neither is especially optimized, the extended point format works
  10. slightly better for that purpose.
  11. While optimizing decaf_fast I also found a minor perf problem in
  12. the constant time lookup code, so that's fixed (I hope?) and
  13. everything is faster at least on my test machine.
  14. At some point soon-ish, I'd like to start removing the base
  15. Goldilocks code from this branch. That will require porting more
  16. of the tests. I might make a C++ header for Decaf, which would
  17. definitely simplify testing.
  18. March 1, 2015:
  19. While by no means complete or stable, I've done most of the ground
  20. work to implement the "Decaf" point encoding. This point encoding
  21. essentially divides the cofactor by 4, turning Goldilocks (or
  22. Ridinghood or E-521) into a prime-order group. Furthermore, like
  23. the Goldilocks encoding, this encoding avoids incompleteness in
  24. the twisted Edwards formulas with a=-1 by sticking to the order-2q
  25. subgroup.
  26. Because the group is prime order, and because the "isogeny strategy"
  27. is not needed, the decaf API can be very simple. I'm still working
  28. on exactly what it should be though. The goal is to have a single-
  29. file (or a few files) for a "ref" version, which is designed for
  30. auditability. The ref version won't be quite so simple as TweetNaCl,
  31. but nearly so simple and much better commented. Then there can also
  32. be an optimized version, perhaps per-platform, which is as fast as
  33. the original Goldilocks code but hopefully still simpler.
  34. I'm experimenting with SHAKE as the hash function here. Possibly I
  35. will also add Keyak as an encryption primitive, so that everything
  36. can be based on Keccak-f, but I'm open to suggestions. For example,
  37. if there's a way to make BLAKE2 as simple and useful as SHAKE
  38. (including in oversized curves like E-521), then the extra speed
  39. would certainly be welcome.
  40. October 27, 2014:
  41. Added more support for >512-bit primes. Changed shared secret
  42. to not overflow the buffer in this case. Changed hashing to
  43. SHA512-PRNG; this doesn't change the behavior in the case that
  44. only one block is required.
  45. E-521 appears to be working. Needs more testing, and maybe some
  46. careful analysis since the carry-handling bounds are awfully tight
  47. under the current analysis (the "< 5<<57" that it #if0 asserts is
  48. not actually tight enough under the current analysis; need
  49. it to be < (1+epsilon) << 59).
  50. So you actually do need to reduce often, at least in the x86_64_r12
  51. version.
  52. p521/arch_ref64: simple and relatively slow impl. Like
  53. p448/arch_ref64, this arch reduces after every add or sub.
  54. p521/arch_x86_64_r12: aggressive, fast implementation. This impl
  55. stores 521 bits not in 9 limbs, but 12! Limbs 3,7,11 are 0, and
  56. are there only for vector alignment. (TODO: remove those limbs
  57. from precomputed tables, so that we don't have to look them up!).
  58. The carry handling on this build is very tight, and probably could
  59. stand more analysis. This is why I have the careful balancing of
  60. "hexad" and "nonad" multiplies in its Chung-Hasan mul routine.
  61. (TODO: reconsider whether this is even worthwhile on machines
  62. without AVX2.)
  63. The 'r12 build is a work in progress, and currently only works on
  64. clang (because it rearranges vectors in the timesW function).
  65. Timings for the fast, aggressive arch on Haswell:
  66. mul: 146cy
  67. sqr: 111cy
  68. invert: 62kcy
  69. keygen: 270kcy
  70. ecdh: 803kcy
  71. sign: 283kcy
  72. verif: 907kcy
  73. Same rules as other Goldi benchmarks. Turbo off, HT off,
  74. timing-channel protected (no dataflow from secrets to branches,
  75. memory lookups or known vt instructions), compressed points.
  76. October 23, 2014:
  77. Pushing through changes for curve flexibility. First up is
  78. Ed480-Ridinghood, because it has the same number of words. Next
  79. is E-521.
  80. Experimental support for Ed480-Ridinghood. To use, compile with
  81. make ... FIELD=p480 -XCFLAGS=-DGOLDI_FIELD_BITS=480
  82. I still need to figure out what to do about the fact that the library
  83. is called "goldilocks", but in will soon support curves that are not
  84. ed448-goldilocks, at least experimentally.
  85. Currently the whole system's header "goldilocks.h" doesn't have
  86. a simpler way to override field size, but it does work (as a hack)
  87. with -DGOLDI_FIELD_BITS=...
  88. There is no support yet for coexistence of multiple fields in one
  89. library. The field routines will have unique names, but scalarmul*
  90. won't, and the top-level goldilocks routines have fixed names.
  91. Current timings on Haswell:
  92. Goldilocks: 178kcy keygen, 536kcy ecdh
  93. Ridinghood: 193kcy keygen, 617kcy ecdh
  94. Note that Ridinghood ECDH does worse than 480/448. This is at least
  95. in part because I haven't calculated the overflow handling limits yet
  96. in ec_point.h (this is a disadvantage of dropping the automated
  97. tool for generating that file). So I'm reducing much more often
  98. than I need to. (There's a really loud TODO in ec_point.h for that.)
  99. Also, I haven't tested the limits on these reductions in a while, so
  100. it could be that there are actual (security-critical) bugs in this
  101. area, at least for p448. Now that there's field flexibility, it's
  102. probably a good idea to make a field impl with extra words to check
  103. this.
  104. Furthermore, field_mulw_scc will perform differently on these two
  105. curves based on whether the curve constant is positive or negative.
  106. I should probably go optimize the "hot" routines like montgomery_step
  107. to have separate cases for positive and negative.
  108. September 29, 2014:
  109. Yesterday I put in some more architecture detection, but it should
  110. really be based on the arch directory, because what's in there really
  111. was a terrible hack. So I've changed it to use $arch/arch_config.h
  112. to get WORD_BITS.
  113. I've tweaked the eBAT construction code to rename the architectures
  114. using test/batarch.map. Maybe I should also rename them internally,
  115. but not yet.
  116. I added some new TODO.txt items. Some folks have been asking for a
  117. more factored library, instead of this combined arithmetic, curve code,
  118. encodings and protocol all-in-one jumble. Likewise the hash and RNG
  119. should be flexible.
  120. I've also been meaning to put more work in on SPAKE2EE, which would
  121. also mean finalizing the Elligator code.
  122. September 18, 2014:
  123. Begin work on a "ref" implementation. Currently this is just the
  124. arch_ref64 architecture. The ref implementation always weak_reduces
  125. after arithmetic, and doesn't use vectors or other hackery. Currently
  126. it still must declare field elements as vector aligned, though,
  127. other code outside the arch directory can be vectorized.
  128. Change goldilocks.c to use field_eq instead of calling deep into field
  129. apis.
  130. September 6, 2014:
  131. Pull in minor changes from David Leon Gil and Nicholas Wilson, with
  132. some adjustments. I hope the adjustments don't break their compiles.
  133. `make bat` now makes a bat which passes supercop-fastbuild, though
  134. the benchmarks are rather different from `make bench`. I need to track
  135. down why.
  136. August 4, 2014:
  137. Experiments and bug fixes.
  138. Add really_memset = memset_s (except not because I'm setting -std=c99),
  139. thanks David Leon Gil. I think I put it in the right places.
  140. Try to work around what I think is a compiler bug in GCC -O3 on non-AVX
  141. platforms. I can't seem to work around it as -Os, so I'm just flagging
  142. a warning (-Werror makes it an error) for now. Will take more
  143. investigation. Thanks Samuel Neves.
  144. Added an experimental (not ready yet!) ARM NEON implementation in
  145. arch_neon_experimental. This implementation seems to work, but needs
  146. more testing. It is currently asm-heavy and not GCC clean. I am
  147. planning to have a flag for it to use intrinsics instead of asm;
  148. currently the intrinsics are commented out. On clang this does ECDH
  149. in 1850kcy on my BeagleBone Black, comparable to Curve41417. Once this
  150. is ready, I will probably move it to arch_neon proper, since arch_neon
  151. isn't particularly tuned.
  152. July 11, 2014:
  153. This is mostly a cleanup release.
  154. Added CRANDOM_MIGHT_IS_MUST config flag (default: 1). When set, this
  155. causes crandom to assume that all features in the target arch will
  156. be available, instead of detecting them. This makes sense because
  157. the rest of the Goldilocks code is not (yet?) able to detect features.
  158. Also, I'd like to submit this to SUPERCOP eventually, and SUPERCOP won't
  159. pass -DMUST_HAVE_XXX on the command line the way the Makefile here did.
  160. Flag EXPERIMENT_CRANDOM_BUFFER_CUTOFF_BYTES to disable the crandom
  161. output buffer. This buffer improves performance (very marginally at
  162. Goldilocks sizes), but can cause problems with forking and VM
  163. snapshotting. By default, the buffer is now disabled.
  164. I've slightly tweaked the Elligator implementation (which is still
  165. unused) to make it easier to invert. This makes anything using Elligator
  166. (i.e. nothing) incompatible with previous releases.
  167. I've been factoring "magic" constants such as curve orders, window sizes,
  168. etc into a few headers, to reduce the effort to port the code to other
  169. primes, curves, etc. For example, I could test the Microsoft curves, and
  170. something like:
  171. x^2 + y^2 = 1 +- 5382[45] x^2 y^2 mod 2^480-2^240-1
  172. ("Goldeneye"? "Ridinghood"?) might be a reasonable thing to try for
  173. 64-bit CPUs.
  174. In a similar vein, most of the internal code has been changed to say
  175. "field" instead of p448, so that a future version of magic.h can decide
  176. which field header to include.
  177. You can now `make bat` to create an eBAT in build/ed448-goldilocks. This
  178. is only minimally tested, though, because SUPERCOP doesn't work on my
  179. machine and I'm too lazy to reverse engineer it. It sets a new macro,
  180. SUPERCOP_WONT_LET_ME_OPEN_FILES, which causes goldilocks_init() to fall
  181. back to something horribly insecure if crandom_init_from_file raises
  182. EMFILE.
  183. Slightly improved documentation.
  184. Removed some old commented-out code; restored the /* C-style */ comment
  185. discipline.
  186. The AMD-64 version should now be GCC clean, at least for reasonably
  187. recent GCC (tested on OS X.9.3, Haswell, gcc-4.9).
  188. History no longer says "2104".
  189. May 3, 2014:
  190. Minor changes to internal routines mean that this version is not
  191. compatible with the previous one.
  192. Added ARM NEON code.
  193. Added the ability to precompute multiples of a partner's public key. This
  194. takes slightly longer than a signature verification, but reduces future
  195. verifications with the precomputed key by ~63% and ECDH by ~70%.
  196. goldilocks_precompute_public_key
  197. goldilocks_destroy_precomputed_public_key
  198. goldilocks_verify_precomputed
  199. goldilocks_shared_secret_precomputed
  200. The precomputation feature are is protected by a macro
  201. GOLDI_IMPLEMENT_PRECOMPUTED_KEYS
  202. which can be #defined to 0 to compile these functions out. Unlike most
  203. of Goldilocks' functions, goldilocks_precompute_public_key uses malloc()
  204. (and goldilocks_destroy_precomputed_public_key uses free()).
  205. Changed private keys to be derived from just the symmetric part. This
  206. means that you can compress them to 32 bytes for cold storage, or derive
  207. keypairs from crypto secrets from other systems.
  208. goldilocks_derive_private_key
  209. goldilocks_underive_private_key
  210. goldilocks_private_to_public
  211. Fixed a number of bugs related to vector alignment on Sandy Bridge, which
  212. has AVX but uses SSE2 alignment (because it doesn't have AVX2). Maybe I
  213. should just switch it to use AVX2 alignment?
  214. Beginning to factor out curve-specific magic, so as to build other curves
  215. with the Goldilocks framework. That would enable fair tests against eg
  216. E-521, Ed25519 etc. Still would be a lot of work.
  217. More thorough testing of arithmetic. Now uses GMP for testing framework,
  218. but not in the actual library.
  219. Added some high-level tests for the whole library, including some (bs)
  220. negative testing. Obviously, effective negative testing is a very difficult
  221. proposition in a crypto library.
  222. March 29, 2014:
  223. Added a test directory with various tests. Currently testing SHA512 Monte
  224. Carlo, compatibility of the different scalarmul functions, and some
  225. identities on EC point ops. Began moving these tests out of benchmarker.
  226. Added scan-build support.
  227. Improved some internal interfaces. Made a structure for Barrett primes
  228. instead of passing parameters individually. Moved some field operations
  229. to places that make more sense, eg Barrett serialize and deserialize. The
  230. deserialize operation now checks that its argument is in [0,q).
  231. Added more documentation.
  232. Changed the names of a bunch of functions. Still not entirely consistent,
  233. but getting more so.
  234. Some minor speed improvements. For example, multiply is now a couple cycles
  235. faster.
  236. Added a hackish attempt at thread-safety and initialization sanity checking
  237. in the Goldilocks top-level routines.
  238. Fixed some vector alignment bugs. Compiling with -O0 should now work.
  239. Slightly simplified recode_wnaf.
  240. Add a config.h file for future configuration. EXPERIMENT flags moved here.
  241. I've decided against major changes to SHA512 for the moment. They add speed
  242. but also significantly bloat the code, which is going to hurt L1 cache
  243. performance. Perhaps we should link to OpenSSL if a faster SHA512 is desired.
  244. Reorganize the source tree into src, test; factor arch stuff into src/arch_*.
  245. Make most of the code 32-bit clean. There's now a 32-bit generic and 32-bit
  246. vectorless ARM version. No NEON version yet because I don't have a test
  247. machine (could use my phone in a pinch I guess?). The 32-bit version still
  248. isn't heavily optimized, but on ARM it's using a nicely reworked signed/phi-adic
  249. multiplier. The squaring is also based on this, but could really stand some
  250. improvement.
  251. When passed an even exponent (or extra doubles), the Montgomery ladder should
  252. now be accept points if and only if they lie on the curve. This needs
  253. additional testing, but it passes the zero bit exponent test.
  254. On 32-bit, use 8x4x14 instead of 5x5x18 table organization. Probably there's
  255. a better heuristic.
  256. March 5, 2014:
  257. First revision.
  258. Private keys are now longer. They now store a copy of the public key, and
  259. a secret symmetric key for signing purposes.
  260. Signatures are now supported, though like everything else in this library,
  261. their format is not stable. They use a deterministic Schnorr mode,
  262. similar to EdDSA. Precomputed low-latency signing is not supported (yet?).
  263. The hash function is SHA-512.
  264. The deterministic hashing mode needs to be changed to HMAC (TODO!). It's
  265. currently envelope-MAC.
  266. Probably in the future there will be a distinction between ECDH key and
  267. signing keys (and possibly also MQV keys etc).
  268. Began renaming internal functions. Removing p448_ prefixes from EC point
  269. operations. Trying to put the verb first. For example,
  270. "p448_isogeny_un_to_tw" is now called "twist_and_double".
  271. Began documenting with Doxygen. Use "make doc" to make a very incomplete
  272. documentation directory.
  273. There have been many other internal changes.
  274. Feb 21, 2014:
  275. Initial import and benchmarking scripts.
  276. Keygen and ECDH are implemented, but there's no hash function.