An implementation of ERC 725 and ERC 735, proposed standard for managing Digital Identity on the Blockchain. We uses the Truffle framework and Ganache CLI for testing.
Using ERC 725, a Smart Contract can protect function calls from being executed unless the Sender has a verified Claim from a trusted Issuer; e.g. build a mechanism into our Smart Contracts to only allow interactions from reputable people. ERC-725 allows for many more use-cases, such as multi-sig execution approvals and verification by contract call instead of key validation.
Default Mnemonic:
logic cradle area quality lumber pitch radar sense dove fault capital observe
the class diagram to make extensive use of Solidity patterns for modular code i.e. libraries, abstract contracts and multiple inheritance:
+--------------+ +------------+
| | | |
| ERC 165 | | KeyStore** |
| | | |
+---+--------+-+ +----+-------+
| | |
+----v-----+ +v---------+ +----v-----+
| | | | | |
+-------------+ ERC 735* | | ERC 725* | | KeyBase* |
| | | | | | |
| +----------+ ++-+----+--+ +--+-------+------+--------------+
| | | | | | |
| | | | | | |
| +-----------------------+ | | +-----+-----+ +-----v-----+ +------v-------+
| | | | | | | | | |
| | +-------|----|-+ Pausable | | KeyGetter | | Destructible |
| | +--------------------|----|-+ | | | | |
| | | | | | +--+--------+ +-+---------+ +--+-----------+
| | | | +----+ | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
+v---v----v---+ +------v--v---+ +--v----v--+ | |
| | | | | | | |
|ClaimManager | | KeyManager | | MultiSig | | |
| | | | | | | |
+---+---------+ ++------------+ +--+-------+ | |
| | | | |
| | | | |
| | +---------v------------------v---+ |
| | | <----------+
| +--------> Identity |
| | (ERC 725 + 735) |
+---------------------> |
+--------------------------------+
* = Abstract contract
** = Library
NVM & Yarn
nvm install v9.11.1 &&
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - &&
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list &&
sudo apt-get update && sudo apt-get install yarn
Installation
#
git clone https://github.com/o2oprotocol/digital-identity &&
cd digital-identity &&
nvm use v9.11.1 && yarn install
Run
nvm use v9.11.1 &&
yarn clean &&
yarn start
Tests
yarn test
- http://digital-identity.o2oprotocol.com
- Certifiers provides Issuer-Services:
Demo Scripts
Imagine we want to deploy a Listing Contract (e.g. post a job to hire a Freelancer), but only allow interactions from Users (e.g. Developers) with a verified Has Facebook
& Has Github
. How can we accomplish this with Digital Identity ERC-725?
First, lets define the entities that will be interacting:
- The Consumer:Developer is an identity who wants to apply a posted job.
- The Issuer:SellerBuyerBroker is an identity which issues claims of type
FACEBOOK_VERIFIED
&GITHUB_VERIFIED
. Note: Buyer-Broker is HeadHunter. - The Listing:JobPosting will only allow Consumer:Developer with
FACEBOOK_VERIFIED
&GITHUB_VERIFIED
claims from an Issuer-HeadHunterService they trust.
Second, Consumer:Developer interact with a O2OIssuer/SellerBuyerBroker Listing Contract by following process:
- Buyer:Employer deploys a new Identity Contract (or reuses one they deployed earlier).
- Buyer:Employer visits O2OIssuer/SellerBuyerBroker/verify and obtains a cryptographic signature proving that they control a particular
email
andphone-number
. - Buyer:Employer adds this
Claim
to theirIdentity Contract
. - Buyer:Employer tries to apply a job via a O2OIssuer/SellerBuyerBroker
Listing Contract
. Listing Contract
looks at Buyer:EmployerโsIdentity
for aClaim
issued by O2OIssuer/SellerBuyerBroker.Listing Contract
recovers the public key from theClaim Signature
and verifies it is still valid on the O2OIssuer/SellerBuyerBrokerIssuer Contract
.- Transaction is allowed to proceed.
Now that the Buyer:Employer has a verified claim on their identity from O2OIssuer/SellerBuyerBroker, they can interact with any other contracts also accepting claims issued by O2OIssuer/SellerBuyerBroker.
- Chrome > Console:
localStorage.clear();
- Chrome > URL:
chrome://settings/siteData
- Screen upon loading: first Wallet-ID
0x313A
for a person who desires a blockchain identity (Consumer:Developer).
- Click "Add an Identity" and deploy an identity contract with name "DevOps".
You can see the address of the Contract, as well as the Wallet-ID of the Owner.
- Switch the active wallet to the second,
0x56BE
, for the role of a service that can verifyHas Facebook
orHas GitHub
(Issuer:SellerBuyerBroker).
Again, you should see the address of this Contract, and the Wallet-ID of the Owner of this Contract.
-
Switch the active wallet to the third,
0xCd5e
for the role to restrict access to only people with verified Facebook/Github accounts. (A marketplace for developers) -
Click "Add a Claim Checker" and deploy a contract called "Job Posting" with certifier of
Has Facebook
. This is the contract which will be limited to interacting to people with verified Facebook accounts.
- Switch to the first Wallet, belonging to "DevOps" then Click on the
Apply Job!
Listing Contract. After clicking on "Check Claim", you should see that the claim is returned as ClaimInvalid. At this point,DevOps
has no proof that has a Facebook account.
- In right column, you should see the
Add Claim
by our "SellerBuyerBroker" Certifier that has a Facebook account. Click "Approve" to accept this claim to Alice's identity.
DevOps now has on-chain proof of
Facebook`!
- Now click the
Job Posting
Listing Contract underClaim Checkers
, and then click onApply Job!
thenCheck Claim
; You should see that this claim is returned as ClaimValid*.
DevOps
is ready to start doing Blockchain Freelancer Marketplace!
===