A urd transaction is a signed message. Everything a client must do reduces to producing the right bytes and signing them, and both halves are published standards rather than urd-specific code:
| step | standard | Python | Rust | JS |
|---|---|---|---|---|
| encode | RFC 8949 canonical CBOR | cbor2 | ciborium / serde_cbor | cbor-x |
| sign | Ed25519 (RFC 8032) | cryptography, PyNaCl | ed25519-dalek | @noble/ed25519 |
There is no urd-specific hash, no pre-hash step, and nothing to port. This was
not true before — signatures used to cover hasch/edn-hash, a Clojure-specific
walk over Clojure's value model, and a client had to reimplement it correctly
before it could sign anything at all.
The signature covers the canonical CBOR encoding of
{:chain "urd-testnet-1" ; domain separation. NOT optional -- see below
:sender "deadbeefcafe" ; your namespace: the hex of your genesis hash
:nonce 7 ; exactly one more than the last; replay protection
:tx-data [...]} ; the datahike transaction
client.py is a complete working client in about fifteen lines. Run it and it
prints the message, the signature and the public key as hex; those exact values
are pinned in skuld.ledger.interop-test, so if that test ever fails, this
document is what broke.
pip install cbor2 cryptography
python3 doc/interop/client.py
For a metered ordinary transaction, also include the integer :fuel in the
canonical CBOR map before signing. Its range is 0 through 512. Omitting it
preserves the original signing bytes and supplies a zero contract budget.
Add the raw public key in :public-key and the base64url-encoded signature in
:signature to the signed fields. A block accepts the complete CBOR map as
one byte frame. The maximum is 1 MiB. Signing covers only the fields described
above. For the accepted operations, fee and nonce behavior, and the distinction
between signing bytes and transport bytes, see transactions.
Keywords are CBOR tag 39. A Clojure keyword rides as the registered
identifier tag around its printed form, colon included: :chain is
39(":chain"). In Python that is cbor2.CBORTag(39, ":chain"). This is not a
urd convention — kabel's CBOR wire already does it, so a client that can talk
to a kabel peer at all already handles it.
Canonical means RFC 8949, not RFC 7049. The two differ in map key ordering:
8949 sorts bytewise on the encoded key, 7049 sorted length-first. They disagree
whenever a map mixes key lengths, which every payload here does. cbor2's
canonical=True is 8949 in current releases and was 7049 in older ones. If
your signatures verify nowhere, check this first.
Sign the chain, and expect the node to check it against its own config.
:chain is what stops a transaction signed on a testnet from being a valid
transaction on mainnet. A verifier that took the chain from the same message it
is verifying would provide no separation at all, so urd's boundary compares it
against node configuration; a client that signs the wrong chain is refused
before anything else happens.
In order, cheapest first, each able to refuse alone:
chain -> known sender -> key authorised by genesis -> signature
-> nonce -> funds -> one speculative transaction
-> write scope -> invariants -> charge
:sender is a namespace, and a namespace is the hash of a genesis record — not
of a public key. That indirection is what lets you rotate your operational key
without your identity moving, and it is the difference between urd and the
did:key / SSB model where the key is the name and rotation is a new
identity. Register the genesis first; the node reads it from the account rather
than from your message, so an unregistered sender is refused as unknown.
Verifying a COMMIT CERTIFICATE -- the proof that a height was decided -- is
urd's, not skuld's, and lives in urd's own doc/interop. So does talking to a
peer over a WebSocket. What is here is the half that is specific to this
ledger: what a transaction is and what its signature covers.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |