Advice and answers from the BitPay Team

A Bitcoin SIN (System Identification Number), also referred to as an ID , is a digital identity using a cryptographic private-public key pair. A Bitcoin SIN is comparable to a Bitcoin address, as they are both able to be derived from the same type of public and private keys.

BitPay offers methods to create a Bitcoin SIN in 5 programming languages:

  • Elixir
  • Java
  • PHP
  • Python
  • Ruby


To pair your client using Elixir, you'll first generate a pem  file. A WebClient  can then be created from the pem file. Please note, it is necessary to persist the pem  file for re-use.

To generate a pem file by running the following:

pem = BitPay.KeyUtils.generate_pem

To create your webclient:

webclient = %BitPay.WebClient{pem:pem}

A URI can be added to pair with the test server.

webclient = %BitPay.WebClient{pem:pem, 


The BitPay server requires a public and private key which are used for all client interaction with the server. The public key is used to derive the client identity and to securely sign all API requests from the client. Storing your private key is necessary.

Depending on your circumstances, there are two methods to create a private key, internally or externally (and inject the key into the SDK).


Create a private key using the SDK:

ECKey key = KeyUtils.createEcKey();

Store the private key, as it is necessary, and inject it into the SDK:

this.bitpay = new BitPay(key);


Create the Private Key outside of the SDK:

String privateKey = 
ECKey key = KeyUtils.createEcKeyFromHexString(privateKey);

Inject the private key into the SDK:

this.bitpay = new BitPay(key);


To create a SIN using PHP, you must first create your keypair - or your private and public key. You will then use your keypair to derive your SIN. When creating your keypair and SIN, you must be sure to save your private key.

First, create your keys.php  file:


//Include autoload, as it’s a necessary component

//Create your private_key and public_key objects
$private_key = new \Bitpay\PrivateKey(‘./api.key');
$public_key = new \Bitpay\PublicKey(‘./');

// Assign a value to the private_key object
// Associate private_key with public_key, and then assign a
 value to the public_key object

// Use the key manager to persist keys
$manager = new \Bitpay\KeyManager(new \Bitpay\Storage\


Run  bitpay.php :

$ php bitpay.php

Which will return something like:

Bitpay\Token Object
    [token:protected] => RealTokenValueHere
    [resource:protected] =>
    [facade:protected] => merchant
    [createdAt:protected] => DateTime Object
            [date] => 2015-03-13 10:53:20
            [timezone_type] => 3
            [timezone] => America/New_York

    [policies:protected] => Array
            [0] => Array
                    [policy] => id
                    [method] => inactive
                    [params] => Array
                            [0] => SinHere



    [pairingCode:protected] => Ag65qWh
    [pairingExpiration:protected] => DateTime Object
            [date] => 2015-03-14 10:53:20
            [timezone_type] => 3
            [timezone] => America/New_York


Extract the pairingCode  from the response and use it to approve your API access on your dashboard, e.g.: 


To create a Bitcoin SIN using Python, you'll first create a pem  file from which you'll derive a Bitcoin SIN. To create a pem  file, you will first need to install the Python library using pip . Packages are available for Python 2.7 and Python 3.

With the package installed, import the BitPay Key Utilities:

import bitpay_key_utils as key_utils

Generate a pem  file by running the following:

pem = key_utils.generate_pem();

Save the pem file:

f = open("temp/local.pem", 'w');
f = write(pem);

Run the following to get the Bitcoin SIN from the pem  file:

sin = get_sin_from_pem(pem);

To pair your Bitcoin SIN, create a function for Merchant Token creation:

def create_merchant_token(self):
   payload = { 'id': self.client_id, 'facade': 'merchant'}
   headers = {"content-type": "application/json", "accept":
     "application/json", "X-accept-version": "2.0.0"}
     response = + "/tokens", verify=
       self.verify, data=json.dumps(payload), headers=
   except Exception as pro:
     raise BitPayConnectionError('Connection refused')
   if response.ok:
     return response.json()

Running the above code will return a response similar to the following response:

{u'data': [{u'pairingExpiration': 1426204460704,
u'dateCreated': 1426118060704, u'pairingCode': u'QmxX9Cv',
u'token': u'8wYeZP2gsXS9e7qLzP8bjP', u'policies':
[{u'policy': u'id', u'params': [u'TexR5Y32WeEZmHXQocVF9TdDfg6ytapbzHL'], u'method': u'inactive'}], u'facade': u'merchant'}]}

Extract the pairingCode  from the response and use it to approve your API access on your dashboard, e.g.: 


To create a Bitcoin SIN using Ruby, you must first create a pem file from which you will derive your Bitcoin SIN.

First, install the bitpay-sdk  Ruby gem:

gem install bitpay-sdk

Generate a pem file by running the following:

pem = Bitpay::KeyUtils.generate_pem

Save the pem file:'path','w') {|f| f.write(pem)}

Run the following to get the SIN from the pem file:

sin = Bitpay::KeyUtils.generate_sin_from_pem(pem)

Pairing a client in Ruby can be done using the PEM, OpenSSL, and the irb  (interactive Ruby) tool. Open the irb tool and import the bitpay_sdk:

require 'bitpay_sdk'

Create your client: (Negate the api_uri parameter to create a client on our live server. Note that for this example, we are pairing to BitPay's Test server.)

client =
'', pem:'pem.pem'), insecure: true)

Request pairing using the client:


Which will return something like:

 => {"data"=>[{"policies"=>[{"policy"=>"id", "method"=>
"inactive", "params"=>["Tf49SFeiUAtytFEW2EUqZgWj32nP51PK73M"]}], "token"=>"BKQyVdaGQZAArdkkSuvtZN5gcN2355c8vXLj5eFPkfuK", "dateCreated"=>1422474475162, "pairingExpiration"=>1422560875162, "pairingCode"=>"Vy76yTh"}]}

Extract the pairingCode  from the response and use it to approve your API access on your dashboard, e.g.: 

Did this answer your question?