Skip to content

Commit 4e39c03

Browse files
committed
docs: added docs article on root keypair generation
1 parent 407a397 commit 4e39c03

File tree

7 files changed

+141
-0
lines changed

7 files changed

+141
-0
lines changed

docs/reference/root-keypair.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Root Keypair
2+
3+
Polykey's entire encryption model revolves around Hybrid Elliptic Curve
4+
Integrated Encryption Scheme (ECIES), and the Root Keypair is the foundation of
5+
everything. It's the cryptographic identity of a node, making secure
6+
communication, encryption, and key derivation possible.
7+
8+
This doc covers:
9+
10+
- What the Root Keypair is.
11+
- How it's generated.
12+
- How it spits out a DEK (Data Encryption Key).
13+
14+
## What is the Root Keypair?
15+
16+
The Root Keypair is an Ed25519 elliptic curve keypair that serves as the node's
17+
identity in Polykey.
18+
19+
It's made up of:
20+
21+
- Private Key: A 256-bit secret, randomly generated and never shared.
22+
- Public Key: Derived from the private key and used for authentication and key
23+
exchange.
24+
25+
### Why do we care?
26+
27+
1. Identity: Every Polykey node has a unique Root Public Key.
28+
2. Key Exchange: It's used in the Key Encapsulation Mechanism (KEM) to securely
29+
share encryption keys.
30+
3. Data Encryption: It's how we derive a DEK, which encrypts stored data.
31+
32+
## Hybrid Cryptosystem Overview
33+
34+
Before generating the Root Keypair, we need to understand how encryption works
35+
in Polykey.
36+
37+
A hybrid cryptosystem consists of:
38+
39+
1. Key Encapsulation Mechanism (KEM): Uses asymmetric encryption (Ed25519) to
40+
securely transmit a symmetric key.
41+
2. Data Encapsulation Scheme (DEM): Uses symmetric encryption (AES/ChaCha20) for
42+
bulk encryption of Polykey's state.
43+
44+
Before we can encrypt anything, we must generate the Ed25519 Root Keypair.
45+
46+
![Step 1](/images/reference/kgd-s1.svg)
47+
48+
## Generating the Root Keypair
49+
50+
The process is deterministic, secure, and clean.
51+
52+
### Root Keypair Generation Begins
53+
54+
- The user or console triggers keypair generation.
55+
- The system gathers high-entropy randomness to ensure security.
56+
57+
![Step 2](/images/reference/kgd-s2.svg)
58+
59+
### BIP39 Wordlist & Recovery Code
60+
61+
- Entropy is converted into a mnemonic phrase using the BIP39 English Wordlist .
62+
- The 24-word recovery code represents 264 bits of entropy.
63+
64+
![Step 3](/images/reference/kgd-s3.svg)
65+
66+
### Mnemonic to Binary Seed
67+
68+
- The 24-word recovery code is converted into a binary seed using PBKDF2.
69+
- Uses HMAC-SHA512 with 2048 iterations.
70+
- The binary seed is 512 bits, then truncated to 256 bits.
71+
72+
![Step 4](/images/reference/kgd-s4.svg)
73+
74+
### Generating the Keypair
75+
76+
- The 256-bit seed is fed into the Ed25519 algorithm to generate a private key.
77+
- Scalar multiplication is performed to derive the public key.
78+
79+
![Step 5](/images/reference/kgd-s5.svg)
80+
81+
## How is the DEK Made?
82+
83+
The Data Encryption Key (DEK) is derived from the Root Keypair using a Key
84+
Derivation Function (KDF).
85+
86+
1. Elliptic Curve Diffie-Hellman (ECDH)
87+
88+
- The Root Private Key and another node's Public Key are combined to create a
89+
shared secret.
90+
91+
2. Run It Through a KDF
92+
93+
- A Key Derivation Function (likely HKDF-SHA256) converts the shared secret into
94+
a 256-bit symmetric DEK.
95+
96+
3. Store or Re-Derive the DEK
97+
98+
- The DEK is either stored securely or regenerated when needed.
99+
100+
![Step 6](/images/reference/kgd-s6.svg)
101+
102+
## Final Output: The Root Keypair
103+
104+
- The final result is a Public and Private Keypair, each 32 bytes (256 bits)
105+
long.
106+
- Key size benefits:
107+
- More efficient than RSA prime factorization.
108+
- 256-bit Ed25519 key provides same security as a 3072-bit RSA key.
109+
- Public key can be encoded using multibase base32z.
110+
111+
## Wrapping It Up
112+
113+
The Root Keypair is the foundation of Polykey's encryption model. It enables:
114+
115+
- Secure messaging
116+
- Key exchange
117+
- Encryption using Ed25519 elliptic curve cryptography .
118+
119+
The DEK, derived from the Root Keypair, locks down all stored data with strong
120+
encryption. This entire setup is faster, more efficient, and more secure than
121+
traditional RSA-based encryption.
122+
123+
That's it. Root Keypair = Identity. DEK = Encrypted data. Simple, secure.

static/images/reference/kgd-s1.svg

Lines changed: 3 additions & 0 deletions
Loading

static/images/reference/kgd-s2.svg

Lines changed: 3 additions & 0 deletions
Loading

static/images/reference/kgd-s3.svg

Lines changed: 3 additions & 0 deletions
Loading

static/images/reference/kgd-s4.svg

Lines changed: 3 additions & 0 deletions
Loading

static/images/reference/kgd-s5.svg

Lines changed: 3 additions & 0 deletions
Loading

static/images/reference/kgd-s6.svg

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)