Guest User

latest_libsec.patch

a guest
Apr 13th, 2015
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.58 KB | None | 0 0
  1. --- src/key.cpp 2015-04-11 12:17:04.944138927 -0300
  2. +++ ../crave-fork/src/key.cpp   2015-04-11 14:22:09.320457280 -0300
  3. @@ -26,11 +26,12 @@
  4.  #ifdef USE_SECP256K1
  5.  class CSecp256k1Init {
  6.  public:
  7. +    secp256k1_context_t* ctx;
  8.      CSecp256k1Init() {
  9. -        secp256k1_start(SECP256K1_START_SIGN);
  10. +        ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
  11.      }
  12.      ~CSecp256k1Init() {
  13. -        secp256k1_stop();
  14. +        secp256k1_context_destroy(ctx);
  15.      }
  16.  };
  17.  static CSecp256k1Init instance_of_csecp256k1;
  18. @@ -467,7 +468,7 @@
  19.  
  20.  bool CKey::SetPrivKey(const CPrivKey &privkey, bool fCompressedIn) {
  21.  #ifdef USE_SECP256K1
  22. -    if (!secp256k1_ec_privkey_import((unsigned char*)begin(), &privkey[0], privkey.size()))
  23. +    if (!secp256k1_ec_privkey_import(instance_of_csecp256k1.ctx, (unsigned char*)begin(), &privkey[0], privkey.size()))
  24.          return false;
  25.  #else
  26.      CECKey key;
  27. @@ -486,7 +487,7 @@
  28.  #ifdef USE_SECP256K1
  29.      privkey.resize(279);
  30.      int privkeylen = 279;
  31. -    int ret = secp256k1_ec_privkey_export(begin(), (unsigned char*)&privkey[0], &privkeylen, fCompressed);
  32. +    int ret = secp256k1_ec_privkey_export(instance_of_csecp256k1.ctx, begin(), (unsigned char*)&privkey[0], &privkeylen, fCompressed);
  33.      assert(ret);
  34.      privkey.resize(privkeylen);
  35.  #else
  36. @@ -502,7 +503,7 @@
  37.      CPubKey pubkey;
  38.  #ifdef USE_SECP256K1
  39.      int clen = 65;
  40. -    int ret = secp256k1_ec_pubkey_create((unsigned char*)pubkey.begin(), &clen, begin(), fCompressed);
  41. +    int ret = secp256k1_ec_pubkey_create(instance_of_csecp256k1.ctx, (unsigned char*)pubkey.begin(), &clen, begin(), fCompressed);
  42.      assert(ret);
  43.      assert(pubkey.IsValid());
  44.      assert((int)pubkey.size() == clen);
  45. @@ -524,7 +525,7 @@
  46.      do {
  47.          nonce.MakeNewKey(true);
  48.  
  49. -        if (secp256k1_ecdsa_sign(hash.begin(), (unsigned char*)&vchSig[0], &nSigLen, begin(),  secp256k1_nonce_function_rfc6979, NULL))
  50. +        if (secp256k1_ecdsa_sign(instance_of_csecp256k1.ctx, hash.begin(), (unsigned char*)&vchSig[0], &nSigLen, begin(),  secp256k1_nonce_function_rfc6979, NULL))
  51.          //if (secp256k1_ecdsa_sign((const unsigned char*)&hash, 32, (unsigned char*)&vchSig[0], &nSigLen, begin(), nonce.begin()))
  52.  
  53.          //if (secp256k1_ecdsa_sign((const unsigned char*)&hash, 32, vchSig.begin(), &nSigLen, begin(), nonce.begin()))
  54. @@ -548,7 +549,7 @@
  55.      CKey nonce;
  56.      do {
  57.          nonce.MakeNewKey(true);
  58. -        if (int ret = secp256k1_ecdsa_sign_compact(hash.begin(), &vchSig[1], begin(), secp256k1_nonce_function_rfc6979, NULL, &rec))
  59. +        if (int ret = secp256k1_ecdsa_sign_compact(instance_of_csecp256k1.ctx, hash.begin(), &vchSig[1], begin(), secp256k1_nonce_function_rfc6979, NULL, &rec))
  60.              break;
  61.      } while(true);
  62.  #else
  63. @@ -564,7 +565,7 @@
  64.  
  65.  bool CKey::Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck=false) {
  66.  #ifdef USE_SECP256K1
  67. -    if (!secp256k1_ec_privkey_import((unsigned char*)begin(), &privkey[0], privkey.size()))
  68. +    if (!secp256k1_ec_privkey_import(instance_of_csecp256k1.ctx, (unsigned char*)begin(), &privkey[0], privkey.size()))
  69.          return false;
  70.  #else
  71.      CECKey key;
  72. @@ -650,7 +651,7 @@
  73.      if (!IsValid())
  74.          return false;
  75.  #ifdef USE_SECP256K1
  76. -    if (!secp256k1_ec_pubkey_verify(begin(), size()))
  77. +    if (!secp256k1_ec_pubkey_verify(instance_of_csecp256k1.ctx, begin(), size()))
  78.          return false;
  79.  #else
  80.      CECKey key;
  81. @@ -665,7 +666,7 @@
  82.          return false;
  83.  #ifdef USE_SECP256K1
  84.      int clen = size();
  85. -    int ret = secp256k1_ec_pubkey_decompress((unsigned char*)begin(), &clen);
  86. +    int ret = secp256k1_ec_pubkey_decompress(instance_of_csecp256k1.ctx, (unsigned char*)begin(), &clen);
  87.      assert(ret);
  88.      assert(clen == (int)size());
  89.  #else
  90. @@ -707,7 +708,7 @@
  91.      memcpy(ccChild, out+32, 32);
  92.  #ifdef USE_SECP256K1
  93.      memcpy((unsigned char*)keyChild.begin(), begin(), 32);
  94. -    bool ret = secp256k1_ec_privkey_tweak_add((unsigned char*)keyChild.begin(), out);
  95. +    bool ret = secp256k1_ec_privkey_tweak_add(instance_of_csecp256k1.ctx, (unsigned char*)keyChild.begin(), out);
  96.  #else
  97.      bool ret = CECKey::TweakSecret((unsigned char*)keyChild.begin(), begin(), out);
  98.  #endif
  99. @@ -726,7 +727,7 @@
  100.      memcpy(ccChild, out+32, 32);
  101.  #ifdef USE_SECP256K1
  102.      pubkeyChild = *this;
  103. -    bool ret = secp256k1_ec_pubkey_tweak_add((unsigned char*)pubkeyChild.begin(), pubkeyChild.size(), out);
  104. +    bool ret = secp256k1_ec_pubkey_tweak_add(instance_of_csecp256k1.ctx, (unsigned char*)pubkeyChild.begin(), pubkeyChild.size(), out);
  105.  #else
  106.      CECKey key;
  107.      bool ret = key.SetPubKey(*this);
Advertisement
Add Comment
Please, Sign In to add comment