Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CustomNewHope

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

This is a reference version, which uses SHA3. See newhopeaessha module for the BoringSSL-compatible implementation, which uses AES-SHA256.

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.

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

Implements

  • KeyAgreement

Index

Constructors

constructor

Properties

acceptMessageLength

acceptMessageLength: number = ACCEPT_MESSAGE_LENGTH

offerMessageLength

offerMessageLength: number = OFFER_MESSAGE_LENGTH

savedStateLength

savedStateLength: number = SAVED_STATE_LENGTH

sharedKeyLength

sharedKeyLength: number

Methods

accept

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

    Parameters

    • offerMsg: Uint8Array

    Returns Uint8Array

clean

  • clean(): void

finish

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

    Parameters

    • acceptMsg: Uint8Array

    Returns this

getSharedKey

  • getSharedKey(): Uint8Array

offer

  • 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

    • Default value seed: Uint8Array = randomBytes(PUBLIC_SEED_LENGTH, this._prng)

    Returns Uint8Array

restoreState

  • restoreState(serializedState: Uint8Array): this

saveState

  • saveState(): Uint8Array

Generated using TypeDoc