Is there a bitcoin library or even just pure javascript way of signing and verifying you own a btc address?
Asked
Active
Viewed 1,739 times
1 Answers
5
bitcoinjs-lib and bitcore-lib are both javascript libraries that allow for key signing.
For example with bitcore-lib:
var Message = require('bitcore-message');
var privateKey = new bitcore.PrivateKey('L23PpjkBQqpAF4vbMHNfTZAb3KFPBSawQ7KinFTzz7dxq6TZX8UA');
var message = new Message('This is an example of a signed message.');
var signature = message.sign(privateKey);
EDIT: To also include the verification example from bitcore's github.
var Message = require('bitcore-message');
var address = '13Js7D3q4KvfSqgKN8LpNq57gcahrVc5JZ';
var signature = 'IBOvIfsAs/da1e36W8kw1cQOPqPVXCW5zJgNQ5kI8m57FycZXdeFmeyoIqJSREzE4W7vfDmdmPk0HokuJPvgPPE=';
var verified = new Message('This is an example of a signed message.').verify(address, signature);
m1xolyd1an
- 5,566
- 2
- 14
- 30
-
how do you verify it? – Patoshi パトシ Mar 28 '17 at 03:39
-
https://github.com/bitpay/bitcore-lib/blob/master/docs/examples.md#verify-a-bitcoin-message – m1xolyd1an Mar 28 '17 at 04:23
-
Here's an example with BitcoinJS in the Blockchain.info wallet: Sign: https://github.com/blockchain/My-Wallet-V3/blob/master/src/address.js#L260-L273 (ignore the code that refers to `secondPassword`) Verify: https://github.com/blockchain/My-Wallet-V3/blob/v3.28.6/src/helpers.js#L441-L443 – Sjors Provoost Mar 29 '17 at 17:22
-
https://github.com/bitcoinjs/bitcoinjs-message – mixdev Jun 06 '17 at 13:35