UNPKG

wallet-storage

Version:

BRC100 conforming wallet, wallet storage and wallet signer components

66 lines 4.55 kB
import { Base64String, Certificate as BsvCertificate, CertificateFieldNameUnder50Bytes, GetPublicKeyArgs, GetPublicKeyResult, OriginatorDomainNameStringUnder250Bytes, PubKeyHex, WalletCertificate, WalletDecryptArgs, WalletDecryptResult, WalletEncryptArgs, WalletEncryptResult, WalletProtocol } from '@bsv/sdk'; export interface CertOpsWallet { getPublicKey(args: GetPublicKeyArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<GetPublicKeyResult>; encrypt(args: WalletEncryptArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<WalletEncryptResult>; decrypt(args: WalletDecryptArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<WalletDecryptResult>; } export declare class CertOps extends BsvCertificate { wallet: CertOpsWallet; _keyring?: Record<CertificateFieldNameUnder50Bytes, string>; _encryptedFields?: Record<CertificateFieldNameUnder50Bytes, Base64String>; _decryptedFields?: Record<CertificateFieldNameUnder50Bytes, string>; constructor(wallet: CertOpsWallet, wc: WalletCertificate); static fromCounterparty(wallet: CertOpsWallet, e: { certificate: WalletCertificate; keyring: Record<CertificateFieldNameUnder50Bytes, string>; counterparty: PubKeyHex; }): Promise<CertOps>; static fromCertifier(wallet: CertOpsWallet, e: { certificate: WalletCertificate; keyring: Record<CertificateFieldNameUnder50Bytes, string>; }): Promise<CertOps>; static fromEncrypted(wallet: CertOpsWallet, wc: WalletCertificate, keyring: Record<CertificateFieldNameUnder50Bytes, string>): Promise<CertOps>; static fromDecrypted(wallet: CertOpsWallet, wc: WalletCertificate): Promise<CertOps>; static copyFields<T>(fields: Record<CertificateFieldNameUnder50Bytes, T>): Record<CertificateFieldNameUnder50Bytes, T>; static getProtocolForCertificateFieldEncryption(serialNumber: string, fieldName: string): { protocolID: WalletProtocol; keyID: string; }; exportForSubject(): { certificate: WalletCertificate; keyring: Record<CertificateFieldNameUnder50Bytes, string>; }; toWalletCertificate(): WalletCertificate; encryptFields(counterparty?: 'self' | PubKeyHex): Promise<{ fields: Record<CertificateFieldNameUnder50Bytes, string>; keyring: Record<CertificateFieldNameUnder50Bytes, string>; }>; decryptFields(counterparty?: PubKeyHex, keyring?: Record<CertificateFieldNameUnder50Bytes, string>): Promise<Record<CertificateFieldNameUnder50Bytes, string>>; exportForCounterparty( /** The incoming counterparty is who they are to us. */ counterparty: PubKeyHex, fieldsToReveal: CertificateFieldNameUnder50Bytes[]): Promise<{ certificate: WalletCertificate; keyring: Record<CertificateFieldNameUnder50Bytes, string>; counterparty: PubKeyHex; }>; /** * Creates a verifiable certificate structure for a specific verifier, allowing them access to specified fields. * This method decrypts the master field keys for each field specified in `fieldsToReveal` and re-encrypts them * for the verifier's identity key. The resulting certificate structure includes only the fields intended to be * revealed and a verifier-specific keyring for field decryption. * * @param {PubKeyHex} verifierIdentityKey - The public identity key of the verifier who will receive access to the specified fields. * @param {CertificateFieldNameUnder50Bytes[]} fieldsToReveal - An array of field names to be revealed to the verifier. Must be a subset of the certificate's fields. * @returns {Promise<Record<CertificateFieldNameUnder50Bytes[], Base64String>} - A new certificate structure containing the original encrypted fields, the verifier-specific field decryption keyring, and essential certificate metadata. * @throws {WERR_INVALID_PARAMETER} Throws an error if: * - fieldsToReveal is empty or a field in `fieldsToReveal` does not exist in the certificate. * - The decrypted master field key fails to decrypt the corresponding field (indicating an invalid key). */ createKeyringForVerifier(verifierIdentityKey: PubKeyHex, fieldsToReveal: CertificateFieldNameUnder50Bytes[]): Promise<Record<CertificateFieldNameUnder50Bytes, Base64String>>; /** * encrypt plaintext field values for the subject * update the signature using the certifier's private key. */ encryptAndSignNewCertificate(): Promise<void>; } //# sourceMappingURL=CertOps.d.ts.map