1

I'm trying to generate Private/Public Keys for Monero using only PHP.

This is the library I'm using:

https://github.com/sneurlax/monerophp/blob/master/src/cryptonote.php

This is my code:

require_once('src/cryptonote.php');

$Cryptonote = new Cryptonote();
$seed = $Cryptonote->gen_new_hex_seed(); //generate new random hex seed
$address = $Cryptonote->gen_private_keys($seed); //generate new random private key

print_r($address);

I receive this output:

Notice: Undefined variable: spendkey in /var/www/html/monero/src/cryptonote.php on line 72 Array ( [spendKey] => c2c511418397a682834576441911a68fb7fc0ab55db4cbf5e11ecd647a6c7402 [viewKey] => 4a078e76cd41a3d3b534b83dc6f2ea2de500b653ca82273b7bfad8045d85a400 )

The $seed seems to output and change but the viewKey stays the same.

How would I code this properly so that I can implement this in a webstore without using the Monero daemon?

Also, is there any downsides to generating keys like this?

1 Answers1

1

Line 72 in that file has a variable name that doesn't match the parameter name (notice the lowercase k in spendkey). Just edit that line replacing $spendkey with $spendKey should fix it.

jtgrassie
  • 19,601
  • 4
  • 17
  • 54