swaponline / sips

Swap.online Improvement Proposals
0 stars 1 forks source link

SIP1: One key for multiple blockchains (BIP39 HD Wallet) #1

Closed vladiuz1 closed 4 years ago

vladiuz1 commented 6 years ago

Right now you make a poor user remember two keys. One ethereum, and one bitcoin. This needs to be fixed. Both blockchains are using the same private key algos: secp256k1. According to bitcoin ():

Range of valid ECDSA private keys

Nearly every 256-bit number is a valid ECDSA private key. Specifically, any 256-bit number from 0x1 to 0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140 is a valid private key.

The range of valid private keys is governed by the secp256k1 ECDSA standard used by Bitcoin.

According to Ethereum (https://etherworld.co/2017/11/17/understanding-the-concept-of-private-key-public-key-and-address-in-ethereum-blockchain/):

Ethereum key generation is based on elliptical curve ecp256k1. Elliptical curve (EC) is intense mathematics, and there are a lot of great articles on the internet covering deep details of the elliptical curve. There are standard libraries to generate Ethereum key pair in a much safer way. In this article, just for demonstration, I will use elliptical curve Javascript library to perform elliptical curve operations.

The only difference right now is that your ethereum private key is represented in Hex format, and your bitcoin private key is in Wif format (that can be easily derived from hex format) like this:

https://en.bitcoin.it/wiki/Wallet_import_format

Now I suggest using Wif format ONLY for the private key because it contains a checksum. Then derive Ethereum private key from it. It should be straightforward. It is just a number in a range. I think either script to generate a private key will do. Bitcoin or Ethereum.

In order to make things more secure and avoid collisions, we may want to use Derived Keys (HD) for the blockchains.

noxonsu commented 6 years ago

"Вроде как да, не думаю, что какие-то проблемы с этим могут возникнуть." - криптограф

vladiuz1 commented 6 years ago

если возникнут - будем решать

как пример решения, чтобы избежать вычисления приватника из 2-х адресов (например эфира и битка) мы можем сделать общий master-key из которого дерайвим по приватнику на каждый бч по некой формуле, как это делают кошельки utxo в биткойне.

и во время первого визита просим запомнить mnemonic seed мастера, удаляем его из памяти. если что по сиду восстанавливаем все приватники. так делает например bitshares, и наверняка другие кошельки тоже.

caffeinum commented 6 years ago

Нужно немного переписать SwapAuth, чтоб так сделать. Пока что hold

vladiuz1 commented 6 years ago

Another important thing.

Backup/restore by mnemonic phrase.

Please check this link: https://iancoleman.io/bip39/#english

This has all necessary key derivations.

You can derive a root key using this algo. No need to reinvent the wheel.

Exotic chains (eos for instance) will need to be derived differently. But we can fix them later. Important - the right core infrustructure.

Also please allow for multiple profiles #89.