Encryption
@human-protocol/sdk • Docs
@human-protocol/sdk / encryption / Encryption
Class: Encryption
Introduction
Class for sign and decrypt messages.
The algorithm includes the implementation of the PGP encryption algorithm multi-public key encryption on typescript. Using the vanilla ed25519 implementation Schnorr signatures for signature and curve25519 for encryption. Learn more.
To get an instance of this class, is recommended to initialize it using the static build method.
static async build(privateKeyArmored: string, passphrase?: string): Promise<Encryption>Installation
npm
npm install @human-protocol/sdkyarn
yarn install @human-protocol/sdkInput parameters
privateKeyArmored- The encrypted private key in armored format.passphrase- The passphrase for the private key.
Code example
Constructors
new Encryption()
new Encryption(
privateKey):Encryption
Constructor for the Encryption class.
Parameters
• privateKey: PrivateKey
The private key.
Returns
Defined in
Methods
decrypt()
decrypt(
message,publicKey?):Promise<string>
This function decrypt message message using the private key. In addition, the public key can be added for signature verification.
Parameters
• message: string
Message to decrypt.
• publicKey?: string
Public key used to verify signature if needed. Optional.
Returns
Promise<string>
Message decrypted.
Code example
Defined in
sign()
sign(
message):Promise<string>
This function signs a message using the private key used to initialize the client.
Parameters
• message: string
Message to sign.
Returns
Promise<string>
Message signed.
Code example
Defined in
signAndEncrypt()
signAndEncrypt(
message,publicKeys):Promise<string>
This function signs and encrypts a message using the private key used to initialize the client and the specified public keys.
Parameters
• message: string
Message to sign and encrypt.
• publicKeys: string[]
Array of public keys to use for encryption.
Returns
Promise<string>
Message signed and encrypted.
Code example
Defined in
build()
staticbuild(privateKeyArmored,passphrase?):Promise<Encryption>
Builds an Encryption instance by decrypting the private key from an encrypted private key and passphrase.
Parameters
• privateKeyArmored: string
The encrypted private key in armored format.
• passphrase?: string
Optional: The passphrase for the private key.
Returns
Promise<Encryption>
The Encryption instance.
Defined in
Last updated