Giter Club home page Giter Club logo

eigen-secret's Introduction

Eigen Secret

Eigen Secret is a zk-zkRollup providing confidential transaction and selective exposure for users with low gas cost.

Building on Private State Model and zkSnark.

The circuits is written by Circom 2, proved by eigen zkit.

Task

npx hardhat --help

Gas Reporter

npx hardhat test

ETH Price: 1899.33 usd/eth

GasPrice: 20Gwei

Contract Method gas consumption

Contract Method Min Max Avg usd(avg)
Rollup approveToken - - 63083 2.40
Rollup deposit - - 226016 8.59
Rollup processDeposits - - 2086729 79.27
Rollup registerToken - - 49443 1.88
Rollup update 333467 350963 339443 12.89
Rollup withdraw - - 983815 37.37
TestToken approve 46223 46235 46229 1.76
TestToken transfer 26678 51378 50142 1.90
TokenRegistry setRollupNC - - 46053 1.75

Contract deployment gas consumption

Deployments Min Max Avg usd(avg)
PoseidonFacade - - 354579 13.47
Rollup - - 4390248 166.77
SMT 358301 358313 358307 13.61
SpongePoseidon - - 271682 10.32
TestToken - - 735448 27.94
TokenRegistry - - 310495 11.79

SDK

The SDK tutorial is generated by typedoc.

Licence

Not determined, any suggestions are welcome.

eigen-secret's People

Contributors

bc-a avatar eigmax avatar ibmp33 avatar jangoccc 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

Watchers

 avatar  avatar  avatar

eigen-secret's Issues

Test case design

Now the simple tests have been passed as per the Readme, the next step we need make sure the complex cases work well.

common setup: deploy contracts, and register one token at least, can use gist scripts here.

id operations result expected pass or not fix
0 common setup;
alice deposit(s) 10;
alias deposit(s) 10;
error_1 Alice's balance should be 20 n #84
1 common setup;
alice deposit(s) 10;
alias deposit(s) 10;
alias deposit(s) 10;
Bob deposit(s) 10;
Bob deposit(s) 10;
Bob sends Alice 11
- Alice's balance should be 41;
Bob's Balance should be 9
y -
2 case 1;
Bob withdraw(s) 9
error_1 Alice's balance should be 41;
Bob's Balance should be 0
n #84
3 case 2;
Alice withdraw(s) 12
error_2 Alice's balance should be 29;
Bob's Balance should be 0
n #85
4 case 3;
Alice send(s) Bob 11
- Alice's balance should be 18;
Bob's Balance should be 11
y -
5 case 4;
Alice withdraw(s) 18
- Alice's balance should be 0;
Bob's Balance should be 11
y -
6 case 5;
Bob withdraw(s) 11
- Alice's balance should be 0;
Bob's Balance should be 0
y -

Error:

  1. error_1
Error: Error: Assert Failed.
Error in template JoinSplit_491 line: 256
Error in template UpdateState_492 line: 102

    at /home/dell/Projects/eigen-secret/circuits/main_update_state_js/witness_calculator.js:161:27
    at Array.forEach (<anonymous>)
    at WitnessCalculator._doCalculateWitness (/home/dell/Projects/eigen-secret/circuits/main_update_state_js/witness_calculator.js:136:14)
    at WitnessCalculator.calculateWTNSBin (/home/dell/Projects/eigen-secret/circuits/main_update_state_js/witness_calculator.js:212:20)
    at Function.updateState (/home/dell/Projects/eigen-secret/core/dist/prover.js:15:55)
    at async SecretSDK.deposit (/home/dell/Projects/eigen-secret/sdk/dist/index.js:243:41)
    at async SimpleTaskDefinition.action (/home/dell/Projects/eigen-secret/tasks/transaction.ts:61:33)
    at async Environment._runTaskDefinition (/home/dell/Projects/eigen-secret/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14)
    at async Environment.run (/home/dell/Projects/eigen-secret/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14)
    at async main (/home/dell/Projects/eigen-secret/node_modules/hardhat/src/internal/cli/cli.ts:277:7)
  1. error_2
AssertionError: expected '1303082764185517615576280214259830761…' to equal '1835262063073854652783164453804654101…'
    at SecretSDK.withdraw (/home/dell/Projects/eigen-secret/sdk/dist/index.js:519:51)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SimpleTaskDefinition.action (/home/dell/Projects/eigen-secret/tasks/transaction.ts:150:33)
    at async Environment._runTaskDefinition (/home/dell/Projects/eigen-secret/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14)
    at async Environment.run (/home/dell/Projects/eigen-secret/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14)
    at async main (/home/dell/Projects/eigen-secret/node_modules/hardhat/src/internal/cli/cli.ts:277:7) {
  showDiff: true,
  actual: '13030827641855176155762802142598307611003275052490893836070115368930574435547',
  expected: '18352620630738546527831644538046541017872781130675447308190206077745304755598',
  operator: 'strictEqual'
}

