Code Monkey home page Code Monkey logo

pengekrukka's Introduction

Pengekrukka - Hackathon

Pengekrukka (tongue in cheek name roughly translating to "Moneypot") is a Proof of Concept solution demonstrating an anonymous and decoupled transfer mechanism between the welfare state and an individual. It's implemented as part of a hackathon arranged by Norwegian Central Bank. The aim of the hackathon was to explore different opportunities, pitfalls and challenges offered by blockchain-based digital currency.

Utilizing Verifiable Credentials (VC's) and Zero Knowledge Proofs (ZKP's) we're demonstrating how a government server can issue money to a citizen entitled to financial support for a specific service. In our case, this is financial support for buying glasses, e.g. due to low income or similar. This example is however completely arbitrary. Our ZKP implementation is heavily based on Tornado Cash. If your goal is to learn more on how to implement this part of the system, we recommend you to check out their repo.

We've attempted to show the flow of the system in the below sequence diagram. In short, the citizen receives a VC from the doctor claiming that s/he needs glasses. The citizen then provides this to the government, along with an assumed ID-VC and gets a government backed VC with a secret that, crucially, only a specific optician can use to redeem the allotted money. This made possible through Asymmetric Encryption, encrypting the secret with the opticians public key.

Most of our solution is off-chain. Smart contracts on the blockchain is simply used as a way to ensure that money is transferred where it is supposed to, in a trustless manner; the actors in this system need minimal to no information about each other, but can still trust that everything works as it should.

sequenceDiagram
    actor Doctor
    actor Citizen
    participant Optician 
    participant Pengekrukka 
    participant Tornado as Tornado-contract
    
    Note left of Citizen: citizen-ID-VC from government issuer 
    Citizen ->> Doctor : I can't see (citizen-VC)
    Doctor -->> Citizen : VC documenting bad eyesight, signed by doctor

    Citizen ->> Pengekrukka : VC from doctor + citizen-ID-VC
    Pengekrukka ->> Pengekrukka: Calculating entitled support
    Pengekrukka ->> Tornado: Adding funds to the contract
    Tornado -->> Pengekrukka: "note" needed to redeem the funds
    Pengekrukka ->> Pengekrukka: Encrypted "note" with _opticians_ public key
    Pengekrukka ->> Citizen : Support-VC with 1) claim of entitlement and 2) encrypted note

    Citizen ->> Optician: Support-VC
    Optician ->> Optician: Decrypts Tornado-note 
    Optician ->> Tornado: Decrypted note 
    Tornado -->> Optician: Funds redeemed from contract
    Optician -->> Citizen: Gets glasses :)
Loading

Known Weaknesses

  • issuer of VC's not cryptographically validated (trivial to implement)
  • have to choose service supplier (i.e. optician) beforehand
  • a pure tornado cash implementation would lend itself to money laundring
  • anonymity is only as good as the anonymity set (i.e. the number of people using the system)
    • 1 deposit and 1 withdrawal creates a 1-1 mapping between the deposit and the withdrawal
  • anonymity is based on same amount in and out for all deposits and withdrawals. This creates a constraint on the system
  • probably lots more :)

// TODO fix this(fill envs automatically)

Local Development

  • Start a local blockchain with yarn contracts start
  • Extract ERC20 address and Tornado address from DeployLocal.json into env.development

Testing

  • Strive towards adding tests when writing new features
  • Share code between tests when possible, but not at the cost of clarity
  • Run tests with yarn <package> test

Working With Packages

Every package is located under ./packages. The monorepo is configured with Yarn Workspaces. The setup intends you to interact with the packages from root level. To run a command in a package, simply run yarn <package> <command>, e.g. yarn contracts test.

Adding a New Package

  1. add a folder under ./packages
  2. add ./packages/<YOUR-PACKAGE>/package.json-file with {"name": "@pengekrukka/<YOUR-PACKAGE>", "version": "0.0.1", "private": true}
  3. add "<YOUR-PACKAGE>": "yarn workspace @pengekrukka/<YOUR-PACKAGE>" under "scripts" in (root) ./package.json.

Environment

Local development expects a .env.development-file at the root level. Use .env.example as a reference.

pengekrukka's People

Contributors

