Skip to content
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4859bf3
Added blog post on .env security issues and Polykey solution
xrissoula Mar 6, 2025
3dc020b
Fixed formatting for .env article
xrissoula Mar 6, 2025
127e44b
Removed incorrect .env article
xrissoula Mar 6, 2025
8d22a7b
Add Root Keypair Generation article
xrissoula Mar 6, 2025
e0c0f80
Remove outdated .env article
xrissoula Mar 6, 2025
ba3113c
Update Root Keypair Generation article with correct frontmatter
xrissoula Mar 6, 2025
71721f0
feat: more syntax and styling fixes for document
xrissoula Mar 7, 2025
3218c27
feat: even more syntax and styling fixes for document
xrissoula Mar 7, 2025
fbe548a
Add full keypair generation flowchart for review
xrissoula Mar 7, 2025
e119540
Added key generation SVGs, linked images in root keypair doc, and rem…
xrissoula Mar 10, 2025
5079b6d
Fixed image embedding in root keypair generation doc
xrissoula Mar 10, 2025
a0b449b
Added Polykey Node IDs documentation (cleaned up)
xrissoula Mar 10, 2025
4f89889
Updated Polykey Node IDs documentation
xrissoula Mar 10, 2025
cb1dae0
Fixed YAML format in Polykey Node IDs doc
xrissoula Mar 10, 2025
ca8d448
Fixed YAML front matter formatting in both documentation files
xrissoula Mar 10, 2025
88f8562
Fixed Polykey Node IDs file tracking issue
xrissoula Mar 10, 2025
a47107d
Removed incorrectly placed root keypair generation document
xrissoula Mar 10, 2025
1ccc1a2
Removed incorrectly included images from Node ID PR
xrissoula Mar 10, 2025
6905b8b
Re-added polykey-node-ids document for tracking
xrissoula Mar 10, 2025
8e9d04c
Removed incorrectly added file: polykey-node-ids
xrissoula Mar 10, 2025
49dca6d
Add polykey-node-ids.md documentation
xrissoula Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions docs/reference/polykey-node-ids.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: 'Polykey Node IDs'
date: 2025-03-10
author: 'Christina'
tags: ['polykey', 'node-id', 'encoding', 'base32', 'security']
---
# How Polykey Handles Node IDs

## The Basics
Polykey generates and encodes Node IDs using Multihash and Multibase to make them flexible, self-describing, and interoperable.

- **Multihash**: A format that encodes the hashing algorithm alongside the hash itself. This ensures that the Node ID always carries metadata about how it was generated.
- **Multibase**: A format that specifies how the hash is encoded, like Base32 Hex. The 'v' prefix is used to indicate Base32 Hex encoding in Polykey.

## How Node IDs Are Generated

### Step 1: Public Key to Multihash
- The Ed25519 Public Key is first hashed using a cryptographic hash function.
- This produces a Multihash output, which includes both the hash algorithm and the digest.

### Step 2: Multihash to Multibase
- The Multihash result is then encoded using Multibase.
- In Polykey, we use Base32 Hex encoding with a 'v' prefix to keep it easy to read and portable.

## Why Multihash and Multibase?

- **Future-Proofing**: Since Multihash includes the hash algorithm, we can change the algorithm later without breaking compatibility.
- **Interoperability**: Other cryptographic systems that use Multihash and Multibase can parse Polykey Node IDs without any issues.
- **Flexible Rendering**: A single Node ID can be represented differently if a different encoding or hash function is chosen.

## Default Representation in Polykey

Polykey defaults to rendering Node IDs as Base32 Hex, which has some major advantages:

- A 32-byte hash always results in a 52-character string.
- The alphabet is simple and does not use special characters, making it easy to copy, paste, and use anywhere.
- The lexicographic sort order of the raw 32-byte Node ID matches its encoded form. This keeps things consistent whether Node IDs are stored in memory or displayed in a human-readable format.

## How This Works in Practice

- Node IDs always go through Multihash first, then Multibase.
- Base32 Hex is the default format, but the same Node ID can be rendered in other ways.
- If a different base or hash is chosen, the Node ID will look different but still represent the same key.

## Key Takeaways

- Node IDs are hashed first (Multihash) and then encoded (Multibase).
- The default encoding is Base32 Hex, but other formats are possible.
- Base32 Hex ensures sort order consistency, easy readability, and portability.
- The Polykey codebase and the JS-ID repo have more details if needed.

---