Liking cljdoc? Tell your friends :D

psosf.sign

Signatures on PSOSF archives, as defined in the PSOSF specification.

An archive's signatures.json holds a digest list (the SHA-256 of every other file, sorted by path) and Ed25519 signatures over messages that bind each signer, role and time to that list. Any change to the archive's content invalidates every signature.

(verify-entries entries {:resolve-key f}) (sign-entries entries {:private-key k ...})

The digest list and the signature message are built here in portable code, so every implementation produces the same bytes. Hashing and Ed25519 use the JVM's built-in providers, or WebCrypto in JavaScript.

Keys are resolved through a function the caller supplies, from a key id to a key record (string keys):

{"key-id" "acme/users/a.mensah@acme.example/2026-11" "public-key" "<Base64 of the raw 32-byte Ed25519 public key>" "owner" {"kind" "human" "id" "a.mensah@acme.example"} "registered-at" "2026-11-02T14:00:00Z" "revoked-at" nil "custody" "device"}

custody records where the private key is held: "device", on the signer's own machine, or "service", held by the Zen service, which signs for the signed-in user. A record without it is treated as "device".

On the JVM, verify-entries and sign-entries return their results; in JavaScript they return promises, using WebCrypto.

This is the form WebCrypto exports (exportKey "raw"), and the form the Zen service returns for a key id.

Signatures on PSOSF archives, as defined in the PSOSF specification.

An archive's signatures.json holds a digest list (the SHA-256 of every
other file, sorted by path) and Ed25519 signatures over messages that bind
each signer, role and time to that list. Any change to the archive's
content invalidates every signature.

  (verify-entries entries {:resolve-key f})
  (sign-entries entries {:private-key k ...})

The digest list and the signature message are built here in portable code,
so every implementation produces the same bytes. Hashing and Ed25519 use
the JVM's built-in providers, or WebCrypto in JavaScript.

Keys are resolved through a function the caller supplies, from a key id to
a key record (string keys):

  {"key-id"        "acme/users/a.mensah@acme.example/2026-11"
   "public-key"    "<Base64 of the raw 32-byte Ed25519 public key>"
   "owner"         {"kind" "human" "id" "a.mensah@acme.example"}
   "registered-at" "2026-11-02T14:00:00Z"
   "revoked-at"    nil
   "custody"       "device"}

custody records where the private key is held: "device", on the signer's
own machine, or "service", held by the Zen service, which signs for the
signed-in user. A record without it is treated as "device".

On the JVM, verify-entries and sign-entries return their results; in
JavaScript they return promises, using WebCrypto.

This is the form WebCrypto exports (exportKey "raw"), and the form the
Zen service returns for a key id.
raw docstring

archive-digestclj

(archive-digest entries)

The SHA-256 of the digest list, identifying the archive's content.

The SHA-256 of the digest list, identifying the archive's content.
sourceraw docstring

attach-signatureclj/s≠

(attach-signature entries details signature-base64)
clj

Adds a signature made over (signing-message entries details). When :public-key (Base64, raw 32 bytes) is given in details, the signature is checked first and refused if it does not verify.

Adds a signature made over (signing-message entries details). When
:public-key (Base64, raw 32 bytes) is given in details, the signature
is checked first and refused if it does not verify.
cljs

A promise of the entries with a signature added. When :public-key (Base64, raw 32 bytes) is given in details, the signature is checked first, and the promise rejects if it does not verify.

A promise of the entries with a signature added. When :public-key
(Base64, raw 32 bytes) is given in details, the signature is checked
first, and the promise rejects if it does not verify.
source (clj)source (cljs)raw docstring

digest-list-textclj/s

(digest-list-text digests)

The digest list as text: one line per file, the lowercase hex SHA-256, two spaces and the path, sorted by path, each line ending in a line feed. digests maps path to hex digest.

The digest list as text: one line per file, the lowercase hex SHA-256, two
spaces and the path, sorted by path, each line ending in a line feed.
digests maps path to hex digest.
sourceraw docstring

digestsclj/s≠

(digests entries)
clj

The digest map {path hex} of every entry except signatures.json.

The digest map {path hex} of every entry except signatures.json.
cljs

A promise of the digest map {path hex} of every entry except signatures.json.

A promise of the digest map {path hex} of every entry except signatures.json.
source (clj)source (cljs)raw docstring

generate-key-pairclj

(generate-key-pair)

A new Ed25519 key pair: {"private-key" seed, "public-key" raw}, each Base64.

A new Ed25519 key pair: {"private-key" seed, "public-key" raw}, each Base64.
sourceraw docstring

messageclj/s

(message {:strs [algorithm key-id role signer signed-at]} digests)

The text a signature is made over, for a signature map with string keys and the archive's digest map.

The text a signature is made over, for a signature map with string keys
and the archive's digest map.
sourceraw docstring

private-keyclj

(private-key seed-base64)

A JVM PrivateKey from the Base64 of a raw 32-byte Ed25519 seed, for callers (Python, C) that hold the key as bytes.

