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.0.tar.gz (17.4 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.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: provable_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 17.4 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.0.tar.gz
Algorithm Hash digest
SHA256 638d2c530798f663df7b113ff73c15a57fb6333fe47c307491034aeb840253af
MD5 ccfb79dc9c69d4554cf5959e2e3288b7
BLAKE2b-256 fa5aad10b506dc7661a462a9d451003076edeaf50a1f158044c4daee593a15c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: provable_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afee6e8597b549216a3aa55688f7880b0e4be1a492cc0b14866b2c46f345f426
MD5 d367b1a089d22272b487b7b1430e580e
BLAKE2b-256 ead4727300798c83b01787ae60ba2ffe5b58317a1ae28cb0f1c5bbf921101668

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