Hi, I have some user data and I want to be able to sign and verify with the users app private key. Very much welcome pointers on how to go about this. I’m trying for example…
var bitcoin = require('bitcoinjs-lib')
var bitcoinMessage = require('bitcoinjs-message')
const bytes = Buffer.from(appprivkey)
const privkeyBs58 = bs58.encode(bytes)
var keyPair = bitcoin.ECPair.fromWIF(privkeyBs58)
var privateKey = keyPair.privateKey
var signature = bitcoinMessage.sign(message, privkey, keyPair.compressed)
where this fails to get valid base 58 encoding of the private key - e.g.
Ah - think I just found the answer from bottom of this this post.
var privKeyWith01 = account.appPrivateKey + '01'
let privkey = hexStringToECPair(privKeyWith01).toWIF()
and then
var keyPair = bitcoin.ECPair.fromWIF(privkey)
var privateKey = keyPair.privateKey
var signature = bitcoinMessage.sign(message, privateKey, keyPair.compressed)
looks like it creates a valid signature but any general comments on this approach will be helpful?
I implemented this in my dapp, Blockusign. I wanted to to prove a real person with a human identity signed a document hash ( preferable with attestations to twitter/facebook etc… ). I wanted it to link back to the users blockstack id, not just a public key. Then I wanted to persist this immutably forever via an anchor of that data to bitcoin using Blockstack subdomains ( $$$$ much cheaper) I anchor twice a day, costing only a few cents per day at the current BTC transaction cost!