<p><a href="https://github.com/bitcoinjs/bitcoinjs-lib" rel="nofollow noreferrer">bitcoinjs-lib</a> and <a href="https://github.com/bitpay/bitcore-lib" rel="nofollow noreferrer">bitcore-lib</a> are both javascript libraries that allow for key signing. </p>

<p>For example with bitcore-lib:</p>

<pre><code>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);
</code></pre>

<p>EDIT: To also include the verification example from bitcore's github. </p>

<pre><code>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);
</code></pre>

CC BY-SA 3.0
2017-03-28T03:39:37.010Z
how do you verify it?
Patoshi パトシ
CC BY-SA 3.0
2017-03-28T04:23:36.710Z
https://github.com/bitpay/bitcore-lib/blob/master/docs/examples.md#verify-a-bitcoin-message
m1xolyd1an
CC BY-SA 3.0
2017-03-29T17:22:38.613Z
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
CC BY-SA 3.0
2017-06-06T13:35:35.630Z
https://github.com/bitcoinjs/bitcoinjs-message
mixdev
CC BY-SA 3.0
2017-03-28T01:00:08.403Z
2017-06-08T01:11:19.870Z
2017-06-08T01:11:19.870Z
m1xolyd1an
<p>Is there a bitcoin library or even just pure javascript way of <strong>signing</strong> and <strong>verifying</strong> you own a btc address? </p>

<message-signing><javascript>
how do you sign and verify a message that you own a bitcoin address using javascript?
Patoshi パトシ
# how do you sign and verify a message that you own a bitcoin address using javascript?

(Asked by: username_0 on 2017-03-27)

Is there a bitcoin library or even just pure javascript way of **signing** and **verifying** you own a btc address?

**Tags:** message-signing, javascript


---

## 1 answers

### Answer by username_1 on 2017-03-28. Score: 6 | Accepted answer

[bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib) and [bitcore-lib](https://github.com/bitpay/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);

```

> **Comments:**
> **username_0**: how do you verify it?  
> **username_1**: https://github.com/bitpay/bitcore-lib/blob/master/docs/examples.md#verify-a-bitcoin-message  
> **username_2**: 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  
> **username_3**: https://github.com/bitcoinjs/bitcoinjs-message  

---

