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

Refactor/seed protection #1500

Closed
wants to merge 7 commits into from
Closed

Conversation

Empowerful
Copy link
Contributor

@Empowerful Empowerful commented Mar 6, 2019

Introduction

This PR is both a proof of concept and first step toward protecting the backup phrase. It is presented here for review but is not intended to be merged (see below for why).

To protect the backup phrase I divided the Web Wallet into two separate applications: one trusted more (the "Root Document") and the other trusted less (the "Main Process"). The Main Process is an <iframe> within the Root Document that takes up the whole viewport and is served locally via port 8082. The two applications communicate with each other via postMessage.

To save development time I created each application from a complete copy of the current Web Wallet and then made modifications to them. The two applications are mostly the same but over time will become more differentiated as I remove code that's no longer relevant to each application.

Notes

  • In the code you'll see the applications sometimes referred to as "realms". A realm is a JavaScript environment with a distinct namespace.
  • The main-process directory is not within packages because Yarn doesn't support nested workspaces.
  • My new inter-realm communication library is in its own subdirectory (web-microkernel) because it will be moved into its own repository in the future.

Use

Install new dependencies:

$ yarn

Start the Main Process on port 8082:

$ cp config/env/* main-process/config/env
$ cd main-process
$ yarn
$ yarn start:staging

Once the Main Process has started, open a second terminal in the top level of the repository and start the Root Document application on port 8080:

$ yarn start:staging

Questions and feedback are highly encouraged.

@Empowerful Empowerful added the don't merge yet Code should not be merged label Mar 6, 2019
@Empowerful
Copy link
Contributor Author

Empowerful commented Mar 7, 2019

@tony-blockchain asked to see some examples of the inter-realm encoding.

Here's the handshake of the two realms exchanging their exports with each other:

[
  "object",
  [
    ["axios", ["function", { "key": "1sz07pq", "length": 1 }]],
    ["dispatch", ["function", { "key": "y3qkt9", "length": 1 }]]
  ]
]

["object", [["dispatch", ["function", { "key": "1tzy5g1", "length": 1 }]]]]

Notice the keys are randomly generated so that a compromised realm couldn't guess the keys in the other.

Here's an example of a function call. This is calling the Redux dispatch function in the other realm to forward the AUTHENTICATE action:

[
  "functionApply",
  {
    "args": ["array", [["object", [["type", ["string", "AUTHENTICATE"]]]]]],
    "functionKey": "oqxn13",
    "returnValueKey": "rszz94"
  }
]

Here's the result of the function application being returned:

["functionReturn", { "returnValueKey": "rszz94", "value": ["number", 0] }]

@Empowerful Empowerful force-pushed the refactor/seed-protection branch 4 times, most recently from 6b16eaf to c55bf21 Compare March 14, 2019 14:58
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from c55bf21 to 3afbec6 Compare March 29, 2019 14:45
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from 3afbec6 to 4dba6cb Compare April 5, 2019 21:55
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from 4dba6cb to 0412030 Compare April 25, 2019 21:35
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from 0412030 to f22a528 Compare May 8, 2019 17:04
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from f22a528 to 1d9443d Compare May 24, 2019 20:01
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from 1d9443d to b1558d4 Compare June 5, 2019 17:20
@Empowerful Empowerful force-pushed the refactor/seed-protection branch 2 times, most recently from 08131fe to c5145af Compare June 21, 2019 19:56
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from c5145af to c9e21b7 Compare July 3, 2019 19:19
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from c9e21b7 to 93cc869 Compare July 11, 2019 21:52
@blockchain blockchain deleted a comment from jakubusi Jul 17, 2019
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from 93cc869 to ac4df07 Compare July 19, 2019 16:31
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from ac4df07 to ea56c9e Compare August 5, 2019 16:09
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from ea56c9e to 7837a77 Compare August 15, 2019 17:34
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from 7837a77 to a270fe9 Compare August 23, 2019 15:28
@Empowerful Empowerful force-pushed the refactor/seed-protection branch 2 times, most recently from 221cab9 to 016f72a Compare August 26, 2019 20:24
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from af82321 to def8476 Compare August 28, 2019 21:03
@Empowerful Empowerful added the work in progress Work is currently in progress label Aug 29, 2019
@Empowerful Empowerful force-pushed the refactor/seed-protection branch 2 times, most recently from 21e8d56 to 6401225 Compare September 9, 2019 18:52
@Empowerful Empowerful force-pushed the refactor/seed-protection branch 2 times, most recently from 1ea4147 to aa7ba79 Compare September 26, 2019 14:59
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from d9c1ee5 to 1205342 Compare October 9, 2019 20:55
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from aa678b4 to 5a3524f Compare October 25, 2019 19:40
@blockchain blockchain deleted a comment from laothuong Oct 27, 2019
@blockchain blockchain deleted a comment Oct 28, 2019
@blockchain blockchain deleted a comment Nov 5, 2019
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from e9228e1 to 0ba6537 Compare November 18, 2019 22:43
@Empowerful Empowerful force-pushed the refactor/seed-protection branch from 3e9852c to 0d1c098 Compare November 29, 2019 22:38
@schnogz schnogz closed this Dec 8, 2019
@schnogz schnogz deleted the refactor/seed-protection branch December 8, 2019 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
don't merge yet Code should not be merged work in progress Work is currently in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants