Gordian Envelope TypeScript Library - v1.0.0-alpha.20
    Preparing search index...

    Interface Encrypter

    A trait for types that can encapsulate shared secrets for public key encryption.

    The Encrypter interface defines an interface for encapsulating a shared secret using a public key. This is a key part of hybrid encryption schemes, where a shared symmetric key is encapsulated with a public key, and the recipient uses their private key to recover the symmetric key.

    Types implementing this interface provide the ability to:

    1. Access their encapsulation public key
    2. Generate and encapsulate new shared secrets

    This interface is typically implemented by:

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

    // Generate a recipient keypair
    const [recipientPrivateKey, recipientPublicKey] = createEncapsulationKeypair(EncapsulationScheme.X25519);

    // Encapsulate a new shared secret
    const [sharedSecret, ciphertext] = recipientPublicKey.encapsulateNewSharedSecret();
    interface Encrypter {
        encapsulationPublicKey(): PublicKeyBase;
        encapsulateNewSharedSecret(): [SymmetricKey, EncapsulationCiphertext];
    }
    Index

    Methods

    • Returns the encapsulation public key for this encrypter.

      Returns PublicKeyBase

      The encapsulation public key that should be used for encapsulation.

    • Encapsulates a new shared secret for the recipient.

      This method generates a new shared secret and encapsulates it using the encapsulation public key from this encrypter.

      Returns [SymmetricKey, EncapsulationCiphertext]

      A tuple containing:

      • The generated shared secret as a SymmetricKey
      • The encapsulation ciphertext that can be sent to the recipient