privateKey = $privateKey; return $this; } /** * Set the public key. */ public function withPublicKey(string $publicKey): self { $this->publicKey = $publicKey; return $this; } /** * Set relays to publish to. */ public function withRelays(array $relays): self { $this->relays = $relays; return $this; } /** * Request deletion of an event (NIP-09). * * @param string $id Event ID to delete */ public function delete(string $id): Response { if (! $this->privateKey || ! $this->publicKey) { return $this->error('Private and public keys required'); } // Build deletion event (kind 5) $event = [ 'kind' => 5, 'pubkey' => $this->publicKey, 'created_at' => time(), 'tags' => [ ['e', $id], // Reference to event being deleted ], 'content' => 'Deletion request', ]; // Calculate event ID $serialized = json_encode([ 0, $event['pubkey'], $event['created_at'], $event['kind'], $event['tags'], $event['content'], ]); $event['id'] = hash('sha256', $serialized); // Sign the event $event['sig'] = $this->signEvent($event['id']); // Note: This is a soft delete - relays may ignore it return $this->ok([ 'deletion_event_id' => $event['id'], 'deleted_event_id' => $id, 'note' => 'Deletion is a request; relays may not honour it', ]); } /** * Sign event with private key. */ protected function signEvent(string $eventId): string { // Placeholder - use proper Schnorr signing in production return hash_hmac('sha256', $eventId, $this->privateKey); } }