How to protect your products against counterfeiting using Blockchain

Let us imagine the following situation: you walk into, say, a luxury watch shop, buy an item that caught your fancy, go home elated, only to open the prized box and, lo and behold, find that the timepiece for which you paid good money… is a knock-off!

Ring a bell? Who’s to blame and what can be done? You can feel your confidence in the watch manufacturer come crashing down. But is he really to blame when someone else rips him off? A debatable point, it would seem. Whatever the case may have been, however, it is clear that counterfeits cause immense loss of goodwill and damages to licensed manufacturers.

The use of EMC DPO and the Emercoin blockchain may solve this type of situation.

How it could work:

Imagine that you walk into the same luxury watch shop and select your timepiece. However, this time, before buying it you spot a captioned QR-code on the box that says something like ‘Scan me to make sure I am not a counterfeit’. You scan the QR-code that sends you to the producer’s website where you can directly read the data as to whether the product with this serial number exists or not, and whether it was purchased earlier by anyone else:

as well as a brief description of the product and its manufacturer:

You can also see whether a given product was already purchased earlier and activated (and in our hypothetical case, you can unmistakably infer that the product on sale in the shop was either in use or is counterfeited):

And so, let’s assume you make sure in the shop that the timepiece was not a knock-off and was not in use before. You buy it and go home. Now, while unpacking it, you spot another QR-code inside the box, hidden behind the opaque protective film, captioned with something like ‘Scan me to activate the product’. You unwrap the film, scan the QR-code, and press ‘Activate the product’:

you then enter your name (optional) and feedback on the product as well as set a password (with which you will later be able to change your feedback on the product, but only once):

After about 10 minutes, the data on purchase of this product will go public, both on the manufacturer’s website and the Emercoin blockchain, where anyone interested will be able to browse it:

{
“name”: “dpo:Your Company:DEMO-1001:0”,
“value”: “Item=Name of your product\nDescription=The description of your product\nPhoto=http://www.blockchainengine.org/wp-content/uploads/2016/04/Smart4.png\nOTP=bb680a8bcae3e5be23f3c9ed4d3d0e97d42cebe561f53a5a7502e2d150a937fb\nOwner=Garrett\nSecret=3aff84a0afcd7201b112652b8692975bcfdeb0060de5efbdaeb16d806f62848d\nComment=Cool !\nUpdated=1”,
“txid”: “ee1ed730e16c41c7a42b3b87bf5bd5936b2e69a6448f510e08dd70d40bf57c1e”,
“address”: “ERGPQNKpmJNaXeaq6ZDYwgghQDMBQGVema”,
“expires_in”: 255036,
“expires_at”: 471574,
“time”: 1488110346
}

You may say: ‘What does the blockchain have to do with all this? The manufacturer of the product can easily organize the same thing centrally!’ And indeed, this is true. However, using such a de-centralized storage system such as the blockchain guarantees complete transparency of the manufacturer’s operations. As a result, no one will get away with churning out undeclared ‘off-the-books’ products — everything will be made public and transparent. If the manufacturer makes a point of being transparent and honest, they will inevitably choose the Emercoin -based EMC DPO system.

EMC DPO Deployment on Your Server

In this section, we shall learn how to deploy and configure EMC DPO on your server, powered by the OS Ubuntu 16.04 LTS (amd64). It is also compatible with the following other operating systems: Ubuntu 14.04 LTS (amd64), Debian 8 (amd64, armhf), RHEL/CentOS 7 (x86_64).

1. Installing the Emercoind service

Let’s use the standard features to install Emercoind:

apt-key adv — keyserver keyserver.ubuntu.com — recv B58C58F4
add-apt-repository ‘deb http://download.emercoin.com/ubuntu xenial emercoin’
apt update && apt -y install emercoin

Make sure that emercoind is installed, working, and starting to download the blockchain:

emc getinfo
{
“version”: 60000,
“protocolversion”: 70002,
“walletversion”: 60000,
“balance”: 1.090000,
“newmint”: 0.000000,
“stake”: 0.000000,
“blocks”: 216541,
“moneysupply”: 39554119.651462,
“timeoffset”: 0,
“connections”: 8,
“proxy”: “”,
“ip”: “0.0.0.0”,
“difficulty”: 206196413.012576,
“testnet”: false,
“keypoololdest”: 1487850355,
“keypoolsize”: 501,
“mintonly”: false,
“unlocked_until”: 0,
“paytxfee”: 0.010000,
“relayfee”: 0.000100,
}

We wait until the blockchain is downloaded. Then we send some coins to the wallet (at the rate of 0.12 EMC approx. for one blockchain data creation/refreshment operation).

A new wallet address can be created by running the following command:

emc getnewaddress

2. Creating NVS entries

It is necessary to create entries in the blockchain’s NVS for the manufacturer (vendor) and for the products themselves (separate entry for each product unit).

2.1. Creating the main entry of the Vendor

Let’s define the input data. Let:

  • The manufacturer (vendor) be referred as “Your Company”
  • For the vendor logo, click this link: http://emercoin.com/images/main-logo.png
  • We would also like to create an additional field called ‘Description’, and enter the following data there: ‘The description of Your Company’
  • The entry will be active for 730 days

After that, such an entry can be created by running the following command:

emc name_new “dpo:Your Company” “Name=Your Company
Description=The description of your Company
Logo=http://emercoin.com/images/main-logo.png" 730

Once this command is executed, we get a Transaction ID code, if everything has gone successfully.

Wait until this entry has made it into the blockchain. To do this, run the command:

emc name_show “dpo:Your Company”

Once the entry is in the blockchain, we should see something like this:

{
“name”: “dpo:Your Company”,
“value”: “Name=Your Company\nDescription=The description of your Company\nLogo=http://emercoin.com/images/main-logo.png",
“txid”: “b11384b162e2d3d2900d10e942c6ae3aa8bca94801dc119677685d68d35c9712”,
“address”: “ERGPQNKpmJNaXeaq6ZDYwgghQDMBQGVema”,
“expires_in”: 127749,
“expires_at”: 343616,
“time”: 1487856529
}

Remember the ‘address’ field data — this is the main address from which all subsequent product entries will be derived.

We also have to devise a ‘salt’, that is, add an arbitrary set of symbols to user passwords to make it harder for phishers to bust passwords. As an example, we might form the following password: johNah2koosie3iG.

2.2. Creating Product Entries

Let’s define the input data. Let:

  • The product be called: “Name of your product”
  • For the photo of the product, click this link: http://www.blockchainengine.org/wp-content/uploads/2016/04/Smart4.png
  • We would also like to create an additional field called ‘Description’, and enter the following data there: ‘The description of your product’
  • For starters, we would like to create 100 serial numbers of the product: from SN-55001 to SN-55100
  • Each product entry will be active for 730 days

After that, such entries can be created by executing the following script (having first installed php-cli and pwgen):

#!/bin/bash
# Source: https://github.com/snvakula/svtools/blob/master/emcdpo-genbulk.sh
URL=”http://emcdpo.info/dpo"
SALT=”johNah2koosie3iG”
ADDRESS=”ERGPQNKpmJNaXeaq6ZDYwgghQDMBQGVema”
VENDOR=”Your Company”
ITEM=”Name of your product”
PHOTO=”http://www.blockchainengine.org/wp-content/uploads/2016/04/Smart4.png"
OTHERS=”Description=The description of your product”
PREFIX=”SN-”
FIRST=55001
LAST=55100
DAYS=730
while [ $FIRST -le $LAST ]; do
echo “Creating serial $PREFIX$FIRST:”
SECRET=$(pwgen 8 1)
OTP=$(php -r “echo(hash(‘sha256’, md5(‘$SECRET’.’$SALT’)));”)
echo “ * SECRET: $SECRET”
echo “ * OTP: $OTP”
echo “ * Public URL: $URL/key/$PREFIX$FIRST”
echo “ * Private URL: $URL/key/$PREFIX$FIRST?otp=$SECRET”
COUNT=0
while emc name_show “dpo:$VENDOR:$PREFIX$FIRST:$COUNT” >/dev/null 2>&1
do
let COUNT=COUNT+1
done
echo “ * NVS Record: dpo:$VENDOR:$PREFIX$FIRST:$COUNT”
VALUE=”Item=$ITEM\nPhoto=$PHOTO\n$OTHERS\nOTP=$OTP”
VALUE=$(echo -e “$VALUE”)
echo -n “ * Transaction ID: “
emc name_new “dpo:$VENDOR:$PREFIX$FIRST:$COUNT” “$VALUE” $DAYS $ADDRESS
echo
let FIRST=FIRST+1
done

where URL is the web address of EMC DPO deployment.

Execution of this script results in the creation of NVS entries (if you have done it all correctly) and data output to the console will look like:

Creating serial SN-55001:
* SECRET: maifeB32
* OTP: bb680a8bcae3e5be23f3c9ed4d3d0e97d42cebe561f53a5a7502e2d150a937fb
* Public URL: http://emcdpo.info/dpo/key/SN-55001
* Private URL: http://emcdpo.info/dpo/key/SN-55001?otp=maifeB32
* NVS Record: dpo:Your Company:SN-55001:0
* Transaction ID: 7e1c5a131887a08971225790047bf9e8asq3ca5f947beb9ba0ced6541931939f

We then save the Public URL and Private URL for each separate serial number, make QR-codes out of them, and place them as follows: one on the outside of the box; the other, naturally, inside the box, under the protective film.

3. EMC DPO Web Application Deployment

First we install dependencies and activate the desired modules:

apt install curl git apache2 libapache2-mod-php php-xml
a2enmod rewrite

Clone a git-repository into /var/www:

cd /var/www
git clone https://github.com/Emercoin/emcdpo

Install composer and its components:

cd /var/www/emcdpo/engine
curl -sS https://getcomposer.org/installer | php
php composer.phar install — prefer-dist

Designate the www-data user (or any other, through which the web server will be executing the code) as the owner of the emcdpo folder:

chown -R www-data:www-data /var/www/emcdpo/engine

Record our parameters into the file /var/www/emcdpo/engine/src/settings.php:

// General Settings
CONST DPO_VENDOR = ‘Your Company’;
CONST SALT = ‘johNah2koosie3iG’;
CONST NVS_DAYS = 730;
CONST ALLOWED_UPDATES = 2;
CONST SEARCH_DEPTH = 10;
// Emercoin RPC Settings
CONST RPC_TYPE = “https”;
CONST RPC_USERNAME = “emccoinrpc”;
CONST RPC_PASSWORD = “RahRoh6ca8chaf6naji9dfaazaeghaidiLooyePi4aeQuah9lai4Eij5gotoocha”;
CONST RPC_HOST = “localhost”;
CONST RPC_PORT = ‘6662’;

Emercoin RPC login details can be read in the file /etc/emercoin/emercoin.conf

Then configure the web-server. To do this, create an Apache configuration file /etc/apache2/sites-available/emcdpo.conf, with the following code an example of this:

Alias /dpo /var/www/emcdpo/engine/web
<Directory /var/www/emcdpo/engine/web>
Options -MultiViews
RewriteEngine On
RewriteBase /dpo
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</Directory>

Activate the configuration and restart Apache:

a2ensite emcdpo
systemctl restart apache2

Now EMC DPO will be available at the following address: http://YOURHOSTNAME/dpo, and it is now ready for use.

Then, based on received URL and codes, you can generate product labels. To do so, you can, for example, use this program (link)