-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing up to match flask breaking changes
- Loading branch information
1 parent
3360ac6
commit a28d5fe
Showing
59 changed files
with
27,003 additions
and
25,955 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
# 💥 Snappy Recovery | ||
|
||
Social Recovery for MetaMask wallets using "Snaps", sandboxed JS plugins for MetaMask. | ||
|
||
Watch the demo on YouTube: | ||
|
||
<p align="center"> | ||
<a href="https://www.youtube.com/watch?v=HjZ2yxUm30k"><img src="https://img.youtube.com/vi/HjZ2yxUm30k/hqdefault.jpg"></a> | ||
</p> | ||
|
||
## How it works, visually | ||
|
||
![Snappy Recovery diagram](snappy-recovery-diagram.png) | ||
|
||
## Why it's safe-ish? | ||
* The Snap code runs in a **sandboxed environment** inside the MetaMask extension | ||
* The Snap code has access to private keys, but no internet access -- it doesn't request that permission | ||
* The Snap never exposes a sensitive private key to the Dapp (browser environment) unless it's encrypted | ||
* The Snap code is installed from NPM and can be audited at all times | ||
|
||
## Why it's probably not so safe? | ||
* I have only a rudimentary cryptography training | ||
* I built this alone, working late at night | ||
* Nobody reviewed nor audited this code | ||
* MetaMask Snaps are still a new feature in development | ||
|
||
## What does this mean? | ||
⚠️ **USE ONLY WITH ON TEST NETWORKS AND WITH TEST MNEMONICS** | ||
|
||
## How it works? | ||
|
||
### Setup the social recovery | ||
1. Connect to MetaMask | ||
1. Accept the permission to manage your Ethereum private keys | ||
1. Go to your profile and copy your Snappy Recovery public key, save it somewhere. It's public data, harmless to save it in the clear. | ||
1. Find 5 friends with whom to split a secret backup key, send them to Snappy Recovery, and ask them for their Snappy Recovery public key (they have to login and go to their profile) | ||
1. Enter the 5 public keys in the "Setup Recovery" section, and press "Setup" | ||
1. The Snappy Recovery Snap, working fully inside MetaMask's sandboxed environment, will: | ||
1. Grab your parent Ethereum node, used to generate all your accounts | ||
1. Create a brand new backup AES encryption key | ||
1. Use this backup key to symmetrically encrypt your Ethereum node | ||
1. Split the backup key using a 3-of-5 Shamir secret sharing scheme | ||
1. Encrypt each backup key part using one of your friends' public keys | ||
1. Return the encrypted Ethereum key + the 5 encrypted shards to this Dapp. This means that at no point will the Dapp be able to "see" your master Ethereum private key in the clear | ||
1. Your encrypted Ethereum key + the 5 encrypted shards will be stored on Gun, a distributed peer-to-peer database | ||
1. All you have to do is save your Snappy Recovery public key ("View your public key" at the top) somewhere like your email or cloud storage | ||
|
||
### Recover your wallet / funds | ||
1. Reinstall MetaMask | ||
1. Go to Snappy Recovery and connect metamask, installing the Snap | ||
1. Press "I lost my private key!" | ||
1. Enter your Snappy Recovery public key that you copied back when you had access to your wallet | ||
1. Press "Get recovery URL" | ||
1. You'll get a URL, share it with at least three of your five friends | ||
1. The recovery page will self-update as your friends follow the procedure on their side -- they just have to click a button | ||
1. Once 3 of your friends have fulfilled their responsibility, press "Recover my ETH!" | ||
1. After a few seconds, you'll see your old accounts appear, with their balances and transaction count | ||
1. To recover an account: | ||
1. Press "Show private key" next to the address | ||
1. Go to MetaMask's menu and choose "Import Account" | ||
1. Paste your private key to import your account | ||
1. Send your funds to a non-imported account from your current wallet | ||
# 💥 Snappy Recovery | ||
|
||
Social Recovery for MetaMask wallets using "Snaps", sandboxed JS plugins for MetaMask. | ||
|
||
Watch the demo on YouTube: | ||
|
||
<p align="center"> | ||
<a href="https://www.youtube.com/watch?v=HjZ2yxUm30k"><img src="https://img.youtube.com/vi/HjZ2yxUm30k/hqdefault.jpg"></a> | ||
</p> | ||
|
||
## How it works, visually | ||
|
||
![Snappy Recovery diagram](snappy-recovery-diagram.png) | ||
|
||
## Why it's safe-ish? | ||
* The Snap code runs in a **sandboxed environment** inside the MetaMask extension | ||
* The Snap code has access to private keys, but no internet access -- it doesn't request that permission | ||
* The Snap never exposes a sensitive private key to the Dapp (browser environment) unless it's encrypted | ||
* The Snap code is installed from NPM and can be audited at all times | ||
|
||
## Why it's probably not so safe? | ||
* I have only a rudimentary cryptography training | ||
* I built this alone, working late at night | ||
* Nobody reviewed nor audited this code | ||
* MetaMask Snaps are still a new feature in development | ||
|
||
## What does this mean? | ||
⚠️ **USE ONLY WITH ON TEST NETWORKS AND WITH TEST MNEMONICS** | ||
|
||
## How it works? | ||
|
||
### Setup the social recovery | ||
1. Connect to MetaMask | ||
1. Accept the permission to manage your Ethereum private keys | ||
1. Go to your profile and copy your Snappy Recovery public key, save it somewhere. It's public data, harmless to save it in the clear. | ||
1. Find 5 friends with whom to split a secret backup key, send them to Snappy Recovery, and ask them for their Snappy Recovery public key (they have to login and go to their profile) | ||
1. Enter the 5 public keys in the "Setup Recovery" section, and press "Setup" | ||
1. The Snappy Recovery Snap, working fully inside MetaMask's sandboxed environment, will: | ||
1. Grab your parent Ethereum node, used to generate all your accounts | ||
1. Create a brand new backup AES encryption key | ||
1. Use this backup key to symmetrically encrypt your Ethereum node | ||
1. Split the backup key using a 3-of-5 Shamir secret sharing scheme | ||
1. Encrypt each backup key part using one of your friends' public keys | ||
1. Return the encrypted Ethereum key + the 5 encrypted shards to this Dapp. This means that at no point will the Dapp be able to "see" your master Ethereum private key in the clear | ||
1. Your encrypted Ethereum key + the 5 encrypted shards will be stored on Gun, a distributed peer-to-peer database | ||
1. All you have to do is save your Snappy Recovery public key ("View your public key" at the top) somewhere like your email or cloud storage | ||
|
||
### Recover your wallet / funds | ||
1. Reinstall MetaMask | ||
1. Go to Snappy Recovery and connect metamask, installing the Snap | ||
1. Press "I lost my private key!" | ||
1. Enter your Snappy Recovery public key that you copied back when you had access to your wallet | ||
1. Press "Get recovery URL" | ||
1. You'll get a URL, share it with at least three of your five friends | ||
1. The recovery page will self-update as your friends follow the procedure on their side -- they just have to click a button | ||
1. Once 3 of your friends have fulfilled their responsibility, press "Recover my ETH!" | ||
1. After a few seconds, you'll see your old accounts appear, with their balances and transaction count | ||
1. To recover an account: | ||
1. Press "Show private key" next to the address | ||
1. Go to MetaMask's menu and choose "Import Account" | ||
1. Paste your private key to import your account | ||
1. Send your funds to a non-imported account from your current wallet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
{ | ||
"name": "snappy-recovery", | ||
"private": true, | ||
"version": "0.0.1", | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.1.0", | ||
"@typescript-eslint/eslint-plugin-tslint": "^5.1.0", | ||
"@typescript-eslint/parser": "^5.1.0", | ||
"babel-eslint": "10.1.0", | ||
"eslint": "^7.18.0", | ||
"eslint-config-airbnb": "^18.2.1", | ||
"eslint-config-airbnb-typescript": "^12.0.0", | ||
"eslint-config-react-app": "^6.0.0", | ||
"eslint-import-resolver-typescript": "^2.3.0", | ||
"eslint-loader": "4.0.2", | ||
"eslint-plugin-flowtype": "5.2.0", | ||
"eslint-plugin-import": "2.22.0", | ||
"eslint-plugin-jsdoc": "^29.2.0", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-no-null": "^1.0.2", | ||
"eslint-plugin-prefer-arrow": "^1.2.1", | ||
"eslint-plugin-react": "^7.22.0", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"eslint-plugin-unicorn": "^20.1.0", | ||
"typescript": "^4.4.2" | ||
}, | ||
"scripts": { | ||
"build": "(cd packages/shared && yarn tsc -b) && (yarn --cwd packages/webapp build)" | ||
}, | ||
"workspaces": { | ||
"packages": [ | ||
"packages/*" | ||
] | ||
} | ||
{ | ||
"name": "snappy-recovery", | ||
"private": true, | ||
"version": "0.0.1", | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.1.0", | ||
"@typescript-eslint/eslint-plugin-tslint": "^5.1.0", | ||
"@typescript-eslint/parser": "^5.1.0", | ||
"babel-eslint": "10.1.0", | ||
"eslint": "^7.18.0", | ||
"eslint-config-airbnb": "^18.2.1", | ||
"eslint-config-airbnb-typescript": "^12.0.0", | ||
"eslint-config-react-app": "^6.0.0", | ||
"eslint-import-resolver-typescript": "^2.3.0", | ||
"eslint-loader": "4.0.2", | ||
"eslint-plugin-flowtype": "5.2.0", | ||
"eslint-plugin-import": "2.22.0", | ||
"eslint-plugin-jsdoc": "^29.2.0", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-no-null": "^1.0.2", | ||
"eslint-plugin-prefer-arrow": "^1.2.1", | ||
"eslint-plugin-react": "^7.22.0", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"eslint-plugin-unicorn": "^20.1.0", | ||
"typescript": "^4.4.2" | ||
}, | ||
"scripts": { | ||
"build": "(cd packages/shared && yarn tsc -b) && (yarn --cwd packages/webapp build)" | ||
}, | ||
"workspaces": { | ||
"packages": [ | ||
"packages/*" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
;(function(){ | ||
var Gun = require('gun'); | ||
require('gun/lib/server'); | ||
require('gun/axe'); | ||
var config = { | ||
port: process.env.PORT, | ||
server: require('http').createServer(Gun.serve) | ||
}; | ||
|
||
var gun = Gun({web: config.server.listen(config.port), file: 'data'}); | ||
|
||
module.exports = gun; | ||
;(function(){ | ||
var Gun = require('gun'); | ||
require('gun/lib/server'); | ||
require('gun/axe'); | ||
var config = { | ||
port: process.env.PORT, | ||
server: require('http').createServer(Gun.serve) | ||
}; | ||
|
||
var gun = Gun({web: config.server.listen(config.port), file: 'data'}); | ||
|
||
module.exports = gun; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"name": "gun-relay", | ||
"version": "0.0.1", | ||
"description": "Gun DB relay server", | ||
"main": "index.js", | ||
"author": "Ziad Saab <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"express": "^4.18.1", | ||
"gun": "^0.2020.1238" | ||
} | ||
} | ||
{ | ||
"name": "gun-relay", | ||
"version": "0.0.1", | ||
"description": "Gun DB relay server", | ||
"main": "index.js", | ||
"author": "Ziad Saab <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"express": "^4.18.1", | ||
"gun": "^0.2020.1238" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{ | ||
"name": "@snappy-recovery/shared", | ||
"version": "0.0.1", | ||
"main": "./lib/src/index.js", | ||
"types": "./lib/src/index.d.ts", | ||
"module": "./lib/src/index.js", | ||
"scripts": { | ||
"watch": "yarn tsc -b --watch" | ||
}, | ||
"dependencies": { | ||
"eth-crypto": "^2.3.0" | ||
} | ||
} | ||
{ | ||
"name": "@snappy-recovery/shared", | ||
"version": "0.0.1", | ||
"main": "./lib/src/index.js", | ||
"types": "./lib/src/index.d.ts", | ||
"module": "./lib/src/index.js", | ||
"scripts": { | ||
"watch": "yarn tsc -b --watch" | ||
}, | ||
"dependencies": { | ||
"eth-crypto": "^2.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './recovery'; | ||
export * from './recovery'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export const RECOVERY_TOTAL_PARTS = 5; | ||
export const RECOVERY_THRESHOLD_PARTS = 3; | ||
export const RECOVERY_TOTAL_PARTS = 5; | ||
export const RECOVERY_THRESHOLD_PARTS = 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './constants'; | ||
export * from './types'; | ||
export * from './constants'; | ||
export * from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { EncryptedBackupKeypairPart } from './crypto'; | ||
|
||
export interface AssistWithRecoveryParams { | ||
encryptedBackupKeypairPart: EncryptedBackupKeypairPart; | ||
targetUserPublicKeyHex: string; | ||
} | ||
|
||
export interface AssistWithRecoveryResult { | ||
backupKeypairPartEncryptedWithTargetUserPublicKey: EncryptedBackupKeypairPart; | ||
} | ||
import { EncryptedBackupKeypairPart } from './crypto'; | ||
|
||
export interface AssistWithRecoveryParams { | ||
encryptedBackupKeypairPart: EncryptedBackupKeypairPart; | ||
targetUserPublicKeyHex: string; | ||
} | ||
|
||
export interface AssistWithRecoveryResult { | ||
backupKeypairPartEncryptedWithTargetUserPublicKey: EncryptedBackupKeypairPart; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import type { Encrypted } from 'eth-crypto'; | ||
|
||
export type AesEncryptedData = { | ||
initializationVectorInBase64: string; | ||
encryptedDataInBase64: string; | ||
}; | ||
|
||
export type EncryptedBackupKeypairPart = Encrypted; | ||
import type { Encrypted } from 'eth-crypto'; | ||
|
||
export type AesEncryptedData = { | ||
initializationVectorInBase64: string; | ||
encryptedDataInBase64: string; | ||
}; | ||
|
||
export type EncryptedBackupKeypairPart = Encrypted; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import { AesEncryptedData, EncryptedBackupKeypairPart } from './crypto'; | ||
|
||
export interface GetRecoveredAddressesParams { | ||
encryptedEthereumNode: AesEncryptedData; | ||
encryptedBackupKeypairParts: EncryptedBackupKeypairPart[]; | ||
} | ||
|
||
export interface RecoveredAddressIndices { | ||
accountIndex: number; | ||
addressIndex: number; | ||
} | ||
|
||
export interface RecoveredAddress extends RecoveredAddressIndices { | ||
address: string; | ||
balanceInEth: string; | ||
numTransactions: number; | ||
} | ||
|
||
export interface GetRecoveredAddressesResult { | ||
recoveredAddresses: RecoveredAddress[]; | ||
} | ||
import { AesEncryptedData, EncryptedBackupKeypairPart } from './crypto'; | ||
|
||
export interface GetRecoveredAddressesParams { | ||
encryptedEthereumNode: AesEncryptedData; | ||
encryptedBackupKeypairParts: EncryptedBackupKeypairPart[]; | ||
} | ||
|
||
export interface RecoveredAddressIndices { | ||
accountIndex: number; | ||
addressIndex: number; | ||
} | ||
|
||
export interface RecoveredAddress extends RecoveredAddressIndices { | ||
address: string; | ||
balanceInEth: string; | ||
numTransactions: number; | ||
} | ||
|
||
export interface GetRecoveredAddressesResult { | ||
recoveredAddresses: RecoveredAddress[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export interface GetRecoveryPublicKeyResult { | ||
publicKeyHex: string; | ||
} | ||
export interface GetRecoveryPublicKeyResult { | ||
publicKeyHex: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export interface GetSnappyKeysResult { | ||
gun: { | ||
epub: string; | ||
epriv: string; | ||
pub: string; | ||
priv: string; | ||
identiconAddress: string; | ||
}; | ||
backupPublicKeyHex: string; | ||
} | ||
export interface GetSnappyKeysResult { | ||
gun: { | ||
epub: string; | ||
epriv: string; | ||
pub: string; | ||
priv: string; | ||
identiconAddress: string; | ||
}; | ||
backupPublicKeyHex: string; | ||
} |
Oops, something went wrong.