Skip to content

pkjha527/zktls-py-sdk

Repository files navigation

ZK TLS Python SDK

A Python SDK for integrating Zero-Knowledge TLS attestation into your applications.

Overview

The ZK TLS Python SDK provides a seamless interface to the ZK TLS protocol, enabling secure and private attestation of network interactions. It wraps the Node.js ZK TLS Core SDK and provides a Pythonic interface for easy integration.

Features

  • 🔒 Secure TLS attestation
  • 🔍 Response verification
  • 📝 Custom templates support
  • 🛠️ Configurable attestation conditions
  • 🔄 Automatic SSL cipher configuration
  • 🐍 Native Python async/await support

Installation

pip install zktls-py-sdk

Prerequisites

The SDK depends on the following:

  • Node.js 14+
  • npm 6+
  • @primuslabs/zktls-core-sdk package version ^0.1.1

The SDK will automatically check for these dependencies during initialization.

Quick Start

import asyncio
from zktls import NodeWrapper

async def main():
    # Initialize SDK
    wrapper = NodeWrapper()
    await wrapper.init("your-app-id", "your-app-secret")
    
    # Define request
    request = {
        "url": "https://api.example.com/data",
        "header": {"Accept": "application/json"},
        "method": "GET",
        "body": ""
    }
    
    # Define response resolves
    response_resolves = [
        {
            "keyName": "field1",
            "parseType": "string",
            "parsePath": "$.field1"
        }
    ]
    
    # Start attestation
    attestation = await wrapper.start_attestation(
        request=request,
        response_resolves=response_resolves
    )
    
    # Verify attestation
    is_verified = await wrapper.verify_attestation(attestation)
    print(f"Attestation verified: {is_verified}")

if __name__ == "__main__":
    asyncio.run(main())

Documentation

Key Concepts

Attestation Flow

  1. Initialization: Create a NodeWrapper instance and initialize with credentials
  2. Request Definition: Define the HTTP request and response parsing rules
  3. Attestation: Start the attestation process with optional custom parameters
  4. Verification: Verify the attestation response

Response Resolves

Response resolves define how to parse and extract data from the response:

response_resolves = [
    {
        "keyName": "field1",    # Name for the extracted field
        "parseType": "string",  # Expected type
        "parsePath": "$.field1" # JSONPath to the field
    }
]

Templates

Templates allow customization of attestation behavior:

attestation = await wrapper.start_attestation(
    request=request,
    response_resolves=response_resolves,
    template_id="my-custom-template"
)

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Security

For security issues, please email security@primuslabs.xyz instead of using the issue tracker.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages