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.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mosaic_credential-0.2.0.tar.gz | 11.7 kB | Without provenance | Details for mosaic_credential-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mosaic_credential-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for mosaic_credential-0.2.0-py3-none-any.whl |
Total release size: 21.2 kB
Release files / mosaic_credential-0.2.0.tar.gz
| Download URL | mosaic_credential-0.2.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9623a4d6a930b8c6c4a5d8ba0897856560fb0dbd079cb2077ef9a5dea15086c
|
|
BLAKE2b-256 checksum How to use checksums |
0f266e5ce4854c0abd98d7e0f553f01fefd0b3ea5a09acb9e73813319cf27b54
|
| 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.2.0-py3-none-any.whl
| Download URL | mosaic_credential-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b6caca27f07185c2319f4217c42ecaabf39de71b48a7c121a45766749bc5634e
|
|
BLAKE2b-256 checksum How to use checksums |
8b653017571b1d595cd35f789a6669357b0f54014aa64b9dd56763abebec52af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for mosaic-credential 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.