Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signing event with self-referencing p tag discards the tag #736

Open
xeruf opened this issue Jan 29, 2025 · 4 comments
Open

Signing event with self-referencing p tag discards the tag #736

xeruf opened this issue Jan 29, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@xeruf
Copy link
Contributor

xeruf commented Jan 29, 2025

Describe the bug
When creating an EventBuilder with a "p"-tag that contains the public key of the key that the event is signed with, the "p"-tag is discarded

To Reproduce

    let keys = Keys::generate();
    let builder = EventBuilder::new(Kind::from(1234), "test").tags([Tag::public_key(keys.public_key)]);
    println!("{:?}", builder);
    println!("{:?}", builder.sign_with_keys(&keys));

example output:

EventBuilder { kind: Custom(1234), tags: [Tag(["p", "258884c3e5e1433731654c6f7c604e0f2176a7c144a42ea1e2575b981fff40bb"])], content: "test", custom_created_at: None, pow: None }
Ok(Event { id: EventId(fc1a6dc2117ef31a7d16644c343a49b9fb880f2cd01e4ce3b56b0d36af03ca76), pubkey: PublicKey(258884c3e5e1433731654c6f7c604e0f2176a7c144a42ea1e2575b981fff40bb), created_at: Timestamp(1738187545), kind: Custom(1234), tags: [], content: "test", sig: Signature(cb5dbcb56fcf5156027fa0bddae53d48f3cd70f13a8696a6ed9a895ab292cae5765b4f609c540d0307950d6d0b602bc0da6d087f871e6d8cacb35424de135c86) })

Expected behavior
No discarding, unless that is something that may be in the spec?

Build environment

  • Library:
  • Language: Rust
  • Language version:
  • Tag/commit: 0.38
@xeruf xeruf added the bug Something isn't working label Jan 29, 2025
@yukibtc
Copy link
Member

yukibtc commented Jan 30, 2025

It's not a bug, it's a feature added at commit 27c656b, suggested by @dluvian here #657.
I'm going to write this also in the doc.

What is the purpose of tagging yourself?

yukibtc added a commit that referenced this issue Jan 30, 2025
Ref #736

Signed-off-by: Yuki Kishimoto <[email protected]>
@dluvian
Copy link
Contributor

dluvian commented Jan 31, 2025

Maybe it should be allowed to be included when using EventBuilder::tags, but EventBuilder::comment and similar functions should not add your own p-tag.

@xeruf
Copy link
Contributor Author

xeruf commented Jan 31, 2025

The purpose is that I use an own event kind for tracking tasks, and use the p-tag to assign somebody to the task.
I can also assign myself.

@yukibtc
Copy link
Member

yukibtc commented Feb 1, 2025

This is from NIP01: "The p tag, used to refer to another user"

https://github.com/nostr-protocol/nips/blob/f440eac3dccefa5c0ec9d3964e1d08357fd31e09/01.md?plain=1#L79

What if by default the self-tagging is not allowed, but enabling an option, it's allowed. Or the opposite?

Allow self-tagging only if explicitly enabled:

let event = builder.allow_self_tagging().sign(signer).await?;

The opposite, allow self-tagging by default and prevent it by calling a method:

let event = builder.prevent_self_tagging().sign(signer).await?;

@xeruf @dluvian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants