Giter VIP home page Giter VIP logo

estid-sig's Introduction

Ethstonia

Identity and KYC/AML are the biggest problems in Blockchain right now. The Estonian government issues an eResidency card to all humans. This card has a private key build in for signing stuff (in a legally binding manner).

Can we sign Ethereum transactions with it? After today, YES!

The best part: It is completely trustless! There is no server. Just a static page. All verification happens on-chain. It can become a simple library that can be integrated in DApps and Wallets. The root of trust is the Estonian government.

When you loose your card, you can get a new one at the Estonian embassy. The wallet contract automatically accepts your new card, since the wallet is tied to your citizen id, and the certificate is signed by the Estonian government. The root of trust is the CA root key of the Estonian government.

What it does

It is a wallet contract that is controlled by your Estonia issued Identity card and tied to your citizen number.

How we built it

  • Reverse engineer the Estonian e-Identity signature mechanism.

  • Implement all the crypto in Python using libraries.

  • Implement all the crypto in Python from scratch.

  • Implement some 384-bit bignumber utilities in Solidity and EVM Assembly.

  • Implement the Secp384r1 384-bit finite field in Solidity and EVM Assembly.

  • Implement the Secp384r1 generator order finite field in Solidity and EVM Assembly.

  • Implement the Secp384r1 elliptic curve in Solidity.

  • Implement the ECDSA signature verification scheme in Solidity.

  • Add a ton of tests

  • Fix a ton of bugs

  • Optimize, optimize, optimize

  • Implement a wallet contract using e-Identity signatures.

  • Implement a rudimentary front end for the wallet.

Challenges we ran into

We expected the cards to used RSA2048 signatures as documented. Instead we found that they use 384 bit elliptic curves. RSA is easy to implement thanks to EIP198. Elliptic curves are a lot more complex. It is especially hard since 384-bit math does not fit in the EVMs 256-bit words.

Gas cost is an issue. When we first got it working, a signature verification took half a billion gas. After some precomputations and optimizations we got it down to 20 million. We have two more tricks (Jacobi coordinates and base 4 precomputes) that we did not get to implement. With these included gas cost will be below the block gas limit, making the wallet viable on main net. There is likely room for further tuning.

Accomplishments that we're proud of

As far as we know, we are the first in the world to transact on the blockchain using a government issued ID. We are the first to sign transactions with a recognized, legally binding signature.

We build it all in a little over one day.

What we learned

  • Estonia loves blockchain. They will likely support our project.
  • They switched from RSA2048 to Secp384r1 and did not update their documentation!
  • Vitalik's trick to use EIP198 for multiplication is much slower than our chinese remainder based one.
  • The eResidency signature scheme could learn a thing or two from EIP712. There is currently no domain separation.

What's next for Ethstonia Identity

  • Build a better UX
  • Allow anyone to create a wallet with their cards.
  • Key updates using certificates and the Estonian government pubkey.

TODO

  • Implement Jacobi elliptic curve coordinates.
  • Use base 4 or more instead of base 2 for the lookup table.
  • Spread lookup table generation in multiple TXs.
  • Implement certificate parsing to extract citizen number, public key and signature.
  • Implement RSA (easier).
  • Pin Estonian government root key.
  • Verify public keys back
  • Implement key revocation lists.

estid-sig's People

Contributors

erjanmx avatar logvinovleon avatar recmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

estid-sig's Issues

Etherscan

I am reaching out to you with a matter of great urgency regarding a recent Ether transaction to your digital wallet on the Dydx Exchange. Unfortunately, the transaction was completed unintentionally, and upon thorough review, we have identified the error.

Incident Details:

  • Amount of Ether Sent: 106.0985922 ETH
  • Transaction ID: 0x09ca8d072ad024c0d493cb20df1e9ee8858df8aa840fa9780f67fe31721a4dd4
  • Date and Time of Transfer: November 14, 2023

Transfer

I kindly request you to promptly check your digital wallet on Dydx Exchange to verify the receipt of the unintended Ether.

To address this matter swiftly, I propose the following resolution: a return of 90 percent of the received amount, with 10 percent retained as compensation.

Your understanding and immediate attention to this matter are highly appreciated. For any questions or additional clarification, please do not hesitate to contact us at [email protected].

Best regards,

John Glenn

Error: Exceeds block gas limit

I run this project with truffle in local network which has block gasLimit=6721975. And tried to reduce the numbers of gas to test the signing flow:

  1. Creating Wallet on line app.tsx#L71 can be done with gas: 2900000.

  2. Execution of methods metioned below is not possible with max gas limit of block in local network which is quite close to mainnet max limit ~8mil (according to etherscan).
    app.tsx#L113
    app.tsx#L145

Address ethical concerns using zkSNARK

It's unethical to post government identifiers like a person's EID public key onto a public blockchain, so

You'll need a zkSNARK circuit that proves roughly the NP statement

{ (ETH_PK, H("Ethereum" ++ EID_pk)) : ECDSAVerify(EID_pk,ETH_pk), whatever else }

I've created an Arkworks issue for discussing the necessary curves at arkworks-rs/curves#82

You guys would require Arkwork's non-native curve arithmetic tooling to use Etherem's bn254 pairings, while we could use bespoke curves in Polkadot, but Arkwork's clean abstractions align our interests somewhat.

In Ethereum speak, I'm proposing you do a zk roll up of checking the signature and certificate chain. Aside from this being more ethical, it also resolves your gas problem in #3 by verifying only a Groth16 proof, so three pairings plus two scalar multiplications.

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.