Skip to main content

Get zkProof

The zkProof method is designed to retrieve a JSON-formatted zero-knowledge proof. This proof can be utilized to verify computations or data integrity without revealing sensitive information. zkDatabase uses Groth16 zkSNARKs for efficient proof generation and verification.

Method Signature

const zkProof = (await zkdb.db(databaseName).zkProof()).unwrap();

Syntax

import { ZkDatabase } from 'zkdb';

const zkdb = new ZkDatabase({
apiKey: 'zkdb_536aac02a1b7.c001b6b8f...da3aa4185d8d2ad07f0ae94aT',
// This URL is for test environment
url: "https://serverless.zkdatabase.org/graphql",
});
const dbTest = zkdb.db('zkdb_test');

// Get zkProof
const zkProof = (await dbTest.zkProof()).unwrap();
console.log('ZK Proof:', zkProof);

Returns

  • A promise that resolves to a TZkProofResponse.

The TZkProofResponse contains the following structure:

TZkProofResponse
PropertyTypeDescription
sequenceNumberbigintThe sequence number associated with the proof generation.
proofTSerializedZkProof | nullA serialized zero-knowledge proof object, or null if not available.
TSerializedZkProof
FieldTypeDescription
proofobjectThe proof object containing the zero-knowledge proof.
publicSignalsstring[]An array of public signals used in the proof.
Null Case

If no proof is available, the returned promise resolves to null. Ensure to handle this scenario appropriately in your implementation.

{
sequenceNumber: 10n,
proof: {
proof: { /* Groth16 proof object */ },
publicSignals: [
'25841764576285046988186167653748636396178872522546148714971399248557895316929',
'3947663588673285028481390057420318710802249460490724323846855806133396101815'
]
}
}