SYNNQ TQI SDK

The SYNNQ TQI SDK is a TypeScript library designed to facilitate interaction with SYNNQ's TQI services. It provides comprehensive support for managing Zero-Knowledge Proofs (ZKP) and Nodes within the SYNNQ network.

Table of Contents

Features

  • Zero-Knowledge Proofs (ZKP): Generate and verify ZKPs using cryptographic methods.
  • Node Management: Register, manage, and interact with nodes in the SYNNQ network.
  • Flexible API: Provides an easy-to-use interface for managing both ZKP and Node operations.

Installation

To install the SYNNQ TQI SDK, run:

npm install synnq_tqi_sdk

Getting Started

Initialization

To start using the SDK, you need to create an APIManager instance. This will allow you to manage both ZKP and Node operations.

import { createAPIManager } from 'synnq_tqi_sdk';
 
// Initialize the APIManager with the Node base URL
const apiManager = createAPIManager('http://node-api.synnq.io');

The createAPIManager function initializes the SDK:

  • ZKP operations will always use the fixed URL https://zkp.synnq.io.
  • Node operations will use the base URL provided when initializing the APIManager.

ZKP Operations

Once you have initialized the APIManager, you can perform ZKP operations such as generating and verifying proofs.

Generate a ZKP

const zkpManager = apiManager.getZKPManager();
const proofResponse = await zkpManager.generateProof('my-secret');
 
console.log('Generated Proof:', proofResponse);

Verify a ZKP

const isValid = await zkpManager.verifyProof(
  proofResponse.proof,
  'my-secret',
  proofResponse.blinding
);
 
console.log('Proof is valid:', isValid);

Node Operations

You can also manage nodes by using the NodeManager from the APIManager.

Register a Node

const nodeManager = apiManager.getNodeManager();
await nodeManager.registerNode(
  'node-id',
  'http://node-address.com',
  'public-key'
);
 
console.log('Node registered successfully');

Get Nodes

const nodes = await nodeManager.getNodes();
console.log('Nodes:', nodes);

Send Data

await nodeManager.sendData({ key: 'value' });
console.log('Data sent successfully');

Receive Broadcast

await nodeManager.receiveBroadcast({ transaction: 'data' });
console.log('Broadcast received successfully');

API Reference

ZKPManager

Handles Zero-Knowledge Proof (ZKP) operations.

  • generateProof(secret: string): Promise<ProofResponse>
    Generates a Zero-Knowledge Proof for the given secret.

  • verifyProof(proof: string, secret: string, blinding: string): Promise<boolean>
    Verifies the provided ZKP using the stored blinding factor.

NodeManager

Handles Node management operations.

  • registerNode(id: string, address: string, publicKey: string): Promise<void>
    Registers a new node in the SYNNQ network.

  • getNodes(): Promise<any[]>
    Retrieves the list of nodes from the SYNNQ network.

  • sendData(data: any): Promise<void>
    Sends data to the SYNNQ network.

  • receiveBroadcast(data: any): Promise<void>
    Receives broadcasted data from the SYNNQ network.

APIManager

Manages both ZKP and Node operations by coordinating ZKPManager and NodeManager.

  • getZKPManager(): ZKPManager
    Returns an instance of the ZKPManager to handle ZKP-related operations.

  • getNodeManager(): NodeManager
    Returns an instance of the NodeManager to handle Node-related operations.

Development

Prerequisites

Building the Project

  1. Clone the repository:

    git clone https://github.com/synnq/synnq_tqi_sdk.git
    cd synnq_tqi_sdk
  2. Install dependencies:

    npm install
  3. Compile the TypeScript code:

    npm run build

Running Tests

Currently, the project does not include any tests. You can add your own tests using your preferred testing framework (e.g., Jest).

Publishing the Package

  1. Ensure your code is compiled and all files are in the dist folder.
  2. Publish to NPM:
    npm publish --access public

License

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

Explanation:

  1. Features: Describes what the SDK offers.
  2. Installation: Provides the command to install the SDK via NPM.
  3. Getting Started: Explains how to initialize and use the SDK for both ZKP and Node operations.
  4. API Reference: Details the methods available in ZKPManager, NodeManager, and APIManager.
  5. Development: Offers guidance on how to set up the project, build it, and publish the SDK.
  6. License: Includes the license under which the SDK is released.

This README.md should provide comprehensive documentation for users of the SDK, guiding them from installation to advanced usage and contributing. Let me know if you need any further adjustments!