diff --git a/docs/main/classes/MlKem1024.html b/docs/main/classes/MlKem1024.html index 95c5107..0706bfd 100644 --- a/docs/main/classes/MlKem1024.html +++ b/docs/main/classes/MlKem1024.html @@ -4,7 +4,7 @@
// Using jsr:
import { MlKem1024 } from "@dajiaji/mlkem";
// Using npm:
// import { MlKem1024 } from "mlkem"; // or "crystals-kyber-js"

const recipient = new MlKem1024();
const [pkR, skR] = await recipient.generateKeyPair();

const sender = new MlKem1024();
const [ct, ssS] = await sender.encap(pkR);

const ssR = await recipient.decap(ct, skR);
// ssS === ssR
-

Hierarchy

Constructors

Hierarchy

Constructors

Properties

Constructors

Properties

_compressedUSize: number = 0
_compressedVSize: number = 0
_du: number = 11
_dv: number = 5
_eta1: number = 2
_eta2: number = 2
_k: number = 4
_pkSize: number = 0
_skSize: number = 0

Methods

  • Lossily compresses and serializes a vector of polynomials.

    +

    Returns MlKem1024

Properties

_compressedUSize: number = 0
_compressedVSize: number = 0
_du: number = 11
_dv: number = 5
_eta1: number = 2
_eta2: number = 2
_k: number = 4
_pkSize: number = 0
_skSize: number = 0

Methods

  • Lossily compresses and serializes a vector of polynomials.

    Parameters

    • r: Uint8Array
    • u: number[][]

      The vector of polynomials to compress.

    Returns Uint8Array

    The compressed and serialized data as a Uint8Array.

    -
  • Lossily compresses and serializes a polynomial.

    +
  • Lossily compresses and serializes a polynomial.

    Parameters

    • r: Uint8Array

      The output buffer to store the compressed data.

    • v: number[]

      The polynomial to compress.

    Returns Uint8Array

    The compressed and serialized data as a Uint8Array.

    -
  • Deserializes and decompresses a vector of polynomials. +

  • Deserializes and decompresses a vector of polynomials. This is the approximate inverse of the _compressU method. Since compression is lossy, the decompressed data may not match the original vector of polynomials.

    Parameters

    • a: Uint8Array

      The compressed and serialized data as a Uint8Array.

    Returns number[][]

    The decompressed vector of polynomials.

    -
  • Decompresses a given polynomial, representing the approximate inverse of +

  • Decompresses a given polynomial, representing the approximate inverse of compress2, in Uint8Array into an array of numbers.

    Note that compression is lossy, and thus decompression will not match the original input.

    Parameters

    • a: Uint8Array

      The Uint8Array to decompress.

    Returns number[]

    An array of numbers obtained from the decompression process.

    -
  • Generates a 2D array of noise samples.

    +
  • Generates a 2D array of noise samples.

    Parameters

    • sigma: Uint8Array

      The noise parameter.

    • offset: number

      The offset value.

    • size: number

      The size of the array.

    Returns number[][]

    The generated 2D array of noise samples.

    -
  • Generates a 2-dimensional array of noise samples.

    +
  • Generates a 2-dimensional array of noise samples.

    Parameters

    • sigma: Uint8Array

      The noise parameter.

    • offset: number

      The offset value.

    • size: number

      The size of the array.

    Returns number[][]

    The generated 2-dimensional array of noise samples.

    -
  • Generates a ciphertext for the public key and a shared secret.

    +
  • Generates a ciphertext for the public key and a shared secret.

    If an error occurred, throws MlKemError.

    Parameters

    • ct: Uint8Array

      A ciphertext generated by encap.

    • sk: Uint8Array

      A private key.

      @@ -62,7 +62,7 @@
      // Using jsr:
      import { MlKem768 } from "@dajiaji/mlkem";
      // Using npm:
      // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

      const kyber = new MlKem768();
      const [pk, sk] = await kyber.generateKeyPair();
      const [ct, ssS] = await kyber.encap(pk);
      const ssR = await kyber.decap(ct, sk);
      // ssS === ssR
      -
  • Derives a keypair [publicKey, privateKey] deterministically from a 64-octet seed.

    +
  • Derives a keypair [publicKey, privateKey] deterministically from a 64-octet seed.

    If an error occurred, throws MlKemError.

    Parameters

    • seed: Uint8Array

      A 64-octet seed for the deterministic key generation.

    Returns Promise<[Uint8Array, Uint8Array]>

    A kaypair [publicKey, privateKey].

    @@ -70,7 +70,7 @@
    // Using jsr:
    import { MlKem768 } from "@dajiaji/mlkem";
    // Using npm:
    // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

    const kyber = new MlKem768();
    const seed = new Uint8Array(64);
    globalThis.crypto.getRandomValues(seed);
    const [pk, sk] = await kyber.deriveKeyPair(seed);
    -
  • Generates a shared secret from the encapsulated ciphertext and the private key.

    +
  • Generates a shared secret from the encapsulated ciphertext and the private key.

    If an error occurred, throws MlKemError.

    Parameters

    • pk: Uint8Array

      A public key.

    • Optionalseed: Uint8Array

      An optional 32-octet seed for the deterministic shared secret generation.

      @@ -79,11 +79,11 @@
      // Using jsr:
      import { MlKem768 } from "@dajiaji/mlkem";
      // Using npm:
      // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

      const kyber = new MlKem768();
      const [pk, sk] = await kyber.generateKeyPair();
      const [ct, ss] = await kyber.encap(pk);
      -
  • Generates a keypair [publicKey, privateKey].

    +
  • Generates a keypair [publicKey, privateKey].

    If an error occurred, throws MlKemError.

    Returns Promise<[Uint8Array, Uint8Array]>

    A kaypair [publicKey, privateKey].

    MlKemError

    // Using jsr:
    import { MlKem768 } from "@dajiaji/mlkem";
    // Using npm:
    // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

    const kyber = new MlKem768();
    const [pk, sk] = await kyber.generateKeyPair();
    -
