Skip to main content

Module signing

Module signing 

Source
Expand description

Ed25519 sign-over-event_id (Nostr NIP-01 style).

Sign flow:

  1. Compute SHA-256 over canonical bytes of msg (strict: drops event_id).
  2. That 32-byte digest IS the event_id (hex-encoded for transport).
  3. Sign the raw 32-byte digest. The signature commits to event_id, which transitively commits to the canonical body — tamper anything, the digest changes, the signature fails.

Why sign the id and not the body: lets relays/index layers cite events by id without re-canonicalizing every body. Same property Nostr exploits.

Re-exports§

pub use crate::canonical::canonical as canonical_value;

Enums§

KindClass
SignError
VerifyError

Constants§

EVENT_SCHEMA_VERSION
Schema version tag stamped on every signed event by 0.5.11+. Pull-side verification rejects events whose schema_version’s major component disagrees with this — see pull::process_events.

Statics§

KIND_RANGES
Disjoint kind-id ranges. Mirrors v3 protocol; v0.1 ships a strict subset.

Functions§

b64decode
b64encode
canonical_event
compute_event_id
fingerprint
generate_keypair
Returns (private_key_bytes, public_key_bytes) — both 32 bytes, raw.
kind_class
Classify a kind id. None means unknown — caller decides how to handle.
kinds
v0.1 named kinds. Anything not here is unknown to this version.
kinds_map
kinds() as a BTreeMap for membership tests. Allocated per call — callers that need it hot should cache.
make_key_id
schema_major
Major component of a v<major>.<minor> schema_version. Used to decide whether a received event is wire-compatible.
sign_message_v31
Sign a message. Returns the canonical wire form: original fields + the computed event_id, public_key_id, signature.
verify_message_v31
Verify a signed message against a trust dict (see trust module).