Skip to main content

Provable SDK for Python

Project description

Provable SDK for Python

provable-sdk-py is the Kayros API and verification SDK for Python.

Installation

pip install provable-sdk

Usage

1. Default usage

Use the built-in key and the default provable_sdk data type.

from provable_sdk import prove_single_hash, get_record_by_hash, verify, verify_with_inclusion

data_item = "ab" * 32
proof = prove_single_hash(data_item)
kayros_hash = proof["hash"]

record = get_record_by_hash(kayros_hash)

verified = verify({
    "data_type": "provable_sdk",
    "data_item": data_item,
    "kayros_hash": kayros_hash,
})

inclusion = verify_with_inclusion({
    "data_type": "provable_sdk",
    "kayros_hash": kayros_hash,
})

2. Usage with API key and custom data type

import os

from provable_sdk import prove_single_hash, verify, verify_with_inclusion, set_api_key

settings = {
    "api_key": os.environ["KAYROS_API_KEY"],
    "data_type": "kayros_indexer_v1",
}

set_api_key(settings["api_key"])

proof = prove_single_hash(
    "ab" * 32,
    data_type=settings["data_type"],
    api_key=settings["api_key"],
)
kayros_hash = proof["hash"]

verified = verify({
    "data_type": settings["data_type"],
    "data_item": "ab" * 32,
    "kayros_hash": kayros_hash,
    "api_key": settings["api_key"],
})

inclusion = verify_with_inclusion({
    "data_type": settings["data_type"],
    "kayros_hash": kayros_hash,
    "api_key": settings["api_key"],
    "verify_batch_existence": True,
})

Main API

  • prove_single_hash(data_hash, data_type=None, api_key=None)
  • get_record_by_hash(kayros_hash, data_type=None, api_key=None)
  • get_record_by_data_item(data_type, data_item, api_key=None)
  • get_merkle_proof(data_type, hash=..., position=..., api_key=None)
  • verify_hash_existence({"data_type": ..., "level": ..., "position": ..., "hash": ...}, api_key=None)
  • verify_hash_batch({"data_type": ..., "level": ..., "start": ..., "hashes": [...]}, api_key=None)
  • verify({"data_type": ..., "data_item"?: ..., "kayros_hash"?: ..., "api_key"?: ...})
  • verify_with_inclusion({"data_type": ..., "data_item"?: ..., "kayros_hash"?: ..., "api_key"?: ..., "trusted_root_hash"?: ..., "trusted_level"?: ..., "trusted_position"?: ..., "levels_hash_type"?: ..., "verify_batch_existence"?: ..., "level_checks"?: [...]})

data_type is required for verification. Provide at least one of data_item or kayros_hash.

levels_hash_type controls the Merkle rollup hash used for local inclusion replay. It defaults to sha3-256 and also accepts sha256.

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.1.1.tar.gz (19.5 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.1.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: provable_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 19.5 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.1.1.tar.gz
Algorithm Hash digest
SHA256 f4bce509f83aea8d6a85943b73ae9dc4dc4f8e52f2cf9ea78ac050961a4fa04b
MD5 0fb76d89317c73429ce744374b4d5543
BLAKE2b-256 1b689adeac5f8664e9f9d3806e3fdad49dd5476460b5d9f9975aadac09e6adfb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: provable_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.8 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2efe8df9e4d16f3fd1044d84b485ae92132831651dfbaae2a76265770f9409e7
MD5 281843d18e79affb829a77a1de52a928
BLAKE2b-256 11709fe76fa57fa81465886e25e8d7850596366c1ff5028d0b99c691a46e89e9

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