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

[FR] Support NIP-09 Event Deletion #38

Closed
8 tasks done
UTXOnly opened this issue Feb 18, 2024 · 0 comments · Fixed by #42
Closed
8 tasks done

[FR] Support NIP-09 Event Deletion #38

UTXOnly opened this issue Feb 18, 2024 · 0 comments · Fixed by #42

Comments

@UTXOnly
Copy link
Owner

UTXOnly commented Feb 18, 2024

Background

NIP-09 Allows clients to send a kind 5 event to delete events from storage within the relay.

Example kind 5 event:

{
  "kind": 5,
  "pubkey": <32-bytes hex-encoded public key of the event creator>,
  "tags": [
    ["e", "dcd59..464a2"],
    ["e", "968c5..ad7a4"],
    ["a", "<kind>:<pubkey>:<d-identifier>"]
  ],
  "content": "these posts were published by accident",
  ...other fields
}

User Story

As any user I want to send a kind 5 event to a relay and have that event deleted from the relay's database. The relay should also store the kind 5 event for future reference

Considerations

Although the spec only indicated that the pubkey from the kind 5 event should match the pubkey for the events to be deleted, I would like to actually verify the validity of the event using a method like below:

  • Was previously implemented in Nostpy for all events added link
async def verify_signature(event_id: str, pubkey: str, sig: str) -> bool:
    try:
        pub_key: secp256k1.PublicKey = secp256k1.PublicKey(bytes.fromhex("02" + pubkey), True)
        result: bool = pub_key.schnorr_verify(bytes.fromhex(event_id), bytes.fromhex(sig), None, raw=True)
        if result:
            logger.info(f"Verification successful for event: {event_id}")
        else:
            logger.error(f"Verification failed for event: {event_id}")
        return result
    except (ValueError, TypeError, secp256k1.Error) as e:
        logger.error(f"Error verifying signature for event {event_id}: {e}")
        return False

TO DO

  • Update event_handler service dependencies to include secp256k1
  • Update handle_new_event to check for kind 5
  • Update Event class to include method/s that:
    • Validates kind 5 event
    • Constructs DELETE statement
    • Executes DELETE statement
    • Replies to client with OK message indicating if the request was successful:
      • Ex ["OK", "b1a649ebe8...", true, ""]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant