Skip to main content
reference

PrivmxCrypto

Wrapper class for the build in Crypto.

Constructors

constructor

constructor()

Static Methods

convertPEMKeyToWIFKey

Converts a PEM key to WIF format.

static async convertPEMKeyToWIFKey(keyPEM: string)

NameTypeDescription
keyPEMstringPEM key to convert

TypeDescription
Promise<string> WIF formatted key

decryptDataSymmetric

Decrypts given data using the provided key.

static async decryptDataSymmetric(data: Uint8Array, key: Uint8Array)

NameTypeDescription
dataUint8Arraydata to decrypt
keyUint8Arraykey to use for decryption

TypeDescription
Promise<Uint8Array> decrypted data

deriveKeySymmetric

Derives a symmetric key from a password and salt using a key derivation function.

static async deriveKeySymmetric(password: string, salt: string)

NameTypeDescription
passwordstringinput password used to derive the key
saltstringa unique string used to ensure that the same password generates different keys

TypeDescription
Promise<Uint8Array> generated derived key

derivePrivateKey

Generates a new private key using PBKDF2.

static async derivePrivateKey(salt: string, password: string)

NameTypeDescription
saltstringsalt to use for key generation
passwordstringpassword to use for key generation

TypeDescription
Promise<string> generated private key

derivePublicKey

Generates a new public key from given private key.

static async derivePublicKey(privKey: string)

NameTypeDescription
privKeystringprivate key to use for generating the public key

TypeDescription
Promise<string> generated public key

encryptDataSymmetric

Encrypts given data using the provided key.

static async encryptDataSymmetric(data: Uint8Array, key: Uint8Array)

NameTypeDescription
dataUint8Arraydata to encrypt
keyUint8Arraykey to use for encryption

TypeDescription
Promise<Uint8Array> encrypted data

generateKeySymmetric

Generates a new symmetric key signData a `Uint8Array`. This function uses a cryptographic algorithm to create a secure random key.

static async generateKeySymmetric()

TypeDescription
Promise<Uint8Array> generated symmetric key

generatePrivateKey

Generates a new private key.

static async generatePrivateKey(baseString: string)

NameTypeDescription
baseStringstringoptional base string to use for key generation

TypeDescription
Promise<string> generated private key

signData

Signs given data using the provided private key.

static async signData(data: Uint8Array, privKey: string)

NameTypeDescription
dataUint8Arraydata to sign
privKeystringprivate key to use for signing

TypeDescription
Promise<Uint8Array> signature

verifySignature

Validate a signature of data using given key.

static async verifySignature(data: Uint8Array, signature: Uint8Array, publicKey: string)

NameTypeDescription
dataUint8Arraybuffer
signatureUint8Arraytof data
publicKeystringpublic ECC key in BASE58DER format used to validate data

TypeDescription
Promise<boolean> validated data