mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-03 08:07:21 +00:00
Skip redundant Schnorr verify on gift-wrap ingest
The outer signature on a NIP-59 gift-wrap (1059/21059) is cryptographically meaningless to the client: wraps are signed by a single-use ephemeral key (direct invites) or, in Concord V2, by a group-shared derived stream key any member can sign with, so the outer sig establishes no sender identity. Authenticity comes from NIP-44 authenticated encryption plus the inner seal signature check and rumor-pubkey/id bindings in the decrypt path. Pass a kind-scoped verifyEvent to NRelay1 that skips the Schnorr verify for wrap kinds only while keeping full verification for every other kind, whose identity does rest on its outer signature.
This commit is contained in:
1 file changed
+8
@@ -1,5 +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 { NostrContext } from '@nostrify/react';
|
||||
import { NUser, useNostrLogin } from '@nostrify/react/login';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
@@ -34,6 +35,13 @@ const NostrProvider: React.FC<NostrProviderProps> = (props) => {
|
||||
const [pool] = useState<NPool>(() => new NPool({
|
||||
open(url: string) {
|
||||
return new NRelay1(url, {
|
||||
// Gift-wrap (1059/21059) outer signatures are redundant on the client
|
||||
// skip them, verify everything else.
|
||||
verifyEvent: (event: NostrEvent): boolean => {
|
||||
if (event.kind === 1059 || event.kind === 21059) return true;
|
||||
return verifyEvent(event);
|
||||
},
|
||||
|
||||
// NIP-42: Respond to relay AUTH challenges by signing a kind
|
||||
// 22242 ephemeral event with the current user's signer.
|
||||
auth: async (challenge: string) => {
|
||||
|
||||
Reference in new issue
Block a user