Provable SDK for Python
Project description
Provable SDK for Python
A Python SDK for interacting with the Provable Kayros API.
Installation
pip install provable-sdk
Usage
from provable_sdk import (
keccak256,
keccak256_str,
sha256,
sha256_str,
prove_single_hash,
get_record_by_hash,
prove_data,
prove_data_str,
verify,
KayrosEnvelope,
)
# Hash bytes (keccak256)
data = b'\x01\x02\x03\x04'
data_hash = keccak256(data)
# Hash string (sha256 - default)
text = "Hello, Provable!"
str_hash = sha256_str(text)
# Prove a hash
proof = prove_single_hash(data_hash)
# Get a record by hash
record = get_record_by_hash(proof["data"]["computed_hash_hex"])
# Prove data directly
data_proof = prove_data(data)
# Prove string data directly
str_proof = prove_data_str(text)
# Create and verify a KayrosEnvelope
envelope = KayrosEnvelope(
data={"message": "Hello, Provable!"},
kayros={
"hash": str_hash,
"hashAlgorithm": "sha256",
"timestamp": {
"service": "kayros",
"response": proof,
},
},
)
result = verify(envelope)
if result["valid"]:
print("Verification successful!")
else:
print(f"Verification failed: {result['error']}")
API
Hash Functions
keccak256(data: bytes) -> str- Compute keccak256 hash of byteskeccak256_str(s: str) -> str- Compute keccak256 hash of a UTF-8 stringsha256(data: bytes) -> str- Compute SHA-256 hash of bytessha256_str(s: str) -> str- Compute SHA-256 hash of a UTF-8 stringhash/hash_str- Aliases for keccak256 functions
Prove Functions
prove_single_hash(data_hash: str) -> ProveSingleHashResponse- Prove a hash via Kayros APIprove_data(data: bytes) -> ProveSingleHashResponse- Hash and prove bytesprove_data_str(s: str) -> ProveSingleHashResponse- Hash and prove a string
Record Functions
get_record_by_hash(record_hash: str) -> GetRecordResponse- Get Kayros record by hash
Verify Function
verify(envelope: KayrosEnvelope) -> VerifyResult- Verify data against Kayros proof
KayrosEnvelope
The KayrosEnvelope class wraps data with Kayros proof metadata:
envelope = KayrosEnvelope(data=my_data, kayros=kayros_metadata)
# Helper methods
envelope.get_data() # Get data as bytes (decodes base64 for V0)
envelope.get_data_hash() # Get the data hash (data_item_hex)
envelope.get_data_type() # Get the data type (data_type_hex)
envelope.get_kayros_hash() # Get the Kayros hash (computed_hash_hex)
envelope.get_time_uuid() # Get the time UUID (timeuuid_hex)
envelope.get_hash_algorithm() # Get hash algorithm (defaults to 'sha256')
envelope.is_v0() # Check if V0 format (legacy, for email proofs)
Envelope Formats
- V1 (default): Hash stored in
kayros["hash"], data is plain string or object - V0 (legacy): Hash in
kayros["data"]["data_item_hex"], data is base64-encoded bytes (used for email proofs)
Configuration
Default configuration:
KAYROS_HOST:https://kayros.provable.dev- API Routes:
- Single Hash:
/api/grpc/single-hash - Get Record:
/api/database/record-by-hash
- Single Hash:
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
provable_sdk-0.0.4.tar.gz
(12.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file provable_sdk-0.0.4.tar.gz.
File metadata
- Download URL: provable_sdk-0.0.4.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61c828f20378a929b484c63d7ec81902a5060b30843538d8d2ba346053e85219
|
|
| MD5 |
0a08a7edf7c9dbb0ff11e624f7c65424
|
|
| BLAKE2b-256 |
9230a0a98ed53b491a07d18ee6244a17eeab2d41035dae628de5fb29f7533d0e
|
File details
Details for the file provable_sdk-0.0.4-py3-none-any.whl.
File metadata
- Download URL: provable_sdk-0.0.4-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bff2a58beab9cb8b183b815a7be2091566281158a3fd38a441308ab9014d7f54
|
|
| MD5 |
7c047ca6f42a38157d13335603001630
|
|
| BLAKE2b-256 |
049350f37933508782a2eba536ad04e4fd7efd7b3c97ab0b91994e77edbc9608
|