feat: NIP-03 opentimestamps support (#105) - #515
Conversation
archief2910
commented
Apr 18, 2026
hi @cameri , can you review it once i have implemented the nip-03 through this pr. |
There was a problem hiding this comment.
Pull request overview
Adds relay-side support for NIP-03 OpenTimestamps attestations by introducing structural .ots proof parsing/validation and a new event strategy for kind 1040, plus unit/integration coverage and metadata/docs updates.
Changes:
- Add
src/utils/nip03.tsto parse.otsbinaries and validate base64-encoded proofs (sha256 digest match + bitcoin attestation requirement). - Add
TimestampEventStrategyfor kind1040and dispatch it fromeventStrategyFactory. - Update constants/metadata (
EventKinds.OPEN_TIMESTAMPS,EventTags.Kind,supportedNips, README) and add tests (unit + cucumber integration).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/utils/nip03.ts | New OpenTimestamps .ots parser + validateOtsProof utility used by kind-1040 validation. |
src/handlers/event-strategies/timestamp-event-strategy.ts | New strategy enforcing NIP-03 tag requirements and proof validation before persistence. |
src/factories/event-strategy-factory.ts | Routes kind 1040 events to TimestampEventStrategy. |
src/utils/event.ts | Adds isOpenTimestampsEvent kind predicate used by the factory. |
src/constants/base.ts | Adds EventKinds.OPEN_TIMESTAMPS and EventTags.Kind. |
test/unit/utils/nip03.spec.ts | Unit tests for .ots parsing and proof validation. |
test/unit/handlers/event-strategies/timestamp-event-strategy.spec.ts | Unit tests for strategy acceptance/rejection behavior. |
test/unit/factories/event-strategy-factory.spec.ts | Ensures factory returns TimestampEventStrategy for kind 1040. |
test/integration/features/nip-03/nip-03.feature.ts | Cucumber steps to publish/subscribe to NIP-03 events end-to-end. |
test/integration/features/nip-03/nip-03.feature | Feature scenarios for valid and mismatching-digest attestations. |
package.json | Adds NIP-03 to supportedNips. |
README.md | Documents NIP-03 support in the features list. |
.changeset/nip-03-opentimestamps.md | Changeset for the new feature release. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
cameri
commented
Apr 19, 2026
were you able to test it with a client that supports OTS? |
archief2910
commented
Apr 19, 2026
yes i was able to test it with the client that supports ots . it worked i will update them in a bit. |
the environment in which i ran was with relay in docker and my ots tool was opentimestamps-client on the path.we grab a real kind 1040 from the public relay , run ots on the proof to show it’s a real timestamp file, then my local nostream accepts and returns that same NIP-03-shaped event. |
| @@ -0,0 +1,459 @@ | |||
| #!/usr/bin/env node | |||
Description
This PR adds NIP-03 support: kind
1040events that carry a base64-encoded OpenTimestamps (.ots) proof for another event.src/utils/nip03.ts— Structural parser and validator for binary.otsfiles: magic header, version, hash op, file digest, commitment tree, and attestation classification. Enforces SHA-256 file digest, digest equals thee-tagged event id (hex), and at least one Bitcoin block-header attestation. Does not verify against the Bitcoin chain (clients useots verify/ Esplora as in the NIP).TimestampEventStrategy— Handles kind1040: requires exactly oneetag (valid 64-char hex id), optional well-formedktag, then runsvalidateOtsProofoncontent.eventStrategyFactory— Dispatches kind1040toTimestampEventStrategy(alongside existing strategies).EventKinds.OPEN_TIMESTAMPSandEventTags.Kindinsrc/constants/base.ts;isOpenTimestampsEventinsrc/utils/event.ts.package.jsonsupportedNipsandREADME.mdfeatures list updated to include NIP-03.Related Issue
Closes#105
Motivation and Context
Issue #105 asks for NIP-03 so relays can accept and store OpenTimestamps attestations in a way that is not misleading: invalid proofs (wrong digest, no Bitcoin attestation, corrupt
.ots) are rejected before persistence, while full blockchain verification remains a client concern per the NIP.How Has This Been Tested?
package.jsonengines, Windows (local); CI should run Linux.npm run build:checknpm run lintnpm run knipnpm run test:unit(full suite)test/unit/utils/nip03.spec.ts(parser +validateOtsProof),test/unit/handlers/event-strategies/timestamp-event-strategy.spec.ts(strategy), extendedtest/unit/factories/event-strategy-factory.spec.ts.Screenshots (if appropriate):
N/A
Types of changes
Checklist: