import CryptoBase from './crypto-base'; import { DecryptedContentV3, DecryptParams, DecryptParamsV3, EncryptedContentV3 } from './types'; export default class CryptoV3 extends CryptoBase { signingPublicKey?: string; constructor({ signingPublicKey }?: { signingPublicKey?: string; }); /** * Encrypt input with a unique keypair for each submission. * @param msg The message to encrypt, will be stringified. * @param form The base-64 encoded form public key for encrypting. * @returns The encrypted basestring. */ encrypt: (msg: any, formPublicKey: string) => EncryptedContentV3; /** * Decrypts an encrypted submission and returns it. * @param submissionSecretKey The base-64 encoded secret key for decrypting. * @param decryptParams The params containing encrypted content and information. * @param decryptParams.encryptedContent The encrypted content encoded with base-64. * @param decryptParams.version The version of the payload. * @returns The decrypted content if successful. Else, null will be returned. */ decryptFromSubmissionKey: (submissionSecretKey: string, decryptParams: DecryptParams) => DecryptedContentV3 | null; /** * Decrypts an encrypted submission and returns it. * @param formSecretKey The base-64 encoded form secret key for decrypting the submission. * @param decryptParams The params containing encrypted content, encrypted submission key and information. * @param decryptParams.encryptedContent The encrypted content encoded with base-64. * @param decryptParams.encryptedSubmissionSecretKey The encrypted submission secret key encoded with base-64. * @param decryptParams.version The version of the payload. Used to determine the decryption process to decrypt the content with. * @returns The decrypted content if successful. Else, null will be returned. * @throws {MissingPublicKeyError} if a public key is not provided when instantiating this class and is needed for verifying signed content. */ decrypt: (formSecretKey: string, decryptParams: DecryptParamsV3) => DecryptedContentV3 | null; /** * Returns true if a pair of public & secret keys are associated with each other * @param publicKey The public key to verify against. * @param secretKey The private key to verify against. */ valid: (publicKey: string, secretKey: string) => boolean; }