message: Fix GroupElement::hash() bug
diff: #include <openssl/rand.h>
  +#include <array>
  +#include <climits>
  +#include <limits>
  #include <sstream>
  #include <stdexcept>
  @@ -531,11 +534,22 @@ std::vector<unsigned char> GroupElement::getvch() const {
  std::size_t GroupElement::hash() const
  {
  - const unsigned char *g = reinterpret_cast<const unsigned char *>(g_);
  + auto ge = gej_to_ge(*reinterpret_cast<secp256k1_gej *>(g_));
  std::size_t h = 0;
  - for (std::size_t i = 0; i < sizeof(secp256k1_gej); i++) {
  - h ^= g[i];
  + if (ge.infinity) {
  + return h;
  + }
  +
  + constexpr auto nlow = std::numeric_limits<decltype(h)>::digits - CHAR_BIT;
  + constexpr auto top = static_cast<decltype(h)>(~0) << nlow;
  + std::array<unsigned char, 32 * 2> coord;
  +
  + secp256k1_fe_get_b32(&coord[0], &ge.x);
  + secp256k1_fe_get_b32(&coord[32], &ge.y);
  +
  + for (auto b : coord) {
  + h = (h << CHAR_BIT) | (((h & top) >> nlow) ^ b);
  }
  return h;
  