Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

private tx example (native) #45

Closed
brenzi opened this issue Jul 8, 2019 · 5 comments · Fixed by #61
Closed

private tx example (native) #45

brenzi opened this issue Jul 8, 2019 · 5 comments · Fixed by #61
Assignees

Comments

@brenzi
Copy link
Collaborator

brenzi commented Jul 8, 2019

Write an example for private transactions.

  • based on ERC20
  • coded in native Rust-inside-enclave (not in WASM-inside-enclave)
  • state must carry a hashmap with all account balances

Example Story

  1. (shielding) Alice sends substrate-native currency (SRML balances) to the substraTEE-worker account (an account for all substraTEE enclaves with a shared private key).
  2. The substraTEE-worker enclave creates a shielded account for Alice inside encrypted state
  3. Bob creates a keypair and tells Alice the pubkey
  4. Alice sends a shielded transfer request to substraTEE proxy (Alice to Bob: 10 tokens)
  5. substraTEE-worker enclave processes the request and transfers tokens from Alice to Bob. receipt is written onchain
  6. (optional) Alice verifies block inclusion of the receipt and sends Bob the receipt along with the shielded tx
  7. Bob queries his account balance directly with the substraTEE-worker with a signed RPC or WS call (over TLS)

Suggestion:

  • refactor for modular STF. separate Business logic into its own module (definition of state, definition of STF)
@brenzi brenzi assigned brenzi and unassigned electronix Sep 9, 2019
@brenzi
Copy link
Collaborator Author

brenzi commented Sep 16, 2019

Consider instantiating an entire Balances module inside the enclave to provide token functionality. the outdated branch https://github.com/scs/substraTEE-worker/tree/brenzi-contract-modular shows how this could be done

@brenzi
Copy link
Collaborator Author

brenzi commented Sep 23, 2019

Re-visiting the ink contract PoC:

We should proceed as follows:

  1. re-visit substrate patches in brenzi-contract-replace-sr-io and apply them to https://github.com/scs/substraTEE-node/tree/master/sr-tee-io. New feature sgx
  2. check mods for worker and integrate balances module

@brenzi
Copy link
Collaborator Author

brenzi commented Sep 23, 2019

@brenzi
Copy link
Collaborator Author

brenzi commented Sep 23, 2019

second part started: instantiate runtime with balancesbut without contracts within enclave
https://github.com/scs/substraTEE-worker/tree/brenzi-private-tx

@brenzi
Copy link
Collaborator Author

brenzi commented Sep 26, 2019

simple demo works:

*** Getting the amount of the registered workers
[<] Found 1  workers

[>] Getting the first worker's from the substraTEE-node
[<] Got first worker's coordinates:
    W1's public key : "5Gkzji8EtE1hTjVzTmZXWqrs6sqcHcbCooGqVH7iRRuxdnar"
    W1's url: "127.0.0.1:2000"

[>] Get the shielding key from W1 (=5Gkzji8EtE1hTjVzTmZXWqrs6sqcHcbCooGqVH7iRRuxdnar)
[<] Got worker shielding key Rsa3072KeyPair: { n:CF67550FB00AB959A76219EA35188B360380037123FCAA77B683A791A1F980331F9D9E11D04C7F5FB3B63787F8AAB579FDFFE1DCE79A29B6ACED2628635C8463965D5D839BD58072AA77B8CAE124E40562955FE9936DAE2976CD57B41A2DE89EEDBF9DA77C155365E8BB45DCA1E0EC3B32604D9489712762BE63B3D1F04801D796887F70115BFDD440450A04BFE81DEE7BE718F56F766E6B0C2D9DE270583C4DFBA64FD59B4DE39C07977F1FD2956588DDBF73987EECB5BB303AF2115C4E72879C5EC69B7CD5C00DAEF9F9B062B40ADA16984C574246C8AB882A79D2E1C2F597C1017FBA69D7449BAD85ADE822D92A775DB1766F21C886E762C3E260390B72C82515F1D48FD190059B419C639E3688BCC2070E9CDB6BDDD49202B7296EA2AB01EA2D3AC2990C5078446582A4C03194BBF8D7E557B4503FF4645C053D7288398C79781F642F3A8D399195E6D2E6F74B434791D881BC97BAA0F0B228BD031C40E357BC61644E68CC40F3E08BDCBBD92E306FA9353FAEA05FDCBFCF4729FECC008C, e:01000001 }

[+] Alice's Incognito Pubkey: 5Dt1Wg85pXGLstt36t6TDdvXXoCtG6zkUL17KkyVaPYSrzGH

[+] Bob's Incognito Pubkey: 5GTTq4EnvMk4oTXYJp2kqTd2T9hbnARuee5awLiKFKsxWgRy

[+] pre-funding Alice's Incognito account (ROOT call)
[+] Subscribed, waiting for event...

[+] Received confirm call from 5Gkzji8EtE1hTjVzTmZXWqrs6sqcHcbCooGqVH7iRRuxdnar
[+] query Alice's Incognito account balance
    got getter response from worker: Ok("State is 1000000")
[+] query Bob's Incognito account balance
    got getter response from worker: Ok("State is 0")

*** incognito transfer from Alice to Bob

[+] Subscribed, waiting for event...

[+] Received confirm call from 5Gkzji8EtE1hTjVzTmZXWqrs6sqcHcbCooGqVH7iRRuxdnar
[+] query Alice's Incognito account balance
    got getter response from worker: Ok("State is 900000")
[+] query Bob's Incognito account balance
    got getter response from worker: Ok("State is 100000")

@brenzi brenzi mentioned this issue Sep 26, 2019
@brenzi brenzi closed this as completed in #61 Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants