Skip to main content

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 (
    hash,
    keccak256,
    hash_str,
    keccak256_str,
    prove_single_hash,
    get_record_by_hash,
    prove_data,
    prove_data_str,
    verify,
)

# Hash bytes
data = b'\x01\x02\x03\x04'
data_hash = hash(data)  # or keccak256(data)

# Hash string
text = "Hello, Provable!"
str_hash = hash_str(text)  # or keccak256_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)

# Verify data with Kayros proof
envelope = {
    "data": {"message": "Hello, Provable!"},
    "kayros": {
        "hash": "abc123...",
        "hashAlgorithm": "keccak256",
        "timestamp": {
            "service": "https://kayros.provable.dev/api/grpc/single-hash",
            "response": proof,
        },
    },
}

result = verify(envelope)
if result["valid"]:
    print("Verification successful!")
else:
    print(f"Verification failed: {result['error']}")

API

Hash Functions

  • hash(data: bytes) -> str - Compute keccak256 hash of bytes
  • keccak256(data: bytes) -> str - Alias for hash
  • hash_str(s: str) -> str - Compute keccak256 hash of a UTF-8 string
  • keccak256_str(s: str) -> str - Alias for hash_str

Prove Functions

  • prove_single_hash(data_hash: str) -> ProveSingleHashResponse - Prove a hash via Kayros API
  • prove_data(data: bytes) -> ProveSingleHashResponse - Hash and prove bytes
  • prove_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

Configuration

Default configuration:

  • KAYROS_HOST: https://kayros.provable.dev
  • API Routes:
    • Single Hash: /api/grpc/single-hash
    • Get Record: /api/database/record-by-hash

License

MIT

Project details


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.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

provable_sdk-0.0.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file provable_sdk-0.0.1.tar.gz.

File metadata

  • Download URL: provable_sdk-0.0.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.4

File hashes

Hashes for provable_sdk-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d10e4f865fa0aca5ea37da9efd510574744f810eeb0ed532b94f57a38b7e10bf
MD5 33917bbbefd7fae434e95103e778d682
BLAKE2b-256 cec719daf88e3955673f5d925075bdd8b78fd01812b5bd88086a9cfd0ac8cf6f

See more details on using hashes here.

File details

Details for the file provable_sdk-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: provable_sdk-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.4

File hashes

Hashes for provable_sdk-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e4c4aa536d151971e676f83874775e95fef7cd265df586a8be8d989132da9ea
MD5 c2c9b48d103fc1c4c42204fd21d8e4af
BLAKE2b-256 a2dcc967c10bbc9506e28314b86ea1a5c1bbb9aee2246bf7d4a7b976bfc78d5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page