2.6 KiB
2.6 KiB
ZKAC Python API Reference
Version 0.1. Cryptographic stack: BBS+ on BLS12-381 (credentials), X25519 + ChaCha20-Poly1305 (transport), BLAKE2b (role IDs).
import zkac
Constants
MAX_BBS_AUTH_PROOF_BYTES
Upper bound on BBS+ proof size in an encrypted auth packet (256 KiB). Larger proofs are rejected.
Transport identity (Ristretto255)
Keypair()
Generates a new random keypair.
Keypair.public_key() -> PublicKey
Raises ValueError if consumed by Node(...).
PublicKey
to_bytes() -> bytes— 32 bytesfrom_bytes(bytes) -> PublicKey- Equality, hash,
reprsupported
BBS+ credentials
role_id(name: str) -> bytes
32-byte opaque role id from a human-readable name.
BbsIssuer()
New random issuer. from_secret_key(bytes) restores from 32-byte secret.
public_key() -> BbsPublicKeysecret_key_bytes() -> bytes(confidential)issue_blind(commitment_with_proof, role_id, epoch) -> bytes—role_idmust be 32 bytes
BbsPublicKey
to_bytes() / from_bytes
prepare_blind_request() -> BlindRequest
commitment_with_proof(),member_secret(),prover_blind()— all returnbytes
Credential.finalize(blind_sig, member_secret, prover_blind, role_id, epoch, pk) -> Credential
present(nonce) -> bytesrole_id() -> bytes,epoch() -> int
Server registry
RoleRegistry
register_role(role_id, pk, epoch)—role_id32 bytesset_epoch(role_id, epoch)verify_presentation(role_id, proof_bytes, nonce) -> boolhas_role(role_id) -> bool
Node and session
Node(keypair) — consumes Keypair
public_key() -> PublicKeyconnect() -> (PendingConnect, bytes)— 32-byte init messageaccept(init_msg) -> (Session, bytes)—init_msg32 bytescomplete_connect(pending, response_msg, credential) -> (Session, bytes)—response_msg32 bytesverify_auth(session, encrypted_auth, registry) -> bytes— returns 32-byterole_id
Session
transcript_hash() -> bytes— use asnonceforCredential.presentencrypt(plaintext) -> bytesdecrypt(packet) -> bytes
Typical flow
- Issuer creates
BbsIssuer(); serverregister_role(role_id, issuer.public_key(), epoch). - Member:
prepare_blind_request→ issuerissue_blind→Credential.finalize. - Client:
connect→ serveraccept→ clientcomplete_connect→ serververify_auth. - Use
Session.encrypt/decryptfor data.
Errors
Raises ValueError with descriptive messages for crypto failures, replay, and bad inputs.