Hi devs!
I would like to prepare the paper-wallet voucher and will need NEM private keys and a correspondig NEM addresses for this. I am trying to find out how both will be created but will need your help as it seems that i have currently not all the infos i would need.
The development plan says: "ECDSA will be used to generate public / private key pairs"
Private key:
In Bitcoin the private key is a 32byte/256bit (random) value converted to hex. To create the wallet import format you add a 0x80 in front, double SHA-256 this, take first 4 byte as checksum, base58 encode (0x80 and privatekey + checksum) to get the final key in import format.
Questions:
Will NEM use the same logic to crate the WIF private key and will it as well use base58 or base32 to encode it?
What prefix will be added in front, 0x80 as well? Public key:
Bitcoin keys use the secp256k1 where a public key is a 65 byte long value consisting of a leading 0x04 and X and Y coordinates of 32 bytes each.
Here is the code for bitcoin as it says more then words:
var curve = getSECCurveByName("secp256k1") //found in bitcoinjs-lib/src/jsbn/sec.js
//convert our random array or private key to a Big Integer
var privateKeyBN = BigInteger.fromByteArrayUnsigned(input)
var curvePt = curve.getG().multiply(privateKeyBN)
var x = curvePt.getX().toBigInteger()
var y = curvePt.getY().toBigInteger()
var publicKeyBytes = integerToBytes(x,32) //integerToBytes is found in bitcoinjs-lib/src/ecdsa.js
publicKeyBytes = publicKeyBytes.concat(integerToBytes(y,32))
publicKeyBytes.unshift(0x04)
var publicKeyHex = Crypto.util.bytesToHex(publicKeyBytes)
The above code will give us the public key hex encoded for Bitcoin (uncompressed format).
Questions:
Will NEM use the same procedure to get the public key hex encoded?
Will there be a leading 0x04 as well?After we have the public key in hex it is time to convert it into an human readable address, the initial development plan says:
1 Perform SHA-3 hashing on the public key
2 Perform RIPEMD-160 hashing on the result of #1
3 Add version byte in front of the RIPEMD-160 hash
4 Perform SHA-3 hashing on the result of #3
5 Perform SHA-3 hashing on the result of #4
6 Let the first four bytes of #5 be the address checksum
7 Concatenate #3 and #6
8 Base32-encode #7
Questions:
What value is the version byte of #3?
Shouldn't #4 be a SHA-256 hash? Just asking because the plan says "...NEM will use the SHA-3 hash of a SHA-256 hash instead of a double SHA-256 hash..."
Will NEM use standard base32 or custom chars?I would be more than happy if you have some information or some code parts for me. It would be very helpful for the development of the paper-wallets.
Sorry, i don't want to disturb everybody with technical details here, if there is a dev around who is able to help please feel free to pm me insted of bore the forum with technical details.
Thanks for your help!