encryption
This class allows to sign, verify, encrypt and decrypt messages at all levels of escrow processing.
The algorithm includes the implementation of the PGP encryption algorithm multi-public key encryption on python. Using the vanilla ed25519 implementation Schnorr signatures for signature and curve25519 for encryption. Learn more.
Code Example
Module
class human_protocol_sdk.encryption.encryption.Encryption(private_key_armored, passphrase=None)
Bases: object
A class that provides encryption and decryption functionality using PGP (Pretty Good Privacy).
__init__(private_key_armored, passphrase=None)
Initializes an Encryption instance.
Parameters:
private_key_armored (
str
) – Armored representation of the private keypassphrase (
Optional
[str
]) – Passphrase to unlock the private key. Defaults to None.
decrypt(message, public_key=None)
Decrypts a message using the private key.
Parameters:
message (
str
) – Armored message to decryptpublic_key (
Optional
[str
]) – Armored public key used for signature verification. Defaults to None.
Return type:
str
Returns: Decrypted message
Example:
sign(message)
Signs a message using the private key.
Parameters: message (
str
) – Message to signReturn type:
str
Returns: Armored and signed message
Example:
sign_and_encrypt(message, public_keys)
Signs and encrypts a message using the private key and recipient’s public keys.
Parameters:
message (
str
) – Message to sign and encryptpublic_keys (
List
[str
]) – List of armored public keys of the recipients
Return type:
str
Returns: Armored and signed/encrypted message
Example:
Last updated