+
diff --git a/docs/main/classes/MlKem512.html b/docs/main/classes/MlKem512.html index 4083128..a6dd739 100644 --- a/docs/main/classes/MlKem512.html +++ b/docs/main/classes/MlKem512.html @@ -4,7 +4,7 @@
// Using jsr:
import { MlKem512 } from "@dajiaji/mlkem";
// Using npm:
// import { MlKem512 } from "mlkem"; // or "crystals-kyber-js"

const recipient = new MlKem512();
const [pkR, skR] = await recipient.generateKeyPair();

const sender = new MlKem512();
const [ct, ssS] = await sender.encap(pkR);

const ssR = await recipient.decap(ct, skR);
// ssS === ssR
-

Hierarchy

Constructors

Hierarchy

Constructors

Properties

Constructors

Properties

_compressedUSize: number = 0
_compressedVSize: number = 0
_du: number = 10
_dv: number = 4
_eta1: number = 3
_eta2: number = 2
_k: number = 2
_pkSize: number = 0
_skSize: number = 0

Methods

  • Compresses the given array of coefficients into a Uint8Array.

    +

    Returns MlKem512

Properties

_compressedUSize: number = 0
_compressedVSize: number = 0
_du: number = 10
_dv: number = 4
_eta1: number = 3
_eta2: number = 2
_k: number = 2
_pkSize: number = 0
_skSize: number = 0

