Skip to main content

mosaic-credential (Python)

Python bindings and reference implementation for Mosaic Credential v1 (mosaic-core / mosaic-auth).

Conforms strictly to the Mosaic Credential Technical Specification v0.1.

Features

  • Structured Secret Composition: Interleave arbitrary Unicode text (with exact scalar preservation) and arbitrary binary files (BLOBs).
  • Exact Backspace Semantics (§5.1): Backspace is represented as CHAR(U+0008) as a deliberate secret element rather than automatically discarding preceding input.
  • Canonical MC v1 Streaming Binary Serialization (§6).
  • Domain-Separated SHA-256 Prehashing (§8.2).
  • Argon2id Verifier Derivation (§8.3) with compact JSON verifier storage (VerifierRecord).
  • Enforces Size Policies (§7): Limits on total encoded bits, maximum blob bits, and maximum element counts.
  • Cross-Platform Test Vector Compatibility (§16.4): Verified 100% against published test vectors matching Rust and WebAssembly implementations.

Installation

pip install mosaic-credential

Quickstart API (§12.3)

from mosaic_credential import CredentialBuilder, Policy, AuthParams, enroll, verify, VerifyResult

# 1. Define application size policy
policy = Policy(
    max_encoded_bits=2_000_000_000,
    max_blob_bits=2_000_000_000,
    max_elements=100_000,
)

# 2. Build the credential
builder = CredentialBuilder(policy)
builder.add_text("Pass")
builder.add_backspace(count=3)
builder.add_blob(b"\x00\x01\x02\x03\x04")
builder.add_text("word")

credential = builder.finalize()

# 3. Enroll (produces compact JSON verifier record)
record = enroll(credential, AuthParams.default())
record_json = record.to_json()
print("Stored record:\n", record_json)

# 4. Verify candidate
candidate_builder = CredentialBuilder(policy)
candidate_builder.add_text("Pass")
candidate_builder.add_backspace(count=3)
candidate_builder.add_blob(b"\x00\x01\x02\x03\x04")
candidate_builder.add_text("word")

result = verify(candidate_builder.finalize(), record)
assert result == VerifyResult.OK

Running Tests

pytest tests/ -v

Metadata

Release files for mosaic-credential 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mosaic-credential 0.1.1
File Size Uploaded
mosaic_credential-0.1.1.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mosaic-credential 0.1.1
File Interpreter ABI Platform
mosaic_credential-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / mosaic_credential-0.1.1.tar.gz

Download URL mosaic_credential-0.1.1.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
64376907fbd73994d799c8ad9ad306ee110cc927ee820baa34aa759c70e664f5
BLAKE2b-256 checksum
How to use checksums
efd811224b0e310a5a89e4c4f1a9e3f68a2e5798f7e3bf3257a9cf8cfda9a699
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / mosaic_credential-0.1.1-py3-none-any.whl

Download URL mosaic_credential-0.1.1-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37c486ee9a50d0abfebf3a5e8a20a82e4e93ef36624b75ad7671e0212c17664a
BLAKE2b-256 checksum
How to use checksums
e819e33968b213d7376994437bf135d20c5e022546164f80bff3130a0ba8d034
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page