Skip to content

Basic Usage

Here is how to integrate Tisura SDK - depending on the kind of certification. As reminder, Tisura supports certification with or without zero-knowledge proofs. Both approaches start with the user sending a request, then:

Send a request (user-side)

A user sends a request via our proxy. This enables us storing the encrypted request and response data for later verification.

import { Tisura } from 'tisura';
 
// Initialize the SDK
const client = new Tisura({
  apiKey: 'your-api-key'
});
 
// Send a request via our proxy
const response = await client.sendRequest({
  serverHost: "api.github.com",
  serverPort: 443,
  endpoint: "/users",
  params: [{ key: "since", value: "1" }],
  method: "POST",
  body: [{ key: "name", value: "sherlock" }],                    // Optional body
  headers: [{ key: "Authorization", value: `Bearer ${token}` }], // Optional headers
});

Prove and verify a response

Generate a proof (user-side)

A user can generate a proof to prove the authenticity of a response in three different scenarios:

// For substring circuit (prove the authenticity of any substring of the response)
const proof = await clientInstance.generateProof({
  circuitName: "substring",
  connectionId: "conn123",
  plaintext: "text to prove"
});
 
// For ownership circuit (prove GitHub repository ownership)
const proof = await clientInstance.generateProof({
  circuitName: "ownership",
  connectionId: "conn123",
  nodeId: "U_xxxxxxxxxx"
});
 
// For contributions circuit (prove GitHub contribution count)
const proof = await clientInstance.generateProof({
  circuitName: "contributions",
  connectionId: "conn123",
  repoName: "my-repo",
  repoOwner: "github-user",
  count: 25
});

Verify a proof (verifier-side)

A verifier can verify a proof to ensure its authenticity.

const isVerified = await client.verifyProof({
  circuitName: "substring", // or "ownership" or "contributions"
  proof,                    // the proof generated above
});

Certify a response (verifier-side)

A verifier - say a bank - can certify a response to ensure its authenticity.

const isCertified = await client.certify({
  dataToCertify,  // data you want to compare against the response
  connectionId,   // by default, we'll use the last connection
  inputSessionKey // by default, we'll use the last session keys
});