1

I have an interesting one off case with a Monero address generation where I am generating a 94 character Monero address vs 95 characters. However when I take the private_spend_key and run it through the monero_wallet_cli I get the full 95 characters. The address generated by the JS is this:

43pQ9h9F7KBFgDpFB1aa9ZAvqbxXa7zixfuFAUoybXzbnsy89jVH4YUG8Wwn1BzSFir8WGMkxHpq91XVNhcaaF27UsGFQw

But when creating it in the cli wallet I get this:

43pQ9h9F7KBFgDpFB1aa9ZAvqbxXa7zix1fuFAUoybXzbnsy89jVH4YUG8Wwn1BzSFir8WGMkxHpq91XVNhcaaF27UsGFQw

Notice the mising "1" before fuFaU

I'm not sure what is causing this issue to create a one off case of a malformed Monero address creation.

My code is in javascript with the following:

function keyToMonero(seed) {
seed = [ 26, 248, 94, 251, 77, 236, 73, 191, 132, 172, 51, 247, 227, 152, 99, 247, 97, 252, 142, 34, 29, 184, 192, 129, 53, 217, 217, 3, 145, 230, 103, 254 ];

  var private_spend = reduce32(seed);

console.log('private_spend');
console.log(private_spend);
console.log(private_spend.toString('hex'));
  var private_view = reduce32(keccak256(private_spend));
console.log('private_view');
console.log(private_view);

  // Hack
  var kp = ed25519.keyFromSecret()
  kp._privBytes = Array.from(private_spend);
  var public_spend = Buffer.from(kp.pubBytes());
  var kp = ed25519.keyFromSecret()
  kp._privBytes = Array.from(private_view);
  var public_view = Buffer.from(kp.pubBytes());


  var address_buf = Buffer.concat([Buffer.alloc(1, 0x12), public_spend, public_view])
  console.log('address_buf 1');
  console.log(address_buf);
  address_buf = Buffer.concat([address_buf, keccak256(address_buf).slice(0,4)]);

  console.log('address_buf 2');
  console.log(address_buf);

  var address = ''
console.log('Correct XMR Address:');
console.log('43pQ9h9F7KBFgDpFB1aa9ZAvqbxXa7zix1fuFAUoybXzbnsy89jVH4YUG8Wwn1BzSFir8WGMkxHpq91XVNhcaaF27UsGFQw');
  for (var i = 0; i < 8; i++) {
    address += bs58.encode(address_buf.slice(i*8, i*8+8));
    console.log('length'+ address.length);
    console.log(address_buf.slice(i*8, i*8+8));
    console.log(address);
  }
  address += bs58.encode(address_buf.slice(64, 69));

  console.log('length'+ address.length);
  console.log(address);

  return {
    private_spend: private_spend.toString('hex'),
    private_view: private_view.toString('hex'),
    public_spend: public_spend.toString('hex'),
    public_view: public_view.toString('hex'),
    public: address
  }
}

My console log output looks like this from the above code:

enter image description here

0
0

You aren't doing any padding.

See your related Q/A.

You have to pad blocks with '1's that convert to less than 11 characters.

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.