@provablehq/sdk
Version:
A Software Development Kit (SDK) for Zero-Knowledge Transactions
38 lines (37 loc) • 2.05 kB
TypeScript
import { KeyVerifier, KeyFingerprint, KeyMetadata } from "./interface.js";
/**
* In-memory implementation of KeyVerifier that stores and verifies key fingerprints.
* Provides functionality to compute and verify cryptographic checksums of keys, storing them
* in memory for subsequent verification. This implementation is primarily used for testing
* and development purposes where persistence is not required.
*
* Key features:
* - Computes SHA-256 checksums and sizes for key bytes.
* - Stores key fingerprints in memory using string locators.
* - Verifies key bytes against stored or provided fingerprints.
*
* @implements {KeyVerifier}
*/
export declare class MemKeyVerifier implements KeyVerifier {
private keyStore;
/**
* Computes and optionally stores key metadata. If a keyFingerprint is provided, this function will verify the computed checksum against it before storing it.
*
* @param {KeyMetadata} keyMetadata - Object containing key bytes and optional verification data.
* @throws {KeyVerificationError} When provided keyFingerprint doesn't match computed values.
* @returns {Promise<KeyFingerprint>} Computed key metadata.
*/
computeKeyMetadata(keyMetadata: KeyMetadata): Promise<KeyFingerprint>;
/**
* Verifies key bytes against stored or provided metadata. Follows a priority verification scheme:
* 1. If KeyFingerprint is provided in the metadata, this method verifies against that first.
* 2. If a locator is provided, attempts to verify against stored fingerprint.
* 3. If neither is available, throws an error.
*
* @param {KeyMetadata} keyMetadata - Object containing the key bytes and optional verification metadata.
* @throws {Error} When neither fingerprint nor valid locator is provided for verification.
* @throws {KeyVerificationError} When size or checksum verification fails.
* @returns {Promise<void>} Promise that resolves when verification succeeds.
*/
verifyKeyBytes(keyMetadata: KeyMetadata): Promise<void>;
}