Examples

The examples/ directory contains runnable demos. Each is a self-contained Ruby file that you can run with ruby examples/<name>.rb after bundle install.

Hello world examples (5-minute demos)

hello_cert.rb

Parse a certificate, compute its hash, anchor it in a transparency log, and verify the inclusion proof. Demonstrates the core audit pattern: every artifact is anchored and verifiable.

hello_composite.rb

Generate an Ed25519 keypair, sign a message, verify the signature. Then parse an attribute-based threshold predicate (“2-of-3 directors from 2 distinct regions”) and evaluate it against a signer set.

hello_policy.rb

Set jurisdictional algorithm allow-lists, toggle FIPS 140 mode, and handle Confium::PolicyViolationError when a disallowed algorithm is attempted.

hello_errors.rb

Trigger each typed error class in the Confium::Error hierarchy and demonstrate per-class rescue patterns with structured .details.

hello_manifest.rb

Load a deployment manifest from TOML, inspect the coordinator configuration, quorum policy, algorithm allow-lists, and signer list.

Full demos

threshold_signing.rb

Shamir-split a P-256 secret across 5 parties, recover from any 3, sign a message. The canonical threshold crypto demo.

composite_verify.rb

Verify a composite signature containing Ed25519 + ECDSA-P256 + ML-DSA-65 components.

transparency_anchor.rb

Anchor a certificate issuance in a Merkle transparency log.

Adding a new example

  1. Pick a single concept (one subsystem, one flow).
  2. Keep it under 60 lines.
  3. Print clear output at each step.
  4. No double() or mocks — use real Confium calls.
  5. Use require "confium" only (no require_relative).
  6. Add a paragraph above the example in this index.