Python binding
Confium ships a native Python extension built with PyO3 0.22.
Targets Python 3.9+. Source: crates/confium-python/ in the main
Rust workspace.
Install
pip install confium
Or from source:
pip install maturin
maturin develop --release # builds + installs into the current venv
Quick start
import confium
print(confium.version()) # "0.3.0"
print(confium.core_version()) # engine version
# Composite signature verification
from confium import composite
cs = composite.CompositeSignature([
composite.ComponentSignature(
algorithm=composite.ED25519,
public_key=pk_bytes, # 32 bytes
signature=sig_bytes, # 64 bytes
),
])
result = cs.verify(message_bytes)
assert result.all_verified
# Transparency log
from confium import transparency
tree = transparency.MerkleTree()
seq = tree.append("certificate_issuance", artifact_hash_bytes)
root = tree.root # 32 bytes
proof = tree.inclusion_proof(seq)
tree.verify_inclusion(seq, proof, root) # raises on failure
API surface
confium.version() / confium.core_version()
Return the binding version and underlying engine version as strings.
confium.composite
| Symbol |
Description |
ComponentSignature(algorithm, public_key, signature) |
Single component. |
CompositeSignature([ComponentSignature, ...]) |
Composite over multiple algorithms. |
CompositeSignature.from_json(s) |
Parse from JSON envelope. |
CompositeSignature.to_json() |
Serialize back to JSON. |
CompositeSignature.sign_ed25519(seed, msg) |
Classmethod: build 1-component Ed25519 composite. |
CompositeSignature.sign_p256(seed, msg) |
Classmethod: build 1-component ECDSA-P256 composite. |
CompositeSignature.verify(msg) |
Built-in Ed25519 + ECDSA-P256. |
CompositeSignature.verify_with(msg, cb) |
Caller-supplied verifier callback. |
VerificationResult.all_verified |
bool — every component verified. |
VerificationResult.per_component |
list of dicts. |
verify_ed25519(pk, msg, sig) |
Standalone Ed25519 verifier. |
verify_ecdsa_p256(pk, msg, sig) |
Standalone ECDSA-P256 verifier (SEC1 pubkey, DER sig). |
ED25519 / ECDSA_P256 / ML_DSA_65 |
Algorithm name constants. |
confium.transparency
| Symbol |
Description |
MerkleTree() |
New empty RFC 6962 tree. |
MerkleTree.append(artifact_type, hash) |
Append entry; returns sequence. |
MerkleTree.root |
32-byte root (empty → all-zeros). |
MerkleTree.size / is_empty |
Entry count / emptiness. |
MerkleTree.inclusion_proof(seq) |
Build RFC 6962 §2.1.1 proof. |
MerkleTree.verify_inclusion(seq, proof, root) |
Round-trip verify. |
MerkleTree.entry(seq) |
Dict: sequence, timestamp, artifact_type, artifact_hash. |
MerkleTree.consistency_proof(old_size) |
RFC 6962 §2.1.2 consistency path. |
MerkleTree.verify_consistency(old_root, new_root, old_size, new_size, proof) |
Brute-force verify. |
compute_leaf_hash(seq, ts, hash) |
Recompute published leaf hash. |
verify_inclusion_with_leaf(leaf, proof, root) |
External-auditor entry point. |
ARTIFACT_TYPES |
Tuple of accepted artifact_type strings. |
confium.pki
| Symbol |
Description |
Certificate.from_der(bytes) / from_pem(str) |
Parse X.509 v3. |
Certificate.to_der() / to_pem() |
Serialize back. |
Certificate.fingerprint_sha256 |
Lowercase hex SHA-256. |
Certificate.serial_bytes / public_key_bytes |
SPKI fields. |
Certificate.not_before / not_after |
ISO 8601 validity bounds. |
Certificate.is_within_validity(now=None) |
Validity check. |
CSR.from_der(bytes) / from_pem(str) |
Parse PKCS#10. |
SignedData.from_json(s) |
Parse CMS SignedData (RFC 5652 §5.1). |
SignedData.build_detached(sig, alg, certs) |
Classmethod: build 1-signer detached CMS. |
SignedData.to_der() |
Encode as RFC 5652 ContentInfo DER. |
SignedData.verify(msg, cb) / verify_with_builtin(msg) |
CMS verify. |
confium.attributes
| Symbol |
Description |
Predicate.parse(src) |
Parse DSL expression. |
Predicate.evaluate([SignerAttributes, ...]) |
Evaluate against signers. |
SignerAttributes({attr: [vals]}) |
Construct from dict. |
SignerAttributes.add(key, val) |
Add value to attribute. |
EXAMPLES |
Dict of example DSL expressions. |
confium.tc
Threshold cryptography (peer-to-peer in-process drivers):
| Symbol |
Description |
tc.FrostP256.generate_keypair() |
Generate P-256 keypair (returns dict). |
tc.FrostP256.split_secret(secret, t, n) |
Shamir-split into N shares, threshold T. |
tc.FrostP256.recover_secret([share, ...]) |
Recover secret from T shares. |
tc.FrostP256.sign(...) |
ECDSA-P256 sign. |
tc.ElGamalP256.encapsulate(pk) |
Threshold ElGamal KEM encapsulate. |
tc.ElGamalP256.partial_decrypt(share, ct) |
Per-custodian partial decryption. |
tc.ElGamalP256.aggregate_partials(partials, t, ct) |
Combine T partials → shared secret. |
tc.Cmp20.keygen(t, n) |
CMP20 in-process DKG → shares + joint pubkey. |
tc.Cmp20.sign(shares, t, msg) |
CMP20 threshold ECDSA sign → 64-byte (r,s). |
tc.Gg18.keygen(t, n) |
GG18 in-process DKG. |
tc.Gg18.sign(shares, t, msg) |
GG18 threshold ECDSA sign. |
import confium
kg = confium.tc.Cmp20.keygen(threshold=2, party_count=3)
sig = confium.tc.Cmp20.sign(kg["shares"][:2], threshold=2, message=b"hi")
confium.deployment
| Symbol |
Description |
Manifest.from_toml(s) |
Parse a deployment manifest. |
Manifest.to_toml() |
Serialize back to TOML. |
Manifest.validate() |
Validate internal consistency (returns issue list). |
Manifest.name / operator / mode / tier_count |
Manifest accessors. |
confium.ers — Evidence Record Syntax (RFC 4998)
| Symbol |
Description |
EvidenceRecord.build_initial(hash, tsa_id, token) |
Build the initial archival evidence. |
EvidenceRecord.renew(new_hash, tsa_id, token) |
Re-timestamp under a newer hash. |
EvidenceRecord.renewal_count |
Number of renewals so far. |
confium.ots — OpenTimestamps (Bitcoin anchoring)
| Symbol |
Description |
OtsClient() |
Calendar-server client. |
OtsClient.calendar_servers |
Configured calendar server URLs. |
OtsClient.stamp(hash) |
Submit a 32-byte hash for anchoring. |
OtsProof.hash |
The anchored hash. |
OtsProof.bitcoin_height |
Bitcoin block height of the anchor. |
OtsVerification.valid |
Whether the proof verified. |
OtsVerification.bitcoin_height |
Block height (0 if unconfirmed). |
OtsVerification.block_timestamp |
Block timestamp (None if pending). |
confium.xmldsig — XML canonicalization
| Symbol |
Description |
xmldsig.canonicalize(xml) |
RFC 3076 Canonical XML 1.0. |
xmldsig.canonicalize_exclusive(xml) |
RFC 3741 Exclusive C14N. |
Building from source
cd crates/confium-python
python3 -m venv .venv
source .venv/bin/activate
pip install maturin pytest cryptography
maturin develop --release
pytest tests/
Limitations
Python now covers verification, parsing, and signing for composite +
transparency + PKI. Remaining gaps (use Ruby for these):
- TC sessions (FROST-P256, ElGamal-P256) — large API surface, in progress for v0.4
- OTS / ERS archival exposure
- Identity Actor / Config Manifest
- External proof-only consistency verification —
MerkleTree.verify_consistency
is method-based (requires &self) because the proof-only algorithm is intricate.
External auditors who only have (old_root, new_root, proof) and not the tree
itself need the standalone verifier — tracked as not yet implemented 067.
See the bindings parity matrix for the full breakdown.
See also