Skip to content

Commit

Permalink
fix verifyEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
BlowaterNostr committed Jun 13, 2023
1 parent f31fdd8 commit 9548577
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions events.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { assertEquals } from "https://deno.land/std@0.176.0/testing/asserts.ts";
import { PrivateKey } from "./key.ts";
import { InMemoryAccountContext, prepareNormalNostrEvent, verifyEvent } from "./nostr.ts";

Deno.test("Verify Event", async () => {
let pri = PrivateKey.Generate();
let event = await prepareNormalNostrEvent(InMemoryAccountContext.New(pri), 1, [], "");
let ok = await verifyEvent(event);
assertEquals(ok, true);
});
4 changes: 2 additions & 2 deletions nostr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ export class InMemoryAccountContext implements NostrAccountContext {
};
}

export function verifyEvent(event: NostrEvent) {
export async function verifyEvent(event: NostrEvent) {
try {
return schnorr.verify(event.sig, calculateId(event), event.pubkey);
return schnorr.verify(event.sig, await calculateId(event), event.pubkey);
} catch (err) {
return false;
}
Expand Down

0 comments on commit 9548577

Please sign in to comment.