UNPKG

@planq-network/encrypted-backup

Version:

Libraries for implemented password encrypted account backups

50 lines (49 loc) 2.93 kB
/// <reference types="node" /> import { Address } from '@planq-network/base/lib/address'; import { Result } from '@planq-network/base/lib/result'; import { ServiceContext as OdisServiceContext } from '@planq-network/identity/lib/odis/query'; import { DomainQuotaStatusResponseSuccess, SequentialDelayDomain } from '@planq-network/phone-number-privacy-common'; import { OdisHardeningConfig } from './config'; import { BackupError } from './errors'; import { EIP712Wallet } from './utils'; /** * Builds an ODIS SequentialDelayDomain with the given hardening configuration. * * @param authorizer Address of the key that should authorize requests to ODIS. * @returns A SequentialDelayDomain with the provided rate limiting configuration. */ export declare function buildOdisDomain(config: OdisHardeningConfig, authorizer: Address, salt?: string): SequentialDelayDomain; /** * Returns a hardened key derived from the input key material and a POPRF evaluation on that keying * material under the given rate limiting domain. * * @param key Input key material which will be the blinded input to the ODIS POPRF. * @param domain Rate limiting configuration and domain input to the ODIS POPRF. * @param environment Information for the targeted ODIS environment. * @param wallet Wallet with access to the authorizer signing key specified in the domain input. * Should be provided if the input domain is authenticated. */ export declare function odisHardenKey(key: Buffer, domain: SequentialDelayDomain, environment: OdisServiceContext, wallet?: EIP712Wallet): Promise<Result<Buffer, BackupError>>; /** * Derive from the nonce a private key and use it to instantiate a wallet for request signing * * @remarks It is important that the auth key does not mix in entropy from the password value. If * it did, then the derived address and signatures would act as a commitment to the underlying * password value and would allow offline brute force attacks when combined with the other values * mixed into the key value. */ export declare function odisQueryAuthorizer(nonce: Buffer): { address: Address; wallet: EIP712Wallet; }; /** * Returns a hardened key derived from the input key material and a POPRF evaluation on that keying * material under the given rate limiting domain. * * @param domain Rate limiting configuration and domain input to the ODIS POPRF. * @param environment Information for the targeted ODIS environment. * @param sessionID client-defined session ID for tracking requests across services * @param wallet Wallet with access to the authorizer signing key specified in the domain input. * Should be provided if the input domain is authenticated. */ export declare function requestOdisDomainQuotaStatus(domain: SequentialDelayDomain, environment: OdisServiceContext, sessionID: string, wallet?: EIP712Wallet): Promise<Result<DomainQuotaStatusResponseSuccess, BackupError>>;