nostr: add NIP-40 expiration to gift wrap and private DM builders#1384
Conversation
|
I know the bindings live in nostr-sdk-ffi and this only touches the core crate. |
22bc4ba to
3508765
Compare
Add an expiration option to GiftWrapBuilder and PrivateDirectMessageBuilder. The NIP-40 expiration tag is anchored to the gift wrap's randomized created_at (created_at + duration) instead of the real send time, so it doesn't leak when the message was actually sent. Closes nostrdevkit#1381 Pull-Request: nostrdevkit#1384 Signed-off-by: Info <info@unsaltedbutter.ai> Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
3508765 to
9df86d4
Compare
|
Thanks! Squashed and merged at 9df86d4
Sure, feel free to open a PR also for FFI, thanks! |
|
@yukibtc — for this NIP-40 change, it's a small change in the FFI:
However, nostr-sdk-ffi still pins nostr at alpha.2 (83fa932), and this change is only reachable at alpha.3+ (9df86d4). Moving the pin also crosses the NIP‑03/15/31/90 removal, which breaks the current bindings (nip90.rs, EventBuilder::job_*, Tag::alt, some Kind variants). Are you working on bumping the FFI to alpha.3, or do you want me to include that bump & migration as a part of a NIP-40 PR? |
|
@unsaltedbutter-ai, I've updated it at nostrdevkit/nostr-sdk-ffi@96ecfad and exposed expiration for NIP-17 and NIP-59 at nostrdevkit/nostr-sdk-ffi@09c0f7f |
|
Thank you. I have a project ready to use this — will keep an eye out for the next nostr-sdk release that includes it. |
I'll probably release the nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "<commit>" } |
Description
Add an expiration option to GiftWrapBuilder and PrivateDirectMessageBuilder. The NIP-40 expiration tag is anchored to the gift wrap's randomized created_at (created_at + duration) instead of the real send time, so it doesn't leak when the message was actually sent.
Closes #1381
Notes to the reviewers
One design decision:
expiration is a builder method taking a Duration rather than something you pass through extra_tags.
It has to be anchored to the gift wrap's created_at, which is randomized internally and not exposed to the caller.
Setting an absolute timestamp from outside would leak the real send time (subtract the duration and you've got it).
So by setting Duration, the library does created_at + duration and nothing leaks.
NIP-17 just hands the same value down to the gift wrap builder. The tag goes on the gift wrap, not the kind:13 seal, which NIP-59 requires to be empty.
Checklist