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.3.tar.gz (10.9 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.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: provable_sdk-0.0.3.tar.gz
  • Upload date:
  • Size: 10.9 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.3.tar.gz
Algorithm Hash digest
SHA256 17350a36695f6b38ba07daebcbc822b1c55e45c675a1e9b852cf568ec78d698f
MD5 43fc57ebdfcbfae4e0cfd8194b7b5b1c
BLAKE2b-256 ed9f853647b13c6f52073e41f764521da8f295bbe23124d769f22798774c1566

See more details on using hashes here.

File details

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

File metadata

  • Download URL: provable_sdk-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 734d316ab90a140e43db6cd2164d591d2eb3bd960e5156e7957bc66f8e802807
MD5 1591ee1e7c2e0e57c2d5473447b43a61
BLAKE2b-256 b665f628764b421d9b4b5627abe8e29ab9ac91c4e5f16c8466c43b92c1ce3d7c

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