Signed decisions

rego4k can sign each decision of a policy, so that another system can verify which policy gave which output.

The format is an in-toto Statement in a DSSE envelope, with the predicate type https://rego4k.dev/decision/v1. in-toto is a framework and a format for software attestations. DSSE is a simple envelope format for signatures. See The format of a signed decision.

What a signed decision holds

A reader must be able to prove which policy gave which output for which input, and when. rego4k-signing-signer signs the output of a query.

A signed decision holds these items:

SignedDecisions.kt
val key = SigningKey(
    "decisions-2026",
    Key(privateKey, SignatureAlgorithm.ES256),
    certificateChain
)
val signed = DecisionSigner(bundle, rego, key).sign(
    Query.Entrypoint("authz/allow"),
    input,
    data,
    Principal(issuer, subject)
)
val decision = DecisionVerifier(
    Trust.Authorities(authorityCertificate, SignatureAlgorithm.ES256)
).verify(signed.envelope)
// evaluates the query again with the provided values of the decision
decision.reproduce(bundle, rego, input, data)
SignedDecisions.kt, lines 53 to 68, on GitHub

The input and the data are hashed in the canonical JSON form that bundle signing hashes for a structured file. A decision uses the same keys and the same 13 algorithms as bundle signing (rego4k-signing-utils).

We compared three formats:

We chose the in-toto Statement in a DSSE envelope. It is the format of software attestations, so a team can verify and store decisions with the tools that it uses for its other attestations.

For example, cosign, the signing tool of the Sigstore project, verifies a signed decision with its public key, and checks the digest of the input.

DSSE has no algorithm field to trust, and it signs the payload with its type. The envelope names the key with keyid. Each signature holds the certificate chain of its key (x5c, as in a JWS).

Thus a verifier needs only the certificate of an authority that it trusts. It checks the chain at the timestamp of the decision.

Only the output of a query that called no impure builtin can be reproduced:

See the READMEs of rego4k-signing-signer and rego4k-signing-verifier. A system that only receives decisions needs only rego4k-signing-verifier.

An upstream system can also sign the input that it sends, with its own key (InputSigner). Then the signed decision holds the signed input.

One verifier checks the whole chain: the upstream signed this input, and this policy gave this output for it. See "The chain of authority" in the README of rego4k-signing-verifier.

Signed decisions on the server

rego4k-server-signing adds a route to the decision server, like OPA's. The route signs each decision for the principal of the caller: POST /v1/signed/data/{path}. Another system verifies it with only the certificate of an authority.

The caller does not know the provided values before the query. Thus each signed decision gives them, and the signature covers them. The plain Data API of the server gives them with provided=true. See Build a decision server.