Validate gift-wrap event id even when skipping Schnorr verify

Returning true unconditionally for wrap kinds also skipped the event id
(content hash) check. The id is what we index and dedupe on, so it must
still match the event's contents. Recompute the hash and compare it while
continuing to skip only the redundant outer signature verification.
This commit is contained in:
Alex Gleason committed 2026-07-09 15:17:57 -05:00
1 parent 17be8730f5
commit 05202229a5
1 file changed
+8 -3
+8 -3
View File
@@ -1,6 +1,6 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { type NostrSigner, NostrEvent, NostrFilter, NPool, NRelay1 } from '@nostrify/nostrify';
import { verifyEvent } from 'nostr-tools';
import { getEventHash, verifyEvent } from 'nostr-tools';
import { NostrContext } from '@nostrify/react';
import { NUser, useNostrLogin } from '@nostrify/react/login';
import { useQueryClient } from '@tanstack/react-query';
@@ -36,9 +36,14 @@ const NostrProvider: React.FC<NostrProviderProps> = (props) => {
open(url: string) {
return new NRelay1(url, {
// Gift-wrap (1059/21059) outer signatures are redundant on the client
// skip them, verify everything else.
// (ephemeral or group-shared key), so skip the Schnorr verify for them.
// The event id (content hash) must still be validated so that the id we
// index/dedupe on actually matches the event's contents; only the
// signature check is redundant. Verify everything else in full.
verifyEvent: (event: NostrEvent): boolean => {
if (event.kind === 1059 || event.kind === 21059) return true;
if (event.kind === 1059 || event.kind === 21059) {
return event.id === getEventHash(event);
}
return verifyEvent(event);
},