@bsv/sdk
Version:
BSV Blockchain Software Development Kit
62 lines • 3.31 kB
TypeScript
import PrivateKey from '../primitives/PrivateKey.js';
import PublicKey from '../primitives/PublicKey.js';
/**
* @class ECIES
* Implements the Electrum ECIES protocol for encrypted communication.
*
* @prprecated This class is deprecated in favor of the BRC-78 standard for portable encrypted messages,
* which provides a more comprehensive and secure solution by integrating with BRC-42 and BRC-43 standards.
*/
export default class ECIES {
/**
* Generates the initialization vector (iv), encryption key (kE), and MAC key (kM)
* using the sender's private key and receiver's public key.
*
* @param {PrivateKey} privKey - The sender's private key.
* @param {PublicKey} pubKey - The receiver's public key.
* @returns {Object} An object containing the iv, kE, and kM as number arrays.
*/
static ivkEkM(privKey: PrivateKey, pubKey: PublicKey): {
iv: number[];
kE: number[];
kM: number[];
};
/**
* Encrypts a given message using the Electrum ECIES method.
*
* @param {number[]} messageBuf - The message to be encrypted, in number array format.
* @param {PublicKey} toPublicKey - The public key of the recipient.
* @param {PrivateKey} [fromPrivateKey] - The private key of the sender. If not provided, a random private key is used.
* @param {boolean} [noKey=false] - If true, does not include the sender's public key in the encrypted message.
* @returns {number[]} The encrypted message as a number array.
*/
static electrumEncrypt(messageBuf: number[], toPublicKey: PublicKey, fromPrivateKey?: PrivateKey, noKey?: boolean): number[];
/**
* Decrypts a message encrypted using the Electrum ECIES method.
*
* @param {number[]} encBuf - The encrypted message buffer.
* @param {PrivateKey} toPrivateKey - The private key of the recipient.
* @param {PublicKey} [fromPublicKey=null] - The public key of the sender. If not provided, it is extracted from the message.
* @returns {number[]} The decrypted message as a number array.
*/
static electrumDecrypt(encBuf: number[], toPrivateKey: PrivateKey, fromPublicKey?: PublicKey): number[];
/**
* Encrypts a given message using the Bitcore variant of ECIES.
*
* @param {number[]} messageBuf - The message to be encrypted, in number array format.
* @param {PublicKey} toPublicKey - The public key of the recipient.
* @param {PrivateKey} [fromPrivateKey] - The private key of the sender. If not provided, a random private key is used.
* @param {number[]} [ivBuf] - The initialization vector for encryption. If not provided, a random IV is used.
* @returns {number[]} The encrypted message as a number array.
*/
static bitcoreEncrypt(messageBuf: number[], toPublicKey: PublicKey, fromPrivateKey?: PrivateKey, ivBuf?: number[]): number[];
/**
* Decrypts a message encrypted using the Bitcore variant of ECIES.
*
* @param {number[]} encBuf - The encrypted message buffer.
* @param {PrivateKey} toPrivateKey - The private key of the recipient.
* @returns {number[]} The decrypted message as a number array.
*/
static bitcoreDecrypt(encBuf: number[], toPrivateKey: PrivateKey): number[];
}
//# sourceMappingURL=ECIES.d.ts.map