Compare commits

..

No commits in common. "4264ca099e420bf6d6d2fa295c17626baecde6d0" and "0df8050df88eb489d3e152d82dd4e9d32db8d1a2" have entirely different histories.

2 changed files with 3 additions and 13 deletions

View File

@ -40,7 +40,7 @@ function setup() {
try {
let query = Query.fromBinary(data);
events.emit("query", query, origin);
events.emit("response", query, origin);
} catch {}
});
}
@ -100,9 +100,6 @@ const plugin: Plugin = {
events.on("create", async (message: Message, origin: Buffer) => {
let newEntry = entryFromMessage(message);
if (!newEntry.signature?.length) {
return;
}
if (!verifyEntry(newEntry)) {
return;
}

View File

@ -1,16 +1,9 @@
import { SignedRegistryEntry } from "./types.js";
import * as ed from "@noble/ed25519";
import b4a from "b4a";
import { sha512 } from "@noble/hashes/sha512";
ed.utils.sha512Sync = (...m) => sha512(ed.utils.concatBytes(...m));
export function verifyEntry(entry: SignedRegistryEntry) {
return ed.sync.verify(
entry.signature,
createSignatureData(entry),
entry.pk.slice(1)
);
return ed.sync.verify(entry.signature, createSignatureData(entry), entry.pk);
}
export function signEntry(
@ -23,7 +16,7 @@ export function signEntry(
export function createSignatureData(entry: SignedRegistryEntry): Uint8Array {
return b4a.concat([
encodeEndian(entry.revision, 8),
b4a.from([entry.data.length]),
entry.data.length,
entry.data,
]);
}