Class: CryptoApi

CryptoApi(encryptionKeyPair, signKeyPair)

This api is a wrapper for crypto functions that operate on secret keys.

Through this wrapper you can expose crypto functionality without exposing the private key. This is exactly what the keychain implementation does. It will never give you direct access to private keys, only the functions needed to work with those keys.

Constructor

new CryptoApi(encryptionKeyPair, signKeyPair)

Parameters:
Name Type Description
encryptionKeyPair KeyPair

keypair for encryption

signKeyPair SignKeyPair

keypair for signing

Construct a new crypt api wrapper.

Source:

Classes

CryptoApi

Methods

encrypt(data, otherPublicKey, nonce) → {Uint8Array}

Parameters:
Name Type Description
data Uint8Array
otherPublicKey PublicKey
nonce Nonce

Same as encryption.ts:encrypt

Source:
Returns:

Type: Uint8Array

encryptAndEmbedNonce(data, otherPublicKey, nonce) → {Uint8Array}

Parameters:
Name Type Description
data Uint8Array
otherPublicKey PublicKey
nonce Nonce

Same as encryption.ts:encryptAndEmbedNonce

Source:
Returns:

Type: Uint8Array

decrypt(cypher, otherPublicKey, nonce) → {Uint8Array}

Parameters:
Name Type Description
cypher Uint8Array
otherPublicKey PublicKey
nonce Nonce

Same as encryption.ts:decrypt

Source:
Returns:

Type: Uint8Array

decryptWithEmbeddedNonce(cypherAndNonce, otherPublicKey) → {Uint8Array}

Parameters:
Name Type Description
cypherAndNonce Uint8Array
otherPublicKey PublicKey

Same as encryption.ts:decryptWithEmbeddedNonce

Source:
Returns:

Type: Uint8Array

createEncryptionApiWithPerson(otherPublicKey) → {EncryptionApi}

Parameters:
Name Type Description
otherPublicKey PublicKey

Construct an encryption/decryption api based on the public key of someone else.

All encryption & decryption calls from this crypto API, require the public key of somebody else. By using the api returned by this function, you do not have to specify the key of the other side each time. This is also slightly faster if multiple functions are called, because this call derives the symmetric key only once.

Source:
Returns:

Type: EncryptionApi

createEncryptionApiWithKeysAndPerson(otherPublicKey) → {SymmetricCryptoApi}

Parameters:
Name Type Description
otherPublicKey PublicKey

Same as createCryptoApiWith, but we also store the public keys of the participants.

Source:
Returns:

Type: SymmetricCryptoApi

sign(data) → {Uint8Array}

Parameters:
Name Type Description
data Uint8Array

Sign the passed data.

This only returns the signature, not a complete signed message.

Source:
Returns:

Type: Uint8Array