aridder avatar olaven avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pengekrukka's Issues

Hansens Brilleforetning

Goal

The goal is to implement a fictional optician's store where the user can use the government-issued voucher VC they got from #39. As with both #39 and #38, this interaction could be physical in a real world implementation of our solution. It's digital for demo purposes only.

Group 21

TODO

GUI for Demo

Goal

A GUI that demonstrates our solution. It should show 1) relevant subsidies 2) login through wallet 3) relevant credentials for user

Todo

Sync linting

Our editors do linting slightly differently. This creates needlessly hard to read diffs. I thnk we should do linting on commit to avoid this, e.g. using husky

Backend issuing VC's

Goal

Endpoints issuing VC's for our use-cases.
For instance, one endpoint for Eidsiva and one for Tibber (if we are working with the energy case)

I propose that each VC provider (energy company) should have it's own package/endpoint/implementation. The ide ais to make it completely clear that these are different (hypothetical) services. To avoid making it too time consuming, however, I think we should share common interfaces between them.

flowchart TB

    subgraph shared
    CI["Common Interface"]
    end
    subgraph endpoints
    CI-->Tibber 
    CI-->Fjordkraft
    CI-->Fortum
    end
    subgraph webapp
    user-- Avhengig av strømselskap som blir oppgitt e.l. -->Fortum
    Fortum -- Forbruk-VC --> user
    end
Loading

Todo

Use VC Contracts

Goal

Use VC Contracts as contracts for verifying VC's and sending NOK funds.

Todo

  • Add TODOs like this and create issues out of them

Wallet + Wallet GUI

Goal

Implement a wallet that stores verifiable credentials fo a use, and provides a super-simple GUI with VC-cards
See Figma for GUI sketch.

TODO

Error signing in

Description

Failing to sign message when Metamask switches to Goerli.

Steps

  1. open app
  2. click "connect wallet"
  3. accept switching network in Metamask
  4. a window in the app says that I need to sign a message
  5. upon clicking "send message", metamask pops up with a dialogue to be confirmed
  6. sign through metamask
  7. app GUI says "Error verifying signature, please retry!"

Show that a transaction occurred

Goal

After the user has gone through #38, #39 and #40, a transaction should have occurred (#55). We want to show this to our audience.

TODO

  • Figure out how we can show this
  • Implement whatever we figure out

Write introduction to the project

When the project is nearing completion, I propose that we dedicate a large portion README.md to explain the project, and the use-case we attempt to show. This is useful for 1) us, preparing for a hackathon presentation, 2) anyone else checking out the project for the hackathon, and 3) others in the future, finding this project.

Legekontor Jensen

Goal

Implement a website representing a doctors office. While this interaction is digital in our demo, it could be physical in a real world implementation. The original design file is available on figma.
Group 19

Todo

Welfare System

Goal

Implement an imagined government organization akin to NAV where the user can upload certificats from (for instance) their doctor in exchange for voucher-VCs from the government. Original design files are available in Figma
Group 20

Todo

share wallet card component with web UI

TODO

  • Accepts color
  • Accepts VC object
  • Accepts icons
  • Renders color
  • Renders expiration
  • Renders icons
  • Renders title
  • Proportions like a credit card
  • matching design in figma
  • component is used by different pages

Test #56

We should have tests for the functionality added in #59.

Mirror solution that Song 2022 uses

Song et al 2022 describes a system for identity verification using VCs and blockchain. Our solution to identity verification should probably be similar.

From my notes (Norwegian):

I deres system lagres ikke [[Verifiable Credential]] i [[plain-text]] paa [[blockchain]]; Kun en hash av [[Verifiable Credential]], [[Zero Knowledge Proofs]] og den digitale signaturen til ID-provider lagres der.

paper.

(thanks to @aridder for pointing me to this)

Manage packages with Yarn Workspaces

I think we should add a tool to manage the packages in a way that allows for 1: dependency sharing and 2: running commands from root level. I suggest Yarn Workspaces since 1: it's easy to add, 2: it's fairly low level and only adds a few things on top of yarn, 3: we already use yarn and 4: I've had good experiences with it working on https://github.com/olaven/paperpod :)

@tordjon @aridder if you want to add your thoughts below, feel free :) I can add whatever we agree on.

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.