ethereumjs / ethereumjs-wallet

Utilities for handling Ethereum keys
MIT License
986 stars 295 forks source link

Private key does not satisfy the curve requirements (ie. it is invalid #174

Open crispy-coffee opened 2 years ago

crispy-coffee commented 2 years ago

`const util = require("ethereumjs-util"); 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"); } } ` Can Anyone help me, please? It gives me the error "throw new Error('Private key does not satisfy the curve requirements (ie. it is invalid)');" it's been 5 days of debugging the code but still no luck; please correct the code and resend it.

jochem-brouwer commented 2 years ago

Your private keys are not 32 bytes in length.