Skip to main content

Get Verification Key

The verificationKey method allows you to retrieve important verification keys associated with specific contracts in the database. These keys include details like the Merkle tree height, key hashes, and raw encoded data. They are essential for verifying zero-knowledge proofs and understanding the cryptographic configuration of the system.

Definition

await zkdb
.db(databaseName: string)
.verificationKey(): Promise<TVerificationKeyResponse | null>;

Parameters

  • None

Returns

  • Promise<TVerificationKeyResponse | null>: Returns verification keys for all deployed smart contracts associated with the database, or null if no contracts are deployed. These keys contain cryptographic parameters essential for zero-knowledge proof verification and contract interaction.
type TVerificationKeyResponse = Record<
EContractName,
TZkDbVerificationKeyRecord
> | null;

type TZkDbVerificationKeyRecord = {
contractName: EContractName;
merkleHeight: number;
verificationKeyHash: string;
data: string;
hash: string;
createdAt: string;
updatedAt: string;
};

enum EContractName {
Rollup = 'Rollup', // Represents the verification key for rollup contracts.
Contract = 'Contract', // Represents the verification key for zkdb smart contracts.
}

Example

import { ZkDatabase } from 'zkdb';

const zkdb = await ZkDatabase.connect({
userName: "chiro-user",
privateKey: "EKFTciRxyxshZjimay9sktsn7v5PvmC5zPq7q4JnitHUytxUVnFP",
environment: "node",
// This URL is for test environment
url: "https://api.zkdatabase.org/graphql",
});

await zkdb.auth.signIn();

const dbTest = zkdb.db('zkdb_test');
const verificationKeys = await dbTest.verificationKey();
console.log('Verification keys:', verificationKeys);

await zkdb.auth.signOut();

Result:

The response contains verification keys for each deployed contract type:

{
"Contract": {
"contractName": "Contract",
"merkleHeight": 8,
"verificationKeyHash": "7d892b456151a3c95e27de7ef8fb3dfdfe2294b4d72d5c89e8e373005aa6358a",
"data": "AQFihNY9Eur2I...",
"hash": "11039021637501775772008318574453933091253743015110713939551628556211349714893",
"createdAt": "2025-01-21T17:16:38.294Z",
"updatedAt": "2025-01-21T17:16:38.294Z"
},
"Rollup": {
"contractName": "Rollup",
"merkleHeight": 8,
"verificationKeyHash": "53d15949c41469c0bc0942b87a7678a05517c03731c4a9a993a96f9bea87ceb3",
"data": "AQHwbVNVDjAVn...",
"hash": "9102873522666665449936385888808683444277565713030518648166535561287070859687",
"createdAt": "2025-01-21T17:16:38.294Z",
"updatedAt": "2025-01-21T17:16:38.294Z"
}
}