@openforge-sh/liboqs - v0.14.3
    Preparing search index...

    Class NTRUHps40961229

    NTRU-HPS-4096-1229 key encapsulation mechanism wrapper class

    NTRUHps40961229

    High-level wrapper for NTRU-HPS-4096-1229 KEM operations. Provides secure key generation, encapsulation, and decapsulation with automatic memory management.

    Memory Management:

    • All WASM memory is managed internally
    • Call destroy() when finished to free resources
    • Do not use instance after calling destroy()
    const kem = await createNTRUHps40961229();

    // Generate keypair
    const { publicKey, secretKey } = kem.generateKeyPair();

    // Encapsulate
    const { ciphertext, sharedSecret: senderSecret } = kem.encapsulate(publicKey);

    // Decapsulate
    const receiverSecret = kem.decapsulate(ciphertext, secretKey);

    // Cleanup
    kem.destroy();
    Index

    Accessors

    • get info(): {
          name: "NTRU-HPS-4096-1229";
          identifier: "NTRU-HPS-4096-1229";
          type: "kem";
          securityLevel: 5;
          standardized: false;
          description: string;
          keySize: {
              publicKey: 1842;
              secretKey: 2366;
              ciphertext: 1842;
              sharedSecret: 32;
          };
      }

      Get algorithm information

      Returns {
          name: "NTRU-HPS-4096-1229";
          identifier: "NTRU-HPS-4096-1229";
          type: "kem";
          securityLevel: 5;
          standardized: false;
          description: string;
          keySize: {
              publicKey: 1842;
              secretKey: 2366;
              ciphertext: 1842;
              sharedSecret: 32;
          };
      }

      Algorithm metadata

      console.log(kem.info.name);           // 'NTRU-HPS-4096-1229'
      console.log(kem.info.securityLevel); // 5
      console.log(kem.info.keySize); // { publicKey: 1842, secretKey: 2366, ciphertext: 1842, sharedSecret: 32 }

    Methods

    • Generate a new NTRU-HPS-4096-1229 keypair

      Returns { publicKey: Uint8Array; secretKey: Uint8Array }

      If instance is destroyed

      If key generation fails

      const { publicKey, secretKey } = kem.generateKeyPair();
      console.log('Public key:', publicKey.length); // 1842 bytes
      console.log('Secret key:', secretKey.length); // 2366 bytes
    • Encapsulate a shared secret using the public key

      Parameters

      • publicKey: Uint8Array<ArrayBufferLike>

        Public key for encapsulation (1842 bytes)

      Returns { ciphertext: Uint8Array; sharedSecret: Uint8Array }

      If instance is destroyed

      If public key is invalid

      If encapsulation fails

      const { ciphertext, sharedSecret } = kem.encapsulate(publicKey);
      console.log('Ciphertext:', ciphertext.length); // 1842 bytes
      console.log('Shared secret:', sharedSecret.length); // 32 bytes
    • Decapsulate a shared secret using the secret key

      Parameters

      • ciphertext: Uint8Array<ArrayBufferLike>

        Ciphertext to decapsulate (1842 bytes)

      • secretKey: Uint8Array<ArrayBufferLike>

        Secret key for decapsulation (2366 bytes)

      Returns Uint8Array<ArrayBufferLike>

      Shared secret (32 bytes)

      If instance is destroyed

      If inputs are invalid

      If decapsulation fails

      const sharedSecret = kem.decapsulate(ciphertext, secretKey);
      console.log('Shared secret:', sharedSecret.length); // 32 bytes
    • Free WASM resources

      Returns void

      Releases all WASM memory associated with this instance. The instance cannot be used after calling destroy().

      kem.destroy();
      // kem is now unusable