Options
All
  • Public
  • Public/Protected
  • All
Menu

NewHope provides post-quantum Ring-LWE-based key exchange between two peers.

One peer generates an "offer message"" by calling offer(), and sends it to the other peer. The other peer accepts the offer and generates "accept message" by calling accept() with the received offer message. It then send the result to the first peer, which calls finish(). After completing these steps, both peers call getSharedKey() to get the established shared key.

This is a reference version, which uses SHAKE-128 and SHA-3-256. You can create a custom version by requiring "lib/custom" and extending CustomNewHope class.

Reference:

Erdem Alkim, Léo Ducas, Thomas Pöppelmann, and Peter Schwabe: Post-quantum key exchange – a new hope.

https://cryptojedi.org/papers/#newhope

Hierarchy

  • CustomNewHope
    • NewHope

Index

Constructors

  • new NewHope(secretSeed?: Uint8Array, prng?: RandomSource): NewHope
  • Parameters

    • Optional secretSeed: Uint8Array
    • Optional prng: RandomSource

    Returns NewHope

Properties

acceptMessageLength: number = ACCEPT_MESSAGE_LENGTH
offerMessageLength: number = OFFER_MESSAGE_LENGTH
savedStateLength: number = SAVED_STATE_LENGTH
sharedKeyLength: number

Methods

  • accept(offerMsg: Uint8Array): Uint8Array
  • Checks the offer message and returns an accept message.

    Parameters

    • offerMsg: Uint8Array

    Returns Uint8Array

  • clean(): void
  • finish(acceptMsg: Uint8Array): NewHope
  • Checks the accept message and generates shared key, which can be retrieved using getSharedKey().

    Parameters

    • acceptMsg: Uint8Array

    Returns NewHope

  • getSharedKey(): Uint8Array
  • offer(seed?: Uint8Array): Uint8Array
  • Returns an offer message.

    Optional public seed must have PUBLIC_SEED_LENGTH random bytes. If not provided, it's generated using randomBytes.

    Parameters

    • seed: Uint8Array = ...

    Returns Uint8Array

  • restoreState(serializedState: Uint8Array): NewHope
  • saveState(): Uint8Array

Generated using TypeDoc