keyer, nip17, nip44, nip59: this time is different!

This commit is contained in:
fiatjaf
2024-09-15 11:06:42 -03:00
parent f976296e01
commit db023e12e9
5 changed files with 67 additions and 55 deletions

View File

@@ -49,9 +49,20 @@ func PrepareMessage(
}
rumor.ID = rumor.GetID()
wraps, err := nip59.GiftWrap(
toUs, err = nip59.GiftWrap(
rumor,
[]string{ourPubkey, recipientPubKey},
ourPubkey,
func(s string) (string, error) { return kr.Encrypt(ctx, s, ourPubkey) },
func(e *nostr.Event) error { return kr.SignEvent(ctx, e) },
modify,
)
if err != nil {
return nostr.Event{}, nostr.Event{}, err
}
toThem, err = nip59.GiftWrap(
rumor,
recipientPubKey,
func(s string) (string, error) { return kr.Encrypt(ctx, s, recipientPubKey) },
func(e *nostr.Event) error { return kr.SignEvent(ctx, e) },
modify,
@@ -60,7 +71,7 @@ func PrepareMessage(
return nostr.Event{}, nostr.Event{}, err
}
return wraps[0], wraps[1], nil
return toUs, toThem, nil
}
// ListenForMessages returns a channel with the rumors already decrypted and checked