[nix-shell:~/Documents/MatrixAI/js-polykey]$ npm run ts-node -- nodeIds.ts
> @matrixai/polykey@1.0.0 ts-node /home/josh/Documents/MatrixAI/js-polykey
> ts-node -r tsconfig-paths/register "nodeIds.ts"
publicKeyToFingerprintBytes length 43: 32
publicKeyToFingerprintBytes length 44: 32
fTypedArray 43: Uint8Array(32) [
10, 45, 47, 45, 125, 109, 40, 40,
20, 160, 60, 163, 101, 100, 189, 222,
38, 35, 246, 172, 73, 251, 232, 221,
13, 97, 139, 151, 240, 251, 129, 201
]
fTypedArray 44: Uint8Array(32) [
233, 254, 155, 220, 4, 146, 225, 43,
130, 201, 87, 50, 52, 141, 221, 156,
15, 162, 131, 58, 120, 191, 146, 36,
49, 133, 50, 92, 203, 95, 232, 13
]
Hex string 43: 0a2d2f2d7d6d282814a03ca36564bdde2623f6ac49fbe8dd0d618b97f0fb81c9
gj3DUVjzAGHvmP9ZRFB5geWLVRwXUSdEUtMcVvxozLx
gj3DUVjzAGHvmP9ZRFB5geWLVRwXUSdEUtMcVvxozLx
Specification
We'd like to canonicalise the representation of a keynode's node ID.
Recall that the node ID of a node is based on the public key of a keynode: it is a public key fingerprint. At the moment, we produce a SHA-256 hash of the public key, resulting in an array of 32 bytes. This array of bytes can be currently seen as the primitive canonicalised representation of the node ID.
The representation needs to provide:
Previously, we were using
base64as the encoding choice for a human-readable version of the node ID. This produced fixed-size node IDs of 44 characters, but used unsafe characters (e.g./,+).After that, we were then looking at
base58btc. This has the advantage of no longer producing URL-unsafe characters, as well as some quality-of-life improvements by not including visually-similar characters. However, it can produce different sized node IDs. See below:Details
As a temporary solution, we've adopted a
base32hexencoding, producing a fixed fixed 53 character node ID, such asv6n7m9vuf44pfqq133re8v91ju7a8968h4nkirjt8r7r9pbcoqqq0(with a prependedvcharacter frommultibase): https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/205#note_711237922Additional context
NodeIdas a proxy/singleton instance #254 - will need to look at this issue concurrentlybase58andbase58btcTasks
NodeGraph(kademlia), across GRPC, etc)