interface DerivedKey { salt: Uint8Array; hash: Uint8Array; } export declare const KEY_LENGTH: number; /** * Derives a key from a password and salt. * @param password The pasword to derive the key from. * @param salt The salt to use. * @returns */ export declare function deriveKey(password: Uint8Array, salt: Uint8Array): DerivedKey; /** * Encrypts the given data with the given password and returns the resulting cyphertext. * * The returned cyphertext contains a version number at the beginning which determines the format of the following data. * * v1 encryptions use XSalsa20 as the cipher and Poly1305 for authentication in addition to scrypt for password-based key derivation. * The output string is formatted as following with periods between the components: * 1. The version number (v1) * 2. The base64 of the salt used to derive the key from the password. (pseudorandom) * 3. The base64 of the nonce used by the cipher. (pseudorandom) * 4. The base64 of the encrypted data. * * @param password The password to use to encrypt. * @param data The data to encrypt. */ export declare function encrypt(password: string, data: Uint8Array): string; /** * Decrypts the given cyphertext with the given password and returns the original plaintext. * Returns null if the data was unable to be decrypted. * @param password The password to use to decrypt. * @param cyphertext The data to decrypt. */ export declare function decrypt(password: string, cyphertext: string): Uint8Array; /** * Encrypts the given data with the given password using version 1 of the encryption mechanisms in this file and returns the resulting * cyphertext. * * version 1 encryptions use XSalsa20 as the cipher and Poly1305 for authentication in addition to scrypt for password-based key derivation. * The output string is formatted as following with periods between the components: * 1. The version number (v1) * 2. The base64 of the salt used to derive the key from the password. (pseudorandom) * 3. The base64 of the nonce used by the cipher. (pseudorandom) * 4. The base64 of the encrypted data. * * @param password The password to use to encrypt the data. * @param data The data to encrypt. */ export declare function encryptV1(password: string, data: Uint8Array): string; /** * Decrypts the given data with the given password using version 1 of the encryption mechanisms in this file and returns the resulting * plaintext. * * version 1 encryptions use XSalsa20 as the cipher and Poly1305 for authentication in addition to scrypt for password-based key derivation. * * @param password The password to use to decrypt the data. * @param cyphertext The cyphertext produced from encryptV1(). */ export declare function decryptV1(password: string, cyphertext: string): Uint8Array; /** * Determines if the given value is a keypair generated using {@link crypto.asymmetric.keypair}. * Returns true if the data is a keypair and false otherwise. * * @param keypair the value that should be tested to see if it is a keypair. * * @example Determine if a value is a keypair. * const encrypted = crypto.asymmetric.isKeypair("hello, world"); * os.toast('Is it a keypair? ' + encrypted); * * @dochash actions/crypto * @docname crypto.asymmetric.isKeypair */ export declare function isAsymmetricKeypair(keypair: string): boolean; /** * Creates a keypair that can be used for public key authenticated encryption. * * The returned keypair contains a version number at the beginning which determines the format of the following data. * * vEK1 keypairs use x25519 with XSalsa20 and Poly1305. * The output string is formatting as following with periods between the components: * 1. The version number (vEK1) - the EK is for "encryption keypair". * 2. The base64 of the public key. * 3. The base64 of the encrypted private key. * * @param password The password that should be used to encrypt the private key of the keypair. */ export declare function asymmetricKeypair(password: string): string; /** * Creates a version 1 keypair that can be used for public key authenticated encryption. * * The returned keypair contains a version number at the beginning which determines the format of the following data. * * vEK1 keypairs use x25519 with XSalsa20 and Poly1305. * The output string is formatting as following with periods between the components: * 1. The version number (vEK1) - the EK is for "encryption keypair". * 2. The base64 of the public key. * 3. The base64 of the encrypted private key. * * @param password The password that should be used to encrypt the private key of the keypair. */ export declare function asymmetricKeypairV1(password: string): string; /** * Encrypts the given data with the given keypair and returns the resulting cyphertext. * * The returned cyphertext contains a version number at the beginning which determines the format of the following data. * * vA1 encryptions use x25519 for key exchange, XSalsa20 as the cipher and Poly1305 for authentication. * * vA1 encryptions technically use two keypairs for encryption/decryption. One for the local party and one for the remote party. * These two parties are used to calculate a shared key that is then used to encrypt and authenticate the data. * When encrypting, a new keypair is generated and used for the "local" party while the given keypair is used for the remote party. * The secret key is then discarded while the public key is included in the output to make it possible for the other party to decrypt the data. * * The output string is formatted as following with periods between the components: * 1. The version number (vA1). The "A" means "asymmetric". * 2. The base64 of the public key of the keypair used to encrypt the data. * 3. The base64 of the nonce used by the cipher. (pseudorandom) * 4. The base64 of the encrypted data. * * @param keypair The keypair to use to encrypt. * @param data The data to encrypt. */ export declare function asymmetricEncrypt(keypair: string, data: Uint8Array): string; /** * Encrypts the given data with the given keypair and returns the resulting cyphertext. * * The returned cyphertext contains a version number at the beginning which determines the format of the following data. * * vA1 encryptions use x25519 for key exchange, XSalsa20 as the cipher and Poly1305 for authentication. * * vA1 encryptions technically use two keypairs for encryption/decryption. One for the local party and one for the remote party. * These two parties are used to calculate a shared key that is then used to encrypt and authenticate the data. * When encrypting, a new keypair is generated and used for the "local" party while the given keypair is used for the remote party. * The secret key is then discarded while the public key is included in the output to make it possible for the other party to decrypt the data. * * The output string is formatted as following with periods between the components: * 1. The version number (vA1). The "A" means "asymmetric". * 2. The base64 of the public key of the keypair used to encrypt the data. * 3. The base64 of the nonce used by the cipher. (pseudorandom) * 4. The base64 of the encrypted data. * * @param keypair The keypair to use to encrypt. * @param data The data to encrypt. */ export declare function asymmetricEncryptV1(keypair: string, data: Uint8Array): string; /** * Decrypts the given data with the given keypair and returns the resulting plaintext. * Returns null if the data was unable to be decrypted. * * vA1 encryptions use x25519 for key exchange, XSalsa20 as the cipher and Poly1305 for authentication. * * @param keypair The keypair to use to decrypt the data. * @param password The password that should be used to decrypt the keypair's private key. * @param cyphertext The data to decrypt. */ export declare function asymmetricDecrypt(keypair: string, password: string, cyphertext: string): Uint8Array; /** * Decrypts the given data with the given keypair using version 1 of the asymmetric encryption mechanisms in this file and returns the resulting * plaintext. Returns null if the data was unable to be decrypted. * * vA1 encryptions use x25519 for key exchange, XSalsa20 as the cipher and Poly1305 for authentication. * * @param keypair The keypair to use to decrypt the data. * @param password The password that should be used to decrypt the keypair's private key. * @param cyphertext The data to decrypt. */ export declare function asymmetricDecryptV1(keypair: string, password: string, cyphertext: string): Uint8Array; /** * Determines if the given value was encrypted using {@link crypto.asymmetric.encrypt}. * Returns `true` if the data is a keypair and `false` otherwise. * * @param cyphertext the value that should be tested to see if it is encrypted. * * @example Determine if a value is encrypted with asymmetric encryption. * const encrypted = crypto.asymmetric.isEncrypted("hello, world"); * os.toast('Is it encrypted? ' + encrypted); * * @dochash actions/crypto * @docname crypto.asymmetric.isEncrypted */ export declare function isAsymmetricEncrypted(cyphertext: string): boolean; /** * Determines if the given value has been encrypted using {@link crypto.encrypt}. * Returns true if the data is encrypted and false otherwise. * * @param cyphertext the value that should be tested to see if it has been encrypted. * * @example Determine if a value is encrypted. * const encrypted = crypto.isEncrypted("hello, world"); * os.toast('Is it encrypted? ' + encrypted); * * @dochash actions/crypto * @docname crypto.isEncrypted */ export declare function isEncrypted(cyphertext: string): boolean; export {}; //# sourceMappingURL=Encryption.d.ts.map