Blockchain Commons Components TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Interface Decrypter

    A trait for types that can decapsulate shared secrets for public key decryption.

    The Decrypter interface defines an interface for decapsulating (recovering) a shared secret using a private key. This is the counterpart to the Encrypter interface and is used by the recipient of encapsulated messages.

    Types implementing this interface provide the ability to:

    1. Access their encapsulation private key
    2. Decapsulate shared secrets from ciphertexts

    This interface is typically implemented by:

    • Encapsulation private keys
    • Higher-level types that contain or can access encapsulation private keys
    import { EncapsulationScheme, createEncapsulationKeypair } from '@bcts/components';

    // Generate a keypair
    const [privateKey, publicKey] = createEncapsulationKeypair(EncapsulationScheme.X25519);

    // Encapsulate a new shared secret
    const [originalSecret, ciphertext] = publicKey.encapsulateNewSharedSecret();

    // Decapsulate the shared secret
    const recoveredSecret = privateKey.decapsulateSharedSecret(ciphertext);

    // The original and recovered secrets should match

    Implemented by

    Index

    Methods

    • Decapsulates a shared secret from a ciphertext.

      This method recovers the shared secret that was encapsulated in the given ciphertext, using the private key from this decrypter.

      Parameters

      Returns SymmetricKey

      The decapsulated SymmetricKey

      Error if the ciphertext type doesn't match the private key type or if decapsulation fails