refactor: transaction

Currently, the transaction just includes input notes, so we can not reconstruct the whole transaction when retrieving a user's trade history.

The transaction is actually useless nearly, the only case is we use it to help encrypt input/output notes together and finally transmit the plain note to TxData. Obviously, this makes no sense for class Transaction.

Another thought is if we need to achieve selective exposure, we need the entire transaction.

So I open this issue to discuss the redesign of transaction class.

Refactor account system

  • Refactor eth sign/recover from eth-sig-util
  • Bind EOA to alias hash
  • Migrate account and it's EOA

migrate-account test failed

Now the simple tests have been passed as per the Readme, the next step we need make sure the complex cases work well.

common setup: deploy contracts, and register one token at least, can use gist scripts here.

update-account test( update user signing key )

id operations result expected pass or not fix
0 common setup;
alice deposit(s) 10;
alias deposit(s) 10;
alias deposit(s) 10;
Bob deposit(s) 10;
Bob deposit(s) 10;
Bob sends Alice 11
- Alice's balance should be 41;
Bob's Balance should be 9
y -
1 case 1;
Alice updateAccount
- Alice's balance should be 41;
Bob's Balance should be 9
y -
2 case 2;
Alice send(s) Bob 22
- Alice's balance should be 19;
Bob's Balance should be 31
y -
3 case 3;
Bob withdraw(s) 31
- Alice's balance should be 19;
Bob's Balance should be 0
y -
4 case 4;
Bob updateAccount
- Alice's balance should be 19;
Bob's Balance should be 0
y -
5 case 5;
Bob deposit(s) 10;
Alice sends Bob 11
Bob sends Alice 12
- Alice's balance should be 20;
Bob's Balance should be 9
y -
6 case 6;
Alice withdraw(s) 20
- Alice's balance should be 0;
Bob's Balance should be 0
y -

migrate-account test( update user accountKey )

id operations result expected pass or not fix
0 common setup;
alice deposit(s) 10;
alias deposit(s) 10;
alias deposit(s) 10;
Bob deposit(s) 10;
Bob deposit(s) 10;
Bob sends Alice 11
- Alice's balance should be 41;
Bob's Balance should be 9
y -
1 case 1;
Alice migrateAccount
- Alice's balance should be 41;
Bob's Balance should be 9
n -
2 case 2;
Alice send(s) Bob 22
- Alice's balance should be 19;
Bob's Balance should be 31
-
3 case 3;
Bob withdraw(s) 31
- Alice's balance should be 19;
Bob's Balance should be 0
-
4 case 4;
Bob migrateAccount
- Alice's balance should be 19;
Bob's Balance should be 0
-
5 case 5;
Bob deposit(s) 10;
Alice sends Bob 11
Bob sends Alice 12
- Alice's balance should be 20;
Bob's Balance should be 9
-
6 case 6;
Alice withdraw(s) 20
- Alice's balance should be 0;
Bob's Balance should be 0
-

Error:

  1. error_1
Error: Assert Failed.
Error in template ForceEqualIfEnabled_325 line: 56
Error in template SMTVerifier_402 line: 134
Error in template Membership_403 line: 25
Error in template Account_404 line: 189
Error in template UpdateState_492 line: 69

    at /Users/ioio33/eigen-secret/circuits/main_update_state_js/witness_calculator.js:161:27
    at Array.forEach (<anonymous>)
    at WitnessCalculator._doCalculateWitness (/Users/ioio33/eigen-secret/circuits/main_update_state_js/witness_calculator.js:136:14)
    at WitnessCalculator.calculateWTNSBin (/Users/ioio33/eigen-secret/circuits/main_update_state_js/witness_calculator.js:212:20)
    at Function.updateState (/Users/ioio33/eigen-secret/core/dist/prover.js:15:55)
    at async SecretSDK.migrateAccount (/Users/ioio33/eigen-secret/sdk/dist/index.js:650:37)
    at async SimpleTaskDefinition.action (/Users/ioio33/eigen-secret/tasks/account.ts:103:33)
    at async Environment._runTaskDefinition (/Users/ioio33/eigen-secret/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14)
    at async Environment.run (/Users/ioio33/eigen-secret/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14)
    at async main (/Users/ioio33/eigen-secret/node_modules/hardhat/src/internal/cli/cli.ts:277:7)

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.