import { Fr } from '@aztec/foundation/curves/bn254'; import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin'; import { type Bufferable } from '@aztec/foundation/serialize'; import type { AztecAsyncKVStore } from '@aztec/kv-store'; import { AztecAddress } from '@aztec/stdlib/aztec-address'; import { CompleteAddress, type PartialAddress } from '@aztec/stdlib/contract'; import { KeyValidationRequest } from '@aztec/stdlib/kernel'; import { type KeyPrefix, type PublicKey } from '@aztec/stdlib/keys'; import type { AccountPrivacyKeys, AccountPrivacySecretKeys } from './account_privacy_keys.js'; /** * Used for managing keys. Can hold keys of multiple accounts. */ export declare class KeyStore { #private; static readonly SCHEMA_VERSION = 1; constructor(database: AztecAsyncKVStore); /** * Adds an account to the key store. * * The key store holds the four privacy secret keys (nullifier-hiding, incoming-viewing, outgoing-viewing, tagging), * but only the *public* message-signing and fallback keys: their secret keys are withheld, since the key store (and * PXE, which embeds it) is not trusted to hold them. The public keys are still needed to reconstruct the account's * address, which commits to all six master public keys. * * @param keys - The account's privacy keys: four secret keys plus the message-signing and fallback public keys. * @param partialAddress - The partial address of the account. * @returns The account's complete address. * @throws If any of the account's six master public keys would be the point at infinity. */ addAccount(keys: AccountPrivacyKeys, partialAddress: PartialAddress): Promise; /** * Retrieves addresses of accounts stored in the key store. * @returns A Promise that resolves to an array of account addresses. */ getAccounts(): Promise; /** Checks whether an account is registered in the key store. */ hasAccount(account: AztecAddress): Promise; /** * Gets the key validation request for a given master public key hash and contract address. * @throws If the account corresponding to the master public key hash does not exist in the key store. * @param pkMHash - The master public key hash. * @param contractAddress - The contract address to silo the secret key in the key validation request with. * @returns The key validation request. */ getKeyValidationRequest(pkMHash: Fr, contractAddress: AztecAddress): Promise; /** * Gets the master nullifier public key for a given account. * @throws If the account does not exist in the key store. */ getMasterNullifierHidingPublicKey(account: AztecAddress): Promise; /** * Gets the master incoming viewing public key for a given account. * @throws If the account does not exist in the key store. */ getMasterIncomingViewingPublicKey(account: AztecAddress): Promise; /** * Retrieves the master outgoing viewing public key. * @throws If the account does not exist in the key store. */ getMasterOutgoingViewingPublicKey(account: AztecAddress): Promise; /** * Retrieves the master tagging public key. * @throws If the account does not exist in the key store. */ getMasterTaggingPublicKey(account: AztecAddress): Promise; /** * Retrieves master incoming viewing secret key. * @throws If the account does not exist in the key store. */ getMasterIncomingViewingSecretKey(account: AztecAddress): Promise; /** * Retrieves the four privacy secret keys the key store holds for an account. Paired with {@link addAccount}, this * allows exporting an account's privacy secret keys, e.g. to re-register it on another PXE. The message-signing and * fallback secret keys are not held by the key store and so are not returned. * * @throws If the account does not exist in the key store. */ getAccountSecretKeys(account: AztecAddress): Promise; /** * Retrieves application outgoing viewing secret key. * @throws If the account does not exist in the key store. * @param account - The account to retrieve the application outgoing viewing secret key for. * @param app - The application address to retrieve the outgoing viewing secret key for. * @returns A Promise that resolves to the application outgoing viewing secret key. */ getAppOutgoingViewingSecretKey(account: AztecAddress, app: AztecAddress): Promise; /** * Retrieves the sk_m corresponding to the given pk_m hash. * @throws If the provided hash is not associated with any of the registered accounts. * @param pkMHash - The master public key hash to get secret key for. * @returns A Promise that resolves to sk_m. * @dev Used when feeding the sk_m to the kernel circuit for keys verification. */ getMasterSecretKey(pkMHash: Fr): Promise; /** * Checks whether a given account has a key matching the provided master public key hash. * @param account - The account address to check. * @param pkMHash - The master public key hash to look for. * @returns True if the account has a key with the given hash. */ accountHasKey(account: AztecAddress, pkMHash: Fr): Promise; /** * Gets the key prefix and account address for a given value. * @returns A tuple containing the key prefix and account address. * @dev Note that this is quite inefficient but it should not matter because there should never be too many keys * in the key store. */ getKeyPrefixAndAccount(value: Bufferable): Promise<[KeyPrefix, AztecAddress]>; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia2V5X3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMva2V5X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sRUFBRS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