fix: check all sigs
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Kieran 2023-10-13 14:39:11 +01:00
parent 9251d5b90a
commit 87bb9dafeb
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 6 additions and 2 deletions

View File

@ -59,6 +59,7 @@ export abstract class EventExt {
* @returns True if valid signature
*/
static verify(e: NostrEvent) {
if ((e.sig?.length ?? 0) < 64) return false;
const id = this.createId(e);
const result = secp.schnorr.verify(e.sig, id, e.pubkey);
return result;
@ -175,6 +176,6 @@ export abstract class EventExt {
if (type === EventType.ParameterizedReplaceable) {
if (!findTag(ev, "d")) return false;
}
return true;
return EventExt.verify(ev);
}
}

View File

@ -179,7 +179,10 @@ export class NostrSystem extends ExternalStore<SystemSnapshot> implements System
}
#onEvent(sub: string, ev: TaggedNostrEvent) {
if (!EventExt.isValid(ev)) return;
if (!EventExt.isValid(ev)) {
this.#log("Rejecting invalid event %O", ev);
return;
}
for (const [, v] of this.Queries) {
v.handleEvent(sub, ev);