Package keyagreement provides interface for key agreement.

interface KeyAgreement {
    acceptMessageLength: number;
    offerMessageLength: number;
    savedStateLength: number;
    sharedKeyLength: number;
    accept(offerMsg: Uint8Array): Uint8Array;
    clean(): void;
    finish(acceptMsg: Uint8Array): this;
    getSharedKey(): Uint8Array;
    offer(): Uint8Array;
    restoreState(serializedState: Uint8Array): this;
    saveState(): Uint8Array;
}

Implemented by

    Properties

    acceptMessageLength: number

    Accept message length in bytes

    offerMessageLength: number

    Offer message length in bytes

    savedStateLength: number

    Saved state length in bytes *

    sharedKeyLength: number

    Shared key length in bytes *

    Methods

    • Accept offer message and return new accept message, which should be sent back to the offering party.

      Also derives shared key, so the accepting party can call getSharedKey() right after calling accept.

      Parameters

      • offerMsg: Uint8Array

      Returns Uint8Array

    • Cleans the temporary instance data.

      Returns void

    • Offering party finishes key agreement by receiving accept message and passing it to finish(). After calling finish(), offering party can call sharedKey() to get shared key.

      Parameters

      • acceptMsg: Uint8Array

      Returns this

    • Returns the agreed shared key.

      • Offering party should call this after finish().
      • Accepting party should call this after accept().

      Returns Uint8Array

    • Offer returns a new offer message, which should be send to the accepting party.

      Returns Uint8Array

    • Restores offering party's state.

      Parameters

      • serializedState: Uint8Array

      Returns this

    • Serializes secret offering party state into byte array.

      This function should be called after offer() if the offering party cannot keep KeyAgreement instance in memory. When it receives accept message, it can create a new instance and call restoreState() on it with the serialized state to recover to continue the agreement.

      Returns Uint8Array