fix: need to ensure we prefix the node id with the key type identifier

This commit is contained in:
Derrick Hammer 2023-09-01 03:22:46 -04:00
parent 320dec6e26
commit a19c515dda
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 14 additions and 12 deletions

17
npm-shrinkwrap.json generated
View File

@ -9,8 +9,7 @@
"version": "0.1.0-develop.3", "version": "0.1.0-develop.3",
"dependencies": { "dependencies": {
"@lumeweb/interface-relay": "^0.0.2-develop.3", "@lumeweb/interface-relay": "^0.0.2-develop.3",
"@lumeweb/libs5": "^0.1.0-develop.14", "@lumeweb/libs5-transport-hyper": "^0.1.0-develop.8",
"@lumeweb/libs5-transport-hyper": "^0.1.0-develop.5",
"@types/streamx": "^2.9.1", "@types/streamx": "^2.9.1",
"streamx": "^2.15.1" "streamx": "^2.15.1"
}, },
@ -1818,9 +1817,9 @@
} }
}, },
"node_modules/@lumeweb/libs5": { "node_modules/@lumeweb/libs5": {
"version": "0.1.0-develop.14", "version": "0.1.0-develop.15",
"resolved": "https://registry.npmjs.org/@lumeweb/libs5/-/libs5-0.1.0-develop.14.tgz", "resolved": "https://registry.npmjs.org/@lumeweb/libs5/-/libs5-0.1.0-develop.15.tgz",
"integrity": "sha512-nLRaDl3c355iDIUU40ES9P5FZvgPtpRJNnAymaJeOxQVjI9TlO+4aGiACB8Wv0uywjSfy6CHvYMS32UZNLhIHA==", "integrity": "sha512-am0t+jrepi42HyZzontQ5n0A4CJ70J8OlBgIKFroHQKwjKBD/ycbdyMf7lm1cKO1iou41PYulGnKIrb7w3xNJQ==",
"dependencies": { "dependencies": {
"@noble/curves": "^1.1.0", "@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1", "@noble/hashes": "^1.3.1",
@ -1832,11 +1831,11 @@
} }
}, },
"node_modules/@lumeweb/libs5-transport-hyper": { "node_modules/@lumeweb/libs5-transport-hyper": {
"version": "0.1.0-develop.5", "version": "0.1.0-develop.8",
"resolved": "https://registry.npmjs.org/@lumeweb/libs5-transport-hyper/-/libs5-transport-hyper-0.1.0-develop.5.tgz", "resolved": "https://registry.npmjs.org/@lumeweb/libs5-transport-hyper/-/libs5-transport-hyper-0.1.0-develop.8.tgz",
"integrity": "sha512-xLc7MhL9dIR7WkaLntkpU56XLNeko3FElB29Rm9q/IEG7xBiwD807ikjxPrBb8R/a/H7c7w1aUAlZVu4U26xxQ==", "integrity": "sha512-TAmSuRq3e6z97xwI1v7cBM9bLWMUHYuECTBeZSsW4RCe8Zkh8XT9mx6vQbiGSBzgBPK8jpCSzXJtO3juVPG/PQ==",
"dependencies": { "dependencies": {
"@lumeweb/libs5": "^0.1.0-develop.13", "@lumeweb/libs5": "^0.1.0-develop.15",
"streamx": "^2.15.1" "streamx": "^2.15.1"
} }
}, },

View File

@ -19,8 +19,7 @@
}, },
"dependencies": { "dependencies": {
"@lumeweb/interface-relay": "^0.0.2-develop.3", "@lumeweb/interface-relay": "^0.0.2-develop.3",
"@lumeweb/libs5": "^0.1.0-develop.14", "@lumeweb/libs5-transport-hyper": "^0.1.0-develop.8",
"@lumeweb/libs5-transport-hyper": "^0.1.0-develop.5",
"@types/streamx": "^2.9.1", "@types/streamx": "^2.9.1",
"streamx": "^2.15.1" "streamx": "^2.15.1"
} }

View File

@ -6,6 +6,8 @@ import {
NodeId, NodeId,
} from "@lumeweb/libs5"; } from "@lumeweb/libs5";
import HyperTransportPeer from "@lumeweb/libs5-transport-hyper"; import HyperTransportPeer from "@lumeweb/libs5-transport-hyper";
import { mkeyEd25519 } from "@lumeweb/libs5";
import { concatBytes } from "@noble/curves/abstract/utils";
import { Level } from "level"; import { Level } from "level";
import { PROTOCOL } from "./constants.js"; import { PROTOCOL } from "./constants.js";
@ -46,7 +48,9 @@ const plugin = {
protocol: PROTOCOL, protocol: PROTOCOL,
}); });
s5peer.id = new NodeId(peer.remotePublicKey); s5peer.id = new NodeId(
concatBytes(Uint8Array.from([mkeyEd25519], peer.remotePublicKey)),
);
await s5peer.init(); await s5peer.init();
node.services.p2p.onNewPeer(s5peer, true); node.services.p2p.onNewPeer(s5peer, true);