-1

Can Anyone help me, please? It gives me the error "throw new Error('Private key does not satisfy the curve requirements (i.e., it is invalid)');" it's been 5 days of debugging the code but still no luck; please correct the code and resend it.

const Wallet = require("ethereumjs-wallet");

var possible = "abcdef1234567890";
var basePrivateKey =
  "0x09e8568e418bcb88662b7d0094db85b24177ad68ae715dc871d07a5ef4c2a1";
var charsMissing = 66 - basePrivateKey.length;
var targetPublicAddress = " 0x3fFacFff9858168c4E0c34C6f88Eb9e6F8576c6B";
var missingPart = "";

for (var i = 0; i < charsMissing; i++) {
  missingPart = missingPart.concat(i);
}

var maxVal = parseInt(missingPart, 16);

console.log(
  ` \n searching for address : ${targetPublicAddress} \n base private key      : ${basePrivateKey} \n missing chars         : ${charsMissing} \n it will be quiet now. if you don't see anything below me, it's working on finding your key. \n If you see something below that doesn't say 'FOUND KEY!', you have an error \n `
);

function makeHexString(numb) {
  var hex = numb.toString(16);
  for (var i = 0; i < charsMissing - hex.length; i++) hex = "0" + hex;

  return hex;
}

for (var i = 0; i <= maxVal; i++) {
  for (var j = 0; j <= basePrivateKey.length; j++) {
    // console.log(" i : " + i + " : j : " + j + "\n");
    var endPrivateKey = makeHexString(i);
    var privateKeyGuess = [
      basePrivateKey.substring(0, j) +
        endPrivateKey +
        basePrivateKey.substring(j, basePrivateKey.length),
    ];

    var wallet = Wallet.fromPrivateKey(Buffer.from(privateKeyGuess, "hex"));

    var publicAddress = util.bufferToHex(wallet.getAddress());

    if (publicAddress.toLowerCase() == targetPublicAddress.toLowerCase()) {
      console.log(
        `Found Private Key: ${privateKeyGuess}\n matching address \n \n \n \n`
      );
      process.exit();
    }
  }
  if (i % 100000 === 0) {
    console.log("checked", i, "keys");
  }
}
Dev Verma
  • 1
  • 1

1 Answers1

0

Length of the basePrivateKey that you shared is 62 hex characters (prepended by 0x) which is 248 bits.

However the expected length is 64 hex characters (prepended by 0x), or 256 bits. In other words, your key is invalid because it's too short.

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100