Methods

  • Compresses the given array of coefficients into a Uint8Array.

    Parameters

    • r: Uint8Array

      The output Uint8Array.

    • u: number[][]

      The array of coefficients.

    Returns Uint8Array

    The compressed Uint8Array.

    -
  • Compresses the given array of numbers into a Uint8Array.

    +
  • Compresses the given array of numbers into a Uint8Array.

    Parameters

    • r: Uint8Array

      The Uint8Array to store the compressed values.

    • v: number[]

      The array of numbers to compress.

    Returns Uint8Array

    The compressed Uint8Array.

    -
  • Decompresses a Uint8Array into a two-dimensional array of numbers.

    +
  • Decompresses a Uint8Array into a two-dimensional array of numbers.

    Parameters

    • a: Uint8Array

      The Uint8Array to decompress.

    Returns number[][]

    The decompressed two-dimensional array.

    -
  • Decompresses a Uint8Array into an array of numbers.

    +
  • Decompresses a Uint8Array into an array of numbers.

    Parameters

    • a: Uint8Array

      The Uint8Array to decompress.

    Returns number[]

    An array of numbers.

    -
  • Internal

    Samples a vector of polynomials from a seed.

    +
  • Internal

    Samples a vector of polynomials from a seed.

    Parameters

    • sigma: Uint8Array

      The seed.

    • offset: number

      The offset.

    • size: number

      The size.

    Returns number[][]

    The sampled vector of polynomials.

    -
  • Generates a 2-dimensional array of noise samples.

    +
  • Generates a 2-dimensional array of noise samples.

    Parameters

    • sigma: Uint8Array

      The noise parameter.

    • offset: number

      The offset value.

    • size: number

      The size of the array.

    Returns number[][]

    The generated 2-dimensional array of noise samples.

    -
  • Generates a ciphertext for the public key and a shared secret.

    +
  • Generates a ciphertext for the public key and a shared secret.

    If an error occurred, throws MlKemError.

    Parameters

    • ct: Uint8Array

      A ciphertext generated by encap.

    • sk: Uint8Array

      A private key.

      @@ -58,7 +58,7 @@
      // Using jsr:
      import { MlKem768 } from "@dajiaji/mlkem";
      // Using npm:
      // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

      const kyber = new MlKem768();
      const [pk, sk] = await kyber.generateKeyPair();
      const [ct, ssS] = await kyber.encap(pk);
      const ssR = await kyber.decap(ct, sk);
      // ssS === ssR
      -
  • Derives a keypair [publicKey, privateKey] deterministically from a 64-octet seed.

    +
  • Derives a keypair [publicKey, privateKey] deterministically from a 64-octet seed.

    If an error occurred, throws MlKemError.

    Parameters

    • seed: Uint8Array

      A 64-octet seed for the deterministic key generation.

    Returns Promise<[Uint8Array, Uint8Array]>

    A kaypair [publicKey, privateKey].

    @@ -66,7 +66,7 @@
    // Using jsr:
    import { MlKem768 } from "@dajiaji/mlkem";
    // Using npm:
    // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

    const kyber = new MlKem768();
    const seed = new Uint8Array(64);
    globalThis.crypto.getRandomValues(seed);
    const [pk, sk] = await kyber.deriveKeyPair(seed);
    -
  • Generates a shared secret from the encapsulated ciphertext and the private key.

    +
  • Generates a shared secret from the encapsulated ciphertext and the private key.

    If an error occurred, throws MlKemError.

    Parameters

    • pk: Uint8Array

      A public key.

    • Optionalseed: Uint8Array

      An optional 32-octet seed for the deterministic shared secret generation.

      @@ -75,11 +75,11 @@
      // Using jsr:
      import { MlKem768 } from "@dajiaji/mlkem";
      // Using npm:
      // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

      const kyber = new MlKem768();
      const [pk, sk] = await kyber.generateKeyPair();
      const [ct, ss] = await kyber.encap(pk);
      -
  • Generates a keypair [publicKey, privateKey].

    +
  • Generates a keypair [publicKey, privateKey].

    If an error occurred, throws MlKemError.

    Returns Promise<[Uint8Array, Uint8Array]>

    A kaypair [publicKey, privateKey].

    MlKemError

    // Using jsr:
    import { MlKem768 } from "@dajiaji/mlkem";
    // Using npm:
    // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

    const kyber = new MlKem768();
    const [pk, sk] = await kyber.generateKeyPair();
    -
+
diff --git a/docs/main/classes/MlKem768.html b/docs/main/classes/MlKem768.html index af760a4..698bba7 100644 --- a/docs/main/classes/MlKem768.html +++ b/docs/main/classes/MlKem768.html @@ -4,7 +4,7 @@
// Using jsr:
import { MlKem768 } from "@dajiaji/mlkem";
// Using npm:
// import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

const recipient = new MlKem768();
const [pkR, skR] = await recipient.generateKeyPair();

const sender = new MlKem768();
const [ct, ssS] = await sender.encap(pkR);

const ssR = await recipient.decap(ct, skR);
// ssS === ssR
-

Hierarchy

Constructors

Hierarchy

Constructors

Properties

_compressedUSize: number = 0
_compressedVSize: number = 0
_du: number = 10
_dv: number = 4
_eta1: number = 2
_eta2: number = 2
_k: number = 3
_pkSize: number = 0
_skSize: number = 0

Methods

  • Compresses the given array of coefficients into a Uint8Array.

    +

Constructors

Properties

_compressedUSize: number = 0
_compressedVSize: number = 0
_du: number = 10
_dv: number = 4
_eta1: number = 2
_eta2: number = 2
_k: number = 3
_pkSize: number = 0
_skSize: number = 0