A JVM PrivateKey from the Base64 of a raw 32-byte Ed25519 seed, for
callers (Python, C) that hold the key as bytes.
sourceraw docstring

public-keyclj

(public-key raw-base64)

A JVM PublicKey from the Base64 of a raw 32-byte Ed25519 key.

A JVM PublicKey from the Base64 of a raw 32-byte Ed25519 key.
sourceraw docstring

raw-public-keyclj/s≠

clj
(raw-public-key k)

The Base64 of the raw 32 bytes of a JVM Ed25519 PublicKey, as stored in a key record.

The Base64 of the raw 32 bytes of a JVM Ed25519 PublicKey, as stored in a key record.
cljs
(raw-public-key public-key)

A promise of the Base64 of a CryptoKey public key's raw 32 bytes, as registered with the Zen service.

A promise of the Base64 of a CryptoKey public key's raw 32 bytes, as
registered with the Zen service.
source (clj)source (cljs)raw docstring

sha-256-hexclj/s≠

(sha-256-hex s)
clj

Lowercase hex SHA-256 of a string's UTF-8 bytes.

Lowercase hex SHA-256 of a string's UTF-8 bytes.
cljs

A promise of the lowercase hex SHA-256 of a string's UTF-8 bytes.

A promise of the lowercase hex SHA-256 of a string's UTF-8 bytes.
source (clj)source (cljs)raw docstring

sign-entriesclj/s≠

(sign-entries entries {:keys [private-key] :as details})
clj

Adds a signature to an archive, returning the new entries. Every other file must already be in its final form; signing never changes them. An existing signatures.json keeps its signatures, so an approver signs an archive the author has already signed. :private-key an Ed25519 private key: see private-key :key-id the key's id, as registered :role "author" or "approver" :signer {"kind" "human"|"agent" "id" ... "model" ...} :signed-at ISO 8601 UTC time

Adds a signature to an archive, returning the new entries. Every other
file must already be in its final form; signing never changes them. An
existing signatures.json keeps its signatures, so an approver signs an
archive the author has already signed.
  :private-key  an Ed25519 private key: see private-key
  :key-id       the key's id, as registered
  :role         "author" or "approver"
  :signer       {"kind" "human"|"agent" "id" ... "model" ...}
  :signed-at    ISO 8601 UTC time
cljs

A promise of the entries with a signature added. :private-key is a WebCrypto Ed25519 CryptoKey, which may be non-extractable.

A promise of the entries with a signature added. :private-key is a
WebCrypto Ed25519 CryptoKey, which may be non-extractable.
source (clj)source (cljs)raw docstring

signatures-pathclj/s

source

signing-messageclj/s≠

(signing-message entries details)
clj

Signing in two steps, for a key the library cannot hold (a key service, a hardware key, the Zen service): the exact text to sign. Sign its UTF-8 bytes with Ed25519, then pass the Base64 signature to attach-signature with the same details. details: :key-id :role :signer :signed-at.

Signing in two steps, for a key the library cannot hold (a key service,
a hardware key, the Zen service): the exact text to sign. Sign its UTF-8
bytes with Ed25519, then pass the Base64 signature to attach-signature
with the same details. details: :key-id :role :signer :signed-at.
cljs

A promise of the exact text to sign, for signing in two steps. Sign its UTF-8 bytes with Ed25519, then call attach-signature with the same details.

A promise of the exact text to sign, for signing in two steps. Sign its
UTF-8 bytes with Ed25519, then call attach-signature with the same
details.
source (clj)source (cljs)raw docstring

sort-pathsclj/s

(sort-paths paths)
source

verify-entriesclj/s≠

(verify-entries entries {:keys [resolve-key] :as opts})
clj

Verifies an archive's signatures. Options: :resolve-key key id -> key record, or nil when unknown (required) :received-at ISO 8601 UTC time the archive was received; a key revoked after this time still vouches for it :approver-custody custodies an approver's key may have, e.g. #{"device"}; any custody when absent Returns {:status :unsigned | :verified | :failed :digests {:match bool :changed [...] :added [...] :removed [...]} :signatures [{:key-id :role :signer :signed-at :custody :valid :reason}] :errors [...]} :verified means the files are exactly those signed and every signature is valid. Signatures are never removed, whatever the result.

Verifies an archive's signatures. Options:
  :resolve-key       key id -> key record, or nil when unknown (required)
  :received-at       ISO 8601 UTC time the archive was received; a key
                     revoked after this time still vouches for it
  :approver-custody  custodies an approver's key may have, e.g.
                     #{"device"}; any custody when absent
Returns
  {:status     :unsigned | :verified | :failed
   :digests    {:match bool :changed [...] :added [...] :removed [...]}
   :signatures [{:key-id :role :signer :signed-at :custody :valid :reason}]
   :errors     [...]}
:verified means the files are exactly those signed and every signature
is valid. Signatures are never removed, whatever the result.
cljs

A promise of the same result as the JVM's verify-entries. :resolve-key may return a key record or a promise of one.

A promise of the same result as the JVM's verify-entries. :resolve-key
may return a key record or a promise of one.
source (clj)source (cljs)raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close