Metadata-Version: 2.4
Name: mintid-proof-core
Version: 0.9.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Rust
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
License-File: LICENSE
License-File: NOTICE
Summary: MintID proof core for Python: the headless holder library and the issuance side of the anonymous-credential core, with the Rust core compiled in
Keywords: mintid,identity,anonymous-credentials,zero-knowledge,selective-disclosure,revocation
Author-email: Marc Molas <marc@mintid.net>
License-Expression: Apache-2.0
Requires-Python: >=3.12
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://gitlab.com/mintid/mintid/-/blob/main/docs/sdk/08-credentials-and-holders.md
Project-URL: Homepage, https://mintid.net
Project-URL: Issues, https://gitlab.com/mintid/mintid/-/issues
Project-URL: Repository, https://gitlab.com/mintid/mintid
Project-URL: Security, https://gitlab.com/mintid/mintid/-/blob/main/SECURITY.md
Project-URL: Source, https://gitlab.com/mintid/mintid/-/tree/main/identity-proof-core

# mintid-proof-core

Python bindings of the MintID proof core: the anonymous-credential core,
written in Rust and compiled into this package, with the headless **holder
library** (`proof_core.holder`) and the issuance side that an issuer service
uses. A holder obtains a credential blind (the issuer never sees it in the
clear), keeps its witnesses current, and answers a verifier's challenge with
a zero-knowledge presentation that proves predicates such as "over 18",
"grade at least A3" or "still active", and nothing else. The holder can also
revoke its own credential without revealing which one it is (holder
self-revocation, the holder's kill switch).

## Where it fits

MintID is a network for verifiable, human-backed identity. Accepted issuers
verify people and issue the credentials; the chain publishes their status
roots, their bonds and the registries; each verifier decides on its own
service. MintID itself issues nothing, certifies nothing and verifies nobody.

The holder library is headless: it runs in the holder's own
infrastructure, next to the keys the holder already custodies. The Python agent
client (`mintid-agent`) builds on it. Verification is not in this package:
it is in the verifier SDK (`mintid-verifier-sdk`), on the relying party's own
service.

## Install

```bash
pip install mintid-proof-core   # Python 3.12 or later
```

The Rust core is compiled in; where no wheel matches your platform, pip
builds it from the source distribution, which needs a Rust toolchain.
Version 0.9.0, published from the main repository,
https://gitlab.com/mintid/mintid (`identity-proof-core/python`); its Rust
core is `proof-core 0.7.0` (`CORE_PIN`).

**New in 0.9.0 (breaking).** Presentation format version 4, in every
presentation kind (identity, agent, mint, relay): a presentation has exactly
one encoding. The holder emits it; verification refuses every other encoding
before it uses any value, and accepts format version 4 only, so presentations
of the earlier format are refused. Holders and verifiers update together. The
dispute presentation digest is returned by verification
(`verify_presentation`'s `dispute`, `dispute_verify_claim`), which computes
it over the bytes it accepted; `dispute_presentation_digest` is removed.

Also in 0.9.0 (breaking for the self-revocation receipt): the holder keeps
what rebuilds the ciphertext of each self-revocation message it builds, in
its custody bytes (version 5 while it keeps one), and the receipt of
`submit_self_revocation` is `pending` / `folded` (`.confirmed`) only when the
record of its code carries one of its own ciphertexts
(`Holder.confirm_self_revocation`); a record whose ciphertext the read does
not carry is `unconfirmed`, and one carrying another is `mismatch` (the code
is recorded and this credential is not revoked by that record). On
`submitted` check again, or send it again through another relay (the message
is idempotent). On `unconfirmed` read again from a node whose record of the
code carries its ciphertext, or ask the issuer to revoke the credential on
request; on `mismatch` sending it again is refused while that record is
kept, so ask the issuer to revoke the credential on request.
The chain reader gains `recorded` and `issuer_faults`. After the issuer's
acknowledgement, `Holder.watch_non_removal(chain_id, chain)` follows the
issuer's public status log with a proven read and reports `listed`, or
builds the non-removal evidence when the credential is still a member at a
later root (`self-revocation-v1.md` §4.4.1); `submit_non_removal_evidence`
hands it to a relay, and `check_non_removal_evidence` /
`proof_core.evidence_check` check a file off line. What rebuilds the
ciphertext is erased when the window or the fault on the record closes.

Also in 0.9.0: blind issuance derives the signature scalar from the
issuer's key and the whole blinded message, with no random input.
`Issuer.issue` and `Issuer.issue_agent` refuse a `status_ref` the key set has
already signed, active or revoked, with `StatusReferenceReuseRefused`, a
`ValueError` whose reason is `STATUS_REFERENCE_REUSE_REFUSED`; nothing is
signed and the registry is unchanged. They also refuse a request whose
opening proof does not carry exactly one response per blind claim. The
credential format is unchanged by this.

Also in 0.9.0: the dispute key document stays version 1, and the MintID
Foundation's key record is accepted on the signature of an active admission
key, checked against the caller's own chain view; this release carries no
custodian term and no custody entry (the custodian's co-signature, ADR-0051,
comes with a later regeneration of the chain). The
holder library checks its own prover's randomness before a presentation or
a self-revocation message leaves it, and refuses to release one that fails
(`prover_randomness_check_failed`). The issuer side gains the padded public
status delta log (`Issuer.status_batch`, `Issuer.revoke_step`,
`Issuer.cover_removal_at`, `StatusSchedule`) and holders apply it
(`apply_status_log`; `StatusLogRefused`). The registry's `production`
profile no longer lists `network_page` or `p2p`. A presentation lives 30 seconds, a constant of
format version 4 compiled into the Rust core: the time predicates are
evaluated at `expires_at` minus 30 seconds by every holder and verifier
alike, and a relay challenge that outlives the lifetime is refused. New
calls for the services: `status_log_listed_step` (whether a published batch
lists a removal, for the issuer's fault correction).

**Also new in 0.9.0.** `Holder.refresh_witness` brings the status witness to a current root from the issuer's public status log, with no request that names the credential: the holder library walks back from the profile's newest published object to the batch it last verified, checks the chain of values, the paths to the root, the removals and the end witness, and keeps that batch's value in custody (encoding version 4, written only once a holder is placed in the log). Pass `status_reader=` (verifier-core's `ChainClient`, or any object with `get_issuer_status` / `get_status_root_ring`) for the proven read of the issuer's status and ring. `Holder.tick()` and `start_status_sync()` run the sync on the schedule set by the issuer's heartbeat, the same for every holder (`proof_core.status_sync.FetchSchedule`): an agent with a `status_reader` fetches each root's object by its epoch eight seconds after the root is due plus a delay of up to five seconds drawn afresh, the root's due time taken from the newest root of its last proven read; an identity holder on start and then on the grid of its period in Unix time (`DEFAULT_IDENTITY_SYNC_SECONDS`, 300 s by default; an identity presentation whose proof verifies against the current accumulator is decided on the issuer's current root, whatever root it names, so the period bounds how long an identity holder whose credential is valid stays refused after another identity credential leaves the accumulator: until its next sync, and how often each identity holder fetches the log and reads the chain: once a period; `sync_period=` sets another); `sync_status()` is one step. The proven read happens on one agent root in four (the same roots for every holder) and at each identity sync; `ScheduledVerifierKeys` (`Holder.schedule_verifier_keys`, set up for the holder's own key source when it has a `status_reader`) keeps the verifier records it deals with and the admission key set and reads them right after that read, never when it answers a challenge; a first contact with another verifier reads at once, or with `first_contact="defer"` waits for the next read. `Holder.watch_on_schedule(...)` runs the non-removal watch's rounds right after the scheduled reads. After `status_root_stale`, `Holder.retry_instant()` is when to present again (the end of the next fetch band). A refused log raises `StatusSyncRefused` (`reason`, `epoch`: the root that failed) and changes nothing; a listing raises `CredentialListed` (a `CredentialRevoked`) and the holder stops presenting. The issuer's witness endpoint is used only for an issuer whose metadata names no log (`witness_fallback="unpublished"`, the default; `"enabled"`, `"never"`).

**New in 0.8.1.** Verification of mint and relay presentations checks the
signature proof's disclosed values against the claims shown beside them and
refuses a mismatch with `DisclosedSetRefused`, a `ValueError`; the reason is
`DISCLOSED_SET_REFUSED`. Proofs and wire formats are unchanged.

**New in 0.8.0.** `Holder.issue` speaks OpenID for Verifiable Credential Issuance 1.0, the Final text: after the token step it fetches a fresh `c_nonce` from the issuer's nonce endpoint and builds its blind request under it; the credential request names the configuration and carries `proofs` without `format`; the credential is read from `credentials`. An issuer whose metadata names no nonce endpoint predates the Final text and is refused at the metadata step (`HolderError`, step `metadata`); a refused nonce request is step `nonce`. `proof_core.holder.credential_request` and `issued_credential` build and read that wire. Issuers of the release that brings it serve both wires for one release. Proofs, checks and the engine pin are unchanged.

**New in 0.7.0.** The holder answers an issuer's mint challenge only for its own issuer, at the origin that issuer named at issuance: `Holder.present_for_mint` refuses, before anything is built, a challenge whose `verifier_id` is not the credential's issuer id or whose `audience` is not that origin, or not the `expected_origin` you pass (the origin you will send the answer to): `MintChallengeRefused` (`mint_challenge_foreign_issuer`, `mint_challenge_origin_mismatch`), a `ValueError` whose message carries no URL or id. The rule is the Rust holder library's, so every binding refuses alike; `proof_core.holder.origin_key` / `same_origin` are the exact comparison (scheme, host, port with the default filled in, never a prefix). A party relaying a mint challenge from another origin gets no presentation, and one that rewrites it gets one the issuer refuses. Proofs, checks and the engine pin are unchanged.

**New in 0.6.0 (breaking).** Every agent presentation now carries a dispute ciphertext: an encryption of the agent's credential reference under a key held jointly by its issuer and the MintID Foundation, with a proof that it belongs to the presented credential. Neither key holder can open it alone; together they open it only for a dispute claim recorded on chain, so that due process can reach an agent that does not cooperate. An agent holder passes the issuer's dispute key document and its own chain view of the Foundation's admission keys (`Holder.present(dispute_key=, admission_keys=)`; `Holder.refresh_witness` keeps the document the issuer serves with the witness, and a key source that reads the chain supplies the view). Agent presentations are wire version 3: holders and verifiers must update together. Identity presentations are unchanged. The issuer, Foundation and claim functions of the dispute rail are exposed for the services (`issuer_dispute_*`, `foundation_dispute_*`, `dispute_*`).

**New in 0.5.5.** A privacy fix in the holder's prover: the commitments behind the range predicates (grade, expiry, age, key custody, transaction limit) are now made with fresh randomness, so a presentation hides those claim values from the verifier that receives it as the specification requires. Verifiers are unchanged and presentations from earlier versions still verify. Every holder must update.

**New in 0.5.4.** No change in behaviour: the network registry's `production` profile gains the `network_page` and `p2p` roles (the single-node production chain is being given a sentry beside its validator, for the nodes of admitted integrators), as the testnet's. Proofs, checks and the Rust core are unchanged.

**New in 0.5.3.** Faster, with the same proofs: the range-proof prover of the engine computes its inner-product folds and its Pedersen commitments by plain scalar multiplication (the Bulletproofs library is vendored with that change, documented, every proof byte-identical to before), and the range-proof generators are built once per process. A presentation is proven in about a third of the time and checked in about 60 %; no verification result changes.

**New in 0.5.2.** No change in behaviour: the source distribution now carries the credential library the engine is built on (`credx` 0.2.1, vendored with its numeric claims typed `i64`, byte-identical on 64-bit platforms), so a build from source and the browser check compile the same code.

**New in 0.5.1.** Network profiles (`proof_core.networks`): the package
carries the MintID network registry, `network("testnet")` (or
`MINTID_NETWORK=testnet`) names the endpoints of a deployment, and
`submit_self_revocation(None, revocation, network="testnet")` takes the
relay and the node from it. `MINTID_TESTNET_*` and the per-service overrides
win; an unknown profile fails naming the valid ones.
`python -m proof_core.networks testnet --shell` prints the shell variables
the documentation's commands read. Additive: without a profile nothing
changes.

**New in 0.5.** The agent profile v2 (`AGENT_V2_PROFILE`, MINT-479): an
agent credential that also carries its principal's age floor, so the agent
proves `age_over` N without any date of birth. `Holder.present_for_mint`
takes an optional `age_over` (read from the issuer's mint challenge when
not given) and the mint outcome reports it; the issuance side gets the v2
key set (`profile=AGENT_V2_PROFILE`). Agent v1 and identity are unchanged.

**Upgrading from 0.3.** `Holder.present` now checks the verifier's
challenge signature before it builds anything (SPEC-1 §10.5): it needs the
verifier's `{request, signature_hex}` unmodified and a source of verifiers'
request keys, given as `verifiers=` to `Holder.issue`, `Holder.from_storage`
or `present` itself (`ProvenVerifierKeys` over a proven chain read, or
`StaticVerifierKeys` of records you pinned). A bare or unsigned request, a
holder without a source, an unknown or retired key and a bad signature are
refused with `ChallengeRefused` (its `reason` names which). Only against a
devnet verifier started with `--insecure-unsigned-challenges`,
`present(..., insecure_skip_challenge_signature=True)` skips the check, and
warns every time.

## Example

```python
import proof_core
from proof_core.holder import Holder, StaticVerifierKeys

print(proof_core.core_version())       # the Rust core compiled into this package

# Where the holder reads verifiers' request keys: a proven chain read
# (ProvenVerifierKeys) or the records you pinned (StaticVerifierKeys).
holder = Holder.issue(offer, verifiers=StaticVerifierKeys(pinned_records))
holder.refresh_witness()               # right before presenting; material that does not verify is refused
envelope = holder.present(challenge)   # the verifier's {request, signature_hex}: the signature is
                                       # checked first (ChallengeRefused otherwise), then one bound,
                                       # 30-second presentation, or nothing is sent
custody = holder.storage_bytes()       # holds the link secret: encrypt it under your own key
```

There is no export: the custody encoding is the only serialisation, and a
lost key is recoverable by nobody (you verify again and get a fresh
credential, unlinkable to the old one).

## Status

Built and in production on the single-node production chain. An independent
audit of the implementation is scheduled as a milestone; its findings will be
published, and it gates nothing.

## Where to test

On the public testnet and its KYC sandbox, and only there: check the status
line of [its page](https://gitlab.com/mintid/mintid/-/blob/main/docs/sdk/17-sandbox-and-testnet.md)
first. Nothing issued on it carries weight. The single-node production chain
is not for third parties and is never a place to test.

## Links

- Documentation: https://gitlab.com/mintid/mintid/-/blob/main/docs/sdk/08-credentials-and-holders.md
- Source: https://gitlab.com/mintid/mintid (`identity-proof-core`), where
  issues and merge requests go
- Public testnet: https://gitlab.com/mintid/mintid/-/blob/main/docs/sdk/17-sandbox-and-testnet.md
- Security: report a vulnerability privately to security@mintid.net, never in
  a public issue; policy: https://gitlab.com/mintid/mintid/-/blob/main/SECURITY.md
- Website: https://mintid.net

## Licence

Apache License 2.0. Author: Marc Molas.

