0

I am receiving as input a private key string and a random string. Goal is to get public key and address.

  1. When I am receiving the string I do:

    var hash = Crypto.util.hexToBytes(privStr);

    this.priv = new BigInteger(hash);

  2. A random string:

    var hash = keccak256.array(suppliedKey);

    this.priv = new BigInteger(hash);

On both randomly work, am I doing it correctly?

UPDATE 1. In first case my issue was I was not appending "0x" as prefix of the string.

0
  1. In first case my issue was I was not appending "0x" as prefix of the string.

  2. My error was using keccak256.array(suppliedKey). The correct way was using:

    var privStr = keccak256(suppliedKey);

    var hash = Crypto.util.hexToBytes(privStr);

    this.priv = new BigInteger(hash);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.