Git Product home page Git Product logo

digital-identity-1's Introduction

Digital-Identity using ERC 725/735

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

Architecture

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

Local Development

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 

Live Demo

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:

  1. Buyer:Employer deploys a new Identity Contract (or reuses one they deployed earlier).
  2. Buyer:Employer visits O2OIssuer/SellerBuyerBroker/verify and obtains a cryptographic signature proving that they control a particular email and phone-number.
  3. Buyer:Employer adds this Claim to their Identity Contract.
  4. Buyer:Employer tries to apply a job via a O2OIssuer/SellerBuyerBroker Listing Contract.
  5. Listing Contract looks at Buyer:Employerโ€™s Identity for a Claim issued by O2OIssuer/SellerBuyerBroker.
  6. Listing Contract recovers the public key from the Claim Signature and verifies it is still valid on the O2OIssuer/SellerBuyerBroker Issuer Contract.
  7. 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.

Troubleshooting

  • Chrome > Console: localStorage.clear();
  • Chrome > URL: chrome://settings/siteData

References:

Demo Walkthrough

  1. Screen upon loading: first Wallet-ID 0x313A for a person who desires a blockchain identity (Consumer:Developer).

image

  1. Click "Add an Identity" and deploy an identity contract with name "DevOps".

image

You can see the address of the Contract, as well as the Wallet-ID of the Owner.

  1. Switch the active wallet to the second, 0x56BE, for the role of a service that can verify Has Facebook or Has GitHub (Issuer:SellerBuyerBroker).

Again, you should see the address of this Contract, and the Wallet-ID of the Owner of this Contract.

  1. 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)

  2. 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.

image

  1. 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.

image

  1. 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.

image

image

DevOps now has on-chain proof of Facebook`!

image

  1. Now click the Job Posting Listing Contract under Claim Checkers, and then click on Apply Job! then Check Claim; You should see that this claim is returned as ClaimValid*.

image

DevOps is ready to start doing Blockchain Freelancer Marketplace!

===

digital-identity-1's People

Contributors

hoanganh25991 avatar o2oprotocol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.