Gift Wrap

low level

Example

/// Wrap event:

// Create an original rumor event
final originalRumor = await ndk.giftWrap.createRumor(
  content: 'Test message for gift wrap',
  kind: 1,
  tags: [],
);

// Wrap the rumor in a gift wrap
final giftWrap = await ndk.giftWrap.toGiftWrap(
  rumor: originalRumor,
  recipientPubkey: "<reciever public key>",
);

log(giftWrap.toString());
/// Unwrap event:

final recvEvent = await ndk.giftWrap.fromGiftWrap(giftWrap: giftWrap);

log(recvEvent.toString());

When to use

You can use Gift Wrap to obscure metadata. It also encrypts the content using nip44.
More information here:

Nostr nip 59
https://github.com/nostr-protocol/nips/blob/master/59.md

Current behavior

Gift wrap APIs:

  • create rumors
  • seal rumors
  • wrap sealed rumors
  • unwrap gift wraps
  • read cached unwrap results when plaintext sidecars already exist

Decryption behavior:

  • wrapped and sealed payload plaintext can be cached separately from the original events
  • later unwraps can reuse cached plaintext
  • cache-only unwrap is available when the required sidecars already exist