Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "x25519/x25519"

Index

Variables

ACCEPT_MESSAGE_LENGTH

ACCEPT_MESSAGE_LENGTH: 32 = PUBLIC_KEY_LENGTH

OFFER_MESSAGE_LENGTH

OFFER_MESSAGE_LENGTH: 32 = PUBLIC_KEY_LENGTH

Constants for key agreement

PUBLIC_KEY_LENGTH

PUBLIC_KEY_LENGTH: 32 = 32

SAVED_STATE_LENGTH

SAVED_STATE_LENGTH: 32 = SECRET_KEY_LENGTH

SECRET_KEY_LENGTH

SECRET_KEY_LENGTH: 32 = 32

SECRET_SEED_LENGTH

SECRET_SEED_LENGTH: 32 = SECRET_KEY_LENGTH

SHARED_KEY_LENGTH

SHARED_KEY_LENGTH: 32 = 32

Functions

generateKeyPair

  • generateKeyPair(prng?: RandomSource): KeyPair

generateKeyPairFromSeed

  • generateKeyPairFromSeed(seed: Uint8Array): KeyPair

scalarMult

  • scalarMult(n: Uint8Array, p: Uint8Array): Uint8Array

scalarMultBase

  • scalarMultBase(n: Uint8Array): Uint8Array

sharedKey

  • sharedKey(mySecretKey: Uint8Array, theirPublicKey: Uint8Array, rejectZero?: boolean): Uint8Array
  • Returns a shared key between our secret key and a peer's public key.

    Throws an error if the given keys are of wrong length.

    If rejectZero is true throws if the calculated shared key is all-zero. From RFC 7748:

    Protocol designers using Diffie-Hellman over the curves defined in this document must not assume "contributory behaviour". Specially, contributory behaviour means that both parties' private keys contribute to the resulting shared key. Since curve25519 and curve448 have cofactors of 8 and 4 (respectively), an input point of small order will eliminate any contribution from the other party's private key. This situation can be detected by checking for the all- zero output, which implementations MAY do, as specified in Section 6. However, a large number of existing implementations do not do this.

    Important: the returned key is a raw result of scalar multiplication. To use it as a key material, hash it with a cryptographic hash function.

    Parameters

    • mySecretKey: Uint8Array
    • theirPublicKey: Uint8Array
    • Default value rejectZero: boolean = false

    Returns Uint8Array

Generated using TypeDoc