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 2 times, most recently from 08131fe to c5145af Compare June 21, 2019 19:56
@blockchain blockchain deleted a comment from jakubusi Jul 17, 2019
@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 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
@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
@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.

None yet

4 participants