Methods

  • Compresses the given array of coefficients into a Uint8Array.

    Parameters

    • r: Uint8Array

      The output Uint8Array.

    • u: number[][]

      The array of coefficients.

    Returns Uint8Array

    The compressed Uint8Array.

    -
  • Compresses the given array of numbers into a Uint8Array.

    +
  • Compresses the given array of numbers into a Uint8Array.

    Parameters

    • r: Uint8Array

      The Uint8Array to store the compressed values.

    • v: number[]

      The array of numbers to compress.

    Returns Uint8Array

    The compressed Uint8Array.

    -
  • Decompresses a Uint8Array into a two-dimensional array of numbers.

    +
  • Decompresses a Uint8Array into a two-dimensional array of numbers.

    Parameters

    • a: Uint8Array

      The Uint8Array to decompress.

    Returns number[][]

    The decompressed two-dimensional array.

    -
  • Decompresses a Uint8Array into an array of numbers.

    +
  • Decompresses a Uint8Array into an array of numbers.

    Parameters

    • a: Uint8Array

      The Uint8Array to decompress.

    Returns number[]

    An array of numbers.

    -
  • Generates a 2D array of noise samples.

    +
  • Generates a 2D array of noise samples.

    Parameters

    • sigma: Uint8Array

      The noise parameter.

    • offset: number

      The offset value.

    • size: number

      The size of the array.

    Returns number[][]

    The generated 2D array of noise samples.

    -
  • Generates a 2-dimensional array of noise samples.

    +
  • Generates a 2-dimensional array of noise samples.

    Parameters

    • sigma: Uint8Array

      The noise parameter.

    • offset: number

      The offset value.

    • size: number

      The size of the array.

    Returns number[][]

    The generated 2-dimensional array of noise samples.

    -
  • Generates a ciphertext for the public key and a shared secret.

    +
  • Generates a ciphertext for the public key and a shared secret.

    If an error occurred, throws MlKemError.

    Parameters

    • ct: Uint8Array

      A ciphertext generated by encap.

    • sk: Uint8Array

      A private key.

      @@ -57,7 +57,7 @@
      // Using jsr:
      import { MlKem768 } from "@dajiaji/mlkem";
      // Using npm:
      // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

      const kyber = new MlKem768();
      const [pk, sk] = await kyber.generateKeyPair();
      const [ct, ssS] = await kyber.encap(pk);
      const ssR = await kyber.decap(ct, sk);
      // ssS === ssR
      -
  • Derives a keypair [publicKey, privateKey] deterministically from a 64-octet seed.

    +
  • Derives a keypair [publicKey, privateKey] deterministically from a 64-octet seed.

    If an error occurred, throws MlKemError.

    Parameters

    • seed: Uint8Array

      A 64-octet seed for the deterministic key generation.

    Returns Promise<[Uint8Array, Uint8Array]>

    A kaypair [publicKey, privateKey].

    @@ -65,7 +65,7 @@
    // Using jsr:
    import { MlKem768 } from "@dajiaji/mlkem";
    // Using npm:
    // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

    const kyber = new MlKem768();
    const seed = new Uint8Array(64);
    globalThis.crypto.getRandomValues(seed);
    const [pk, sk] = await kyber.deriveKeyPair(seed);
    -
  • Generates a shared secret from the encapsulated ciphertext and the private key.

    +
  • Generates a shared secret from the encapsulated ciphertext and the private key.

    If an error occurred, throws MlKemError.

    Parameters

    • pk: Uint8Array

      A public key.

    • Optionalseed: Uint8Array

      An optional 32-octet seed for the deterministic shared secret generation.

      @@ -74,11 +74,11 @@
      // Using jsr:
      import { MlKem768 } from "@dajiaji/mlkem";
      // Using npm:
      // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

      const kyber = new MlKem768();
      const [pk, sk] = await kyber.generateKeyPair();
      const [ct, ss] = await kyber.encap(pk);
      -
  • Generates a keypair [publicKey, privateKey].

    +
  • Generates a keypair [publicKey, privateKey].

    If an error occurred, throws MlKemError.

    Returns Promise<[Uint8Array, Uint8Array]>

    A kaypair [publicKey, privateKey].

    MlKemError

    // Using jsr:
    import { MlKem768 } from "@dajiaji/mlkem";
    // Using npm:
    // import { MlKem768 } from "mlkem"; // or "crystals-kyber-js"

    const kyber = new MlKem768();
    const [pk, sk] = await kyber.generateKeyPair();
    -
+
diff --git a/docs/main/classes/MlKemError.html b/docs/main/classes/MlKemError.html index 3a2d60d..dc4c1f9 100644 --- a/docs/main/classes/MlKemError.html +++ b/docs/main/classes/MlKemError.html @@ -1,7 +1,7 @@ MlKemError | API reference for crystals-kyber-js/main

The base error class of kyber-ts.

-

Hierarchy

  • Error
    • MlKemError

Constructors

Hierarchy

  • Error
    • MlKemError

Constructors

Properties

Constructors

Properties

cause?: unknown
message: string
name: string
stack?: string
+

Constructors

Properties

cause?: unknown
message: string
name: string
stack?: string