UnifiedCrypto is a class that provides a unified interface for the different encryption algorithms It is used to encrypt and decrypt messages, sign and verify messages, and generate identities for the different algorithms It uses Enigma for PQC encryption/decryption and Cryptography for RSA encryption/decryption It uses Enigma for PQC signing and Cryptography for Ed25519 signing It uses the master seed to derive seeds for the different algorithms using HKDF Manages encryptedObjects and signedObjects to route data through the supported algorithms REVIEW: Check race conditions REVIEW: Check stability of the master seed transformation TODO: Build a test suite for the UnifiedCrypto class

Properties

ed25519KeyPair: {
    privateKey: NativeBuffer;
    publicKey: NativeBuffer;
}
enigma: Enigma
masterSeed: Uint8Array<ArrayBufferLike>
rsaKeyPair: KeyPair
supportedPQCAlgorithms: PQCAlgorithm[] = ...

Methods

  • Decrypts an encrypted object based on the algorithm

    Parameters

    Returns Promise<Uint8Array<ArrayBufferLike>>

    The decrypted data

  • Derives a seed for the given algorithm

    Parameters

    • algorithm:
          | "falcon"
          | "ml-dsa"
          | "ed25519"
          | "ml-kem-aes"
          | "rsa"

      The algorithm to derive the seed for

    • Optionalseed: Uint8Array<ArrayBufferLike>

      (optional) The seed to derive the seed from, or undefined to generate a new one or use the master seed if set

    Returns Promise<Uint8Array<ArrayBufferLike>>

    The derived seed

  • Encrypts a message based on the algorithm using the previously generated identity

    Parameters

    • algorithm: "ml-kem-aes" | "rsa"

      The algorithm to encrypt the message with

    • data: Uint8Array<ArrayBufferLike>

      The message to encrypt

    • peerPublicKey: Uint8Array<ArrayBufferLike>

      The public key of the peer to encrypt the message to

    Returns Promise<encryptedObject>

    The encrypted object as an encryptedObject

  • Ensures that the master seed is set and generates a new one if not set

    Parameters

    • OptionalmasterSeed: Uint8Array<ArrayBufferLike>

      (optional) The master seed to set, or undefined to generate a new one

    Returns Promise<void>

  • Parameters

    • algorithm:
          | "falcon"
          | "ml-dsa"
          | "ed25519"
          | "ml-kem-aes"
          | "rsa"
    • OptionalmasterSeed: Uint8Array<ArrayBufferLike>

    Returns Promise<void>

  • Parameters

    • algorithm:
          | "falcon"
          | "ml-dsa"
          | "ed25519"
          | "ml-kem-aes"
          | "rsa"

    Returns Promise<{
        genKey?: Uint8Array<ArrayBufferLike>;
        privateKey: NativeBuffer | Uint8Array<ArrayBufferLike> | PrivateKey;
        publicKey: PublicKey | NativeBuffer | Uint8Array<ArrayBufferLike>;
    }>

  • Signs a message based on the algorithm using the previously generated identity

    Parameters

    • algorithm: "falcon" | "ml-dsa" | "ed25519"

      The algorithm to sign the message with

    • data: Uint8Array<ArrayBufferLike>

      The message to sign

    Returns Promise<signedObject>

    The signed object as a signedObject

  • Verifies a signed object based on the algorithm

    Parameters

    Returns Promise<boolean>

    True if the signed object is valid, false otherwise

    Error if publicKey is not in the expected format for the algorithm