EncryptionUtils

@human-protocol/sdk / Modules / encryption / EncryptionUtils

Class: EncryptionUtils

encryption.EncryptionUtils

Introduction

Utility class for encryption-related operations.

Installation

npm

npm install @human-protocol/sdk

yarn

yarn install @human-protocol/sdk

Code example

import { EncryptionUtils } from '@human-protocol/sdk';

const keyPair = await EncryptionUtils.generateKeyPair('Human', '[email protected]');

Table of contents

Constructors

Methods

Constructors

constructor

new EncryptionUtils(): EncryptionUtils

Returns

EncryptionUtils

Methods

encrypt

encrypt(message, publicKeys): Promise<string>

This function encrypts a message using the specified public keys.

Parameters

Name
Type
Description

message

string

Message to encrypt.

publicKeys

string[]

-

Returns

Promise<string>

Message encrypted.

Code example

Defined in

encryption.ts:422


generateKeyPair

generateKeyPair(name, email, passphrase?): Promise<IKeyPair>

This function generates a key pair for encryption and decryption.

Parameters

Name
Type
Default value
Description

name

string

undefined

Name for the key pair.

email

string

undefined

Email for the key pair.

passphrase

string

''

Passphrase to encrypt the private key. Optional.

Returns

Promise<IKeyPair>

Key pair generated.

Code example

Defined in

encryption.ts:360


getSignedData

getSignedData(message): Promise<string>

This function gets signed data from a signed message.

Parameters

Name
Type
Description

message

string

Message.

Returns

Promise<string>

Signed data.

Code example

Defined in

encryption.ts:317


isEncrypted

isEncrypted(message): boolean

Verifies if a message appears to be encrypted with OpenPGP.

Parameters

Name
Type
Description

message

string

Message to verify.

Returns

boolean

true if the message appears to be encrypted, false if not.

Code example:

Defined in

encryption.ts:471


verify

verify(message, publicKey): Promise<boolean>

This function verifies the signature of a signed message using the public key.

Parameters

Name
Type
Description

message

string

Message to verify.

publicKey

string

Public key to verify that the message was sign by a specific source.

Returns

Promise<boolean>

True if verified. False if not verified.

Code example

Defined in

encryption.ts:284

Last updated