Smart contracts for the Open Registry
JavaScript HTML CSS
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Open Registry for IoT: Smart Contracts

This open source project represents Ethereum smart contracts which are at the essence of Open Registry for IoT. You can find contracts in /contracts directory.

  • Registrar — whitelisting contract, stores all Registrants which are allowed to add new Things to the registry.
  • Registry — registry itself, stores identities and information about all Things added.

Separate repository provides SDK which gives clear interface to the contracts for JavaScript.

Install Dependencies

$ npm install -g truffle
$ npm install -g ethereumjs-testrpc

Test contracts

$ testrpc
$ truffle test

URN Specification


In the Open Registry, all Things have identities. We have adopted a Uniform Resource Name (URN) standard format to represent these identities, ranging from cryptographic public keys to BLE & NFC device IDs. The URN format is easily readable and allows for the support of a wide variety of identities. It complies with current standards for representing products, books, electronics, etc., and can be used to identify literally anything without need to specify schema / protocol this identity can reached by. This extensibility is essential for building a universal and open platform for the Internet of Things.


Each identity will be split by : into multiple sections, denoting more specific information about the identity after each subsequent colon. The last section denotes the actual identity of the Thing.

<Category>[:<Subcategory>[:<sub-Subcategory> … ]]:<ID>

All categories are case-insensitive.






Electronic Product Code: Serialized Global Trade Item Number


Serial number


Elliptic Curve Public Key


RSA public key


Construction of Public Key

Public Key


Elliptic Curve Public Key


RSA Public Key


Elliptic curve using verified random parameters




Elliptic Curve Public Key

Asymmetric encryption public key is stored in open registry to securely verify authenticity identity of a Thing using by means of cryptographic signature.

From Raw ECC Public Key to Identity in the Open Registry

Here we will illustrate an example how to convert an uncompressed public key into URN identity to be stored in the Open Registry. Its assumed that you have already generated your ECC key pair.

The public key is represented as a point (x,y) on an elliptic curve. Convert point coordinates into their hexadecimal representations. For this example we will use the following point: x=0x7462163f89fc02b989e564cf7a2ce39a806273ee4042201fb5544cc794c48975 y=0xd53acb27ef5da1cba6ff90e3611637e55a14ce6a9ec25063cd0de943f1dd3b04


We're using format suggested in Uncompressed public keys: mark the first octet with 0x04 Compressed public keys: mark the first octet with the correct polarity byte 0x02, 0x03 depending on the polarity of the y coordinate (explained below).

The public key in an uncompressed representation is then: 047462163f89fc02b989e564cf7a2ce39a806273ee4042201fb5544cc794c48975d53acb27ef5da1cba6ff90e3611637e55a14ce6a9ec25063cd0de943f1dd3b04

Converting into URN Format

Before the uncompressed public key can be registered to the Open Registry, it must be converted into the correct URN format as described above. Since we are using ECC's secp256r1 standard, the URN prefix is pbk:ec:secp256r1.

Resulting URN:


Open Registry SDK

From here, the URN is fed into the Open Registry SDK. Here, it is parsed, compressed, and packaged to be deployed into the Open Registry. It matches the schema of the URN to identify what cryptographic standards are being used and adjusts the keys accordingly.


For ECC keys, the SDK checks the first byte. If the first byte is 0x04 then it compresses the key to minimize amount of data stored. If the first byte is 0x02 or 0x03 then it's already compressed.


Compression is done by eliminating Y coordinate from the public key, since elliptic curve is symmetric to X axis. Though information on which side of X the point is located is crucial. That's why polarity is appended to the x coordinate of compressed key. And since ECC uses modulo, one just need to know whether it's even or odd. To demonstrate consider values -1, 1 and modulo 5. Since -1 % 5 = 4 and 1 % 5 = 1 it's clearly distinguishable where value falls.

even --> 0x02
odd  --> 0x03

We've built our own library to compress and decompress public keys for secp256r1. It can be found at:

Specifically, the method is ec.compress(<Public key>); For our example, compressing will result in: 027462163f89fc02b989e564cf7a2ce39a806273ee4042201fb5544cc794c48975. Now public key is compressed and ready to be deployed as an identity of a Thing in the Open Registry.

RSA Public Key

URN format of an RSA public key is as follows:

pbk:rsa:<key size in bits>:<public key of defined size><exponent used>

A sample RSA public key in URN format with 2048 bits key and exponent 0x010001 is:


Electronic Product Code

We're using same format described in the standard, though urn: prefix is omitted for brevity. Before EPC identity is getting stored in Open Registry ID portion of URN is encoded following standard description.

Useful Resources

Standards naming: EPC Tag Data Standard:


Copyright (c) 2016 Chronicled, Inc. All rights reserved.