Skip to content

purien/keystore

Repository files navigation

About the Keystore

  • A simple cost effective solution to securely store&use blockchain private keys in the cloud
    -- Cost effective, alternative to HSM
    -- Anywhere, anytime
    -- Secure and tamper proof
  • Blockchain keystore embedded in a tamper resistant server
    -- Fully under the (remote) user (owner) control
  • On the client side, credentials are optionally stored in a Secure Element (access card) and may use a crypto terminal.
  • Simple and highly secure architecture
    -- Relies on TLS1.3 secure communication and Secure Elements

Making an Ethereum transaction with the keystore

See https://github.com/purien/keystore/wiki/Making-an-Ethereum-Transaction-with-the-keystore

Demonstration Server for Windows

See https://github.com/purien/keystore/wiki/Windows-Keystore-Demonstration

The concept

Why TLS1.3

  • State of art for communication security -- Several years of debates between security experts at IETF.
    -- Privacy enforcement with Diffie-Hellman Exchange over Elliptic Curve (ECDHE)
    -- Authenticated Encryption with Associated Data (AEAD)
    -- Server and client authentication based on PKI or pre-shared-key (PSK)
  • TLS-SE 1.0 works with AES-128-CCM cipher-suite, ECDHE (over SECP256k1), and 32 bytes PSK.
  • Next version will support PKI

Keystore commands

  • A keystore command is a text line (ASCII) ended by CrLf (Carriage Return, Line Feed) or Lf
  • The first character is the command identifier (?, c, X, g, p, r, t, v, b, s)
  • The second and third character is the command index coded in hexadecimal
    -- index: 00=>0, 01=1, 0A=>10, FF=>255
    -- The keystore supports four keys identfified by index 00, 01, 02, 03
  • Remaining characters (if any) represent the command payload
    -- For ?01 echo command, the payload is a set of ASCII characters
    -- For other commands the payload is a set of bytes encoded in hexadecimal format (even number of characters)
    -- For BIP32, only hardened keys are supported. The path is expressed as a list of 32bits values, with the most significant bit set to 1.
  • The timeout is 30 seconds, use ?02 for deconnection.

keystore raspberry-pi board keystore wi-fi board

Personal HSM

Personal HSM board

OPENSSL examples

OPENSSL command line

  • without server name
    openssl s_client -tls1_3 -connect server.com:8888 -groups P-256 -cipher DHE -ciphersuites TLS_AES_128_CCM_SHA256 -no_ticket -psk 0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20

  • with TLS server name keyx.com
    openssl s_client -tls1_3 -connect server.com:8888 -servername keyx.com -groups P-256 -cipher DHE -ciphersuites TLS_AES_128_CCM_SHA256 -no_ticket -psk 0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20

Upon success your scree should display the following lines:

CONNECTED(00000130)
no peer certificate available
No client certificate CA names sent
Server Temp Key: ECDH, P-256, 256 bits
SSL handshake has read 252 bytes and written 387 bytes
Verification: OK
Reused, TLSv1.3, Cipher is TLS_AES_128_CCM_SHA256
Secure Renegotiation IS NOT supported
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)

A simple session

?00 (get version)
Ethertrust keystore 1.1
?01abcdef (echo abcdef)
abcdef
?02 (disconnect)

Generating a key

c03 (clear key 3)
OK
g03 (generate key 3)
OK
p03 (get public key 3)
04E67689C83475EFB1C91B64F56BECD926FAE5CC81631EF98AFD4EF8AF310F64460CE0D3550BD6658ABD26EDA825859746C10F781354EC1C086161B4 A808B1BD56
r03 (get private key 3)
5E2A0AAD12FF24E638174AE9B17F45078C5C068F08F0479AAE9CB645DFBB4408
?02 (disconnect)

Setting a key

c03 (clear key 3)
OK
X031234 (set private & public key 3)
OK
p03 (get public key 3)
0437A4AEF1F8423CA076E4B7D99A8CABFF40DDB8231F2A9F01081F15D7FA65C1BAB96CED90A1B8F9B43A18FC900FF55AF2BE0E94B90A434FCA5B9E22 6B835024CD
r03 (get private key 3)
0000000000000000000000000000000000000000000000000000000000001234
?02 (disconnect)

Setting BIP32 seed and computing keys

c03 (clear key 3)
OK
t031234 (set tree 3 secret seed)
OK
v03 (get tree 3 secret seed)
1234
b0380000001 (compute hardened key 1H for BIP tree 3)
p03 (get public key 3)
0455CB37165F08D5E85D49DA700C083B8D9D7CB33EA7BEF0FE3455F632FE50DE743E4664A488C3D825F872135BF2F139C655B9E212394717D0A9F27E 9DEA32146E
r03 (get private key 3)
95DC50F1D52AC952B866B8AD9845F9E3EBB9DD8EDF49F8E7CC342469A8DA77C8
?02 (disconnect)

Generating BIP32 random secret seed

c03 (clear key 3)
OK
t03 (generate tree 3 secret seed)
OK
v03 (get tree 3 secret seed)
139CF1FED85772090C9A9AEBECD4F3ABB549B0D5D6858F77D540A9B565A98FF1
?02 (disconnect)

Generating BIP32 test vector

see https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
c03 (clear key 3)
OK
t03000102030405060708090a0b0c0d0e0f (set tree 3 secret seed)
OK
v03 (get tree 3 secret seed)
000102030405060708090a0b0c0d0e0f
b0380000000 (compute hardened key 0H for BIP tree 3)
p03 (get public key 3)
045A784662A4A20A65BF6AAB9AE98A6C068A81C52E4B032C0FB5400C706CFCCC567F717885BE239DAADCE76B568958305183AD616FF74ED4DC219A74 C26D35F839
r03 (get private key 3)
EDB2E14F9EE77D26DD93B4ECEDE8D16ED408CE149B6CD80B0715A2D911A0AFEA

Signing

s03abcd (sign with key 3)
30440220604F3520C7112BA934B34D25DB03DD66851C84017A0216FE1DC876A4ED4F6C33022070B437A956D5D9D7B7EAEBDC122E52DC347218DA4884 EF920AA44940D48BD92F

Writting

Write record#0 64 characters (32 hexa bytes)
Z00010203040506070809101112131415161718182021223242526272829303132
OK
Write record#31 64 characters (32 hexa bytes)
Z1F010203040506070809101112131415161718182021223242526272829303132
OK

Reading

read record#0
I00
010203040506070809101112131415161718182021223242526272829303132
read record#31
I1F
010203040506070809101112131415161718182021223242526272829303132

Disconnect

?02 (disconnect)

About

On-line test for keystore with OPENSSL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published