pysui-crypto
A Python extension providing zkLogin and SEAL threshold encryption support for Sui, extending the pysui SDK.
The library is backed by a Rust crate compiled via PyO3 and maturin, exposing a native Python extension module.
Requirements
Python 3.10 or later
pysui — integrated in the upcoming pysui 1.1.0 release (date TBD)
Installation
From PyPI (sdist)
Only a source distribution is published to PyPI. Installing it requires a Rust toolchain and maturin:
pip install maturin
pip install pysui-crypto
Pre-built wheels
Platform wheels for Linux (x86_64, aarch64), Windows (x64), and macOS (x86_64, aarch64) are attached to each GitHub release as zip archives. Download the archive for your platform and install the wheel directly:
pip install pysui_crypto-<version>-<platform>.whl
Build from source
maturin is required to compile the Rust extension:
pip install maturin
maturin develop # installs into the active virtual environment
To produce a wheel:
maturin build --release --out dist
zkLogin Support
Functions for constructing and submitting zkLogin authenticated transactions on Sui.
- generate_ephemeral_keypair(as_secp256r1)
Generate an Ed25519 (default) or secp256r1 ephemeral key pair for nonce construction. Returns {"public_key": bytes, "private_key": bytes}.
- extract_jwt_claims(jwt)
Parse a zkLogin JWT and enforce Sui size constraints. Returns (iss, sub, aud, nonce).
- compute_nonce(epk_bytes, max_epoch, randomness)
Compute the Poseidon-hashed nonce to embed in the OAuth authorization request.
- compute_address_seed(key_claim_name, key_claim_value, audience, user_salt)
Compute the 32-byte BN254/Poseidon address seed from JWT claims and a user salt.
- compute_zklogin_address(iss, address_seed, legacy)
Derive the final Blake2b256 Sui address from the issuer string and address seed.
- build_zklogin_signature(proof_json, ephemeral_sig, address_seed, max_epoch)
Assemble and BCS-serialize a ZkLoginAuthenticator; returns standard base64 ready for the Sui RPC.
SEAL Support
Functions for SEAL threshold encryption. SEAL requires access to one or more running SEAL key servers; this library provides the client-side cryptographic primitives only.
- DemType
Enum of supported data-encapsulation mechanisms: AesGcm256, Hmac256Ctr, Plain.
- EncryptedObject
Parse and inspect a SEAL encrypted object (parse(data) / to_bytes()). Exposes version, package_id, id, threshold, services, dem_type.
- seal_encrypt(package_id, id, key_servers, public_keys, threshold, data, dem_type, aad)
Threshold-encrypt plaintext using IBE. Returns (ciphertext, dem_key) where dem_key is non-None only for Plain mode.
- seal_decrypt(encrypted_object, user_secret_keys, public_keys)
Decrypt a SEAL ciphertext using user secret keys collected from key servers.
- generate_session_keypair()
Generate an Ed25519 session key pair for SEAL key server authentication. Returns {"public_key": bytes, "private_key": bytes}.
- generate_elgamal_keypair()
Generate an ElGamal key pair for SEAL key server encryption. Returns {"public_key": bytes, "private_key": bytes}.
- elgamal_decrypt(sk, encryption)
Decrypt an ElGamal ciphertext using a private key.
- verify_user_secret_key(usk, full_id, public_key)
Verify a user secret key returned by a key server; raises ValueError on failure.
- seal_signed_message(package_id, session_vk, creation_time, ttl_min)
Construct the key server request message for signing; returns hex-encoded bytes.
License
Apache-2.0
Metadata
Release files for pysui-crypto 0.1.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 |
|---|---|---|---|---|
| pysui_crypto-0.1.0.tar.gz | 82.8 kB | Without provenance | Details for pysui_crypto-0.1.0.tar.gz |
Release files / pysui_crypto-0.1.0.tar.gz
| Download URL | pysui_crypto-0.1.0.tar.gz |
|---|---|
| Size | 82.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39b22f3b5bd1df1da71e41a7ced507bb86d44577aeee32c3d7cb0c1cb1338461
|
|
BLAKE2b-256 checksum How to use checksums |
da3319f25eedf94d3e934bfcd8f2dcc07673b542f01659c84c7f71e1df461d70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.6
|
Security for pysui-crypto 0.1.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.