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.2.tar.gz (10.8 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.2-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: provable_sdk-0.0.2.tar.gz
  • Upload date:
  • Size: 10.8 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.2.tar.gz
Algorithm Hash digest
SHA256 85645160b3ae1d7a37c622c7e58cdbb83f0662173f09c725b9cd14a062bd2ae0
MD5 3ef3e9c6f1302baab7b2d20d630a7ab4
BLAKE2b-256 23d483e91e990d2da49d960d8ba5bb54bd021afc3b9d9d7ed55b79f1c7288ed1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: provable_sdk-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 21ab56287f3786f786e03986eef1a1a51528d762f671b8035b57619ea33742d5
MD5 538af18d9da2165d05dc8ab33b136cb5
BLAKE2b-256 23fe6bdfbecedf9025b8aea80a636ddba6fec035927d16dcfe77fad99d1251fa

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