An unestablished HPKE recipient session.

This class is used to start the establishment of a HPKE session. The other side of the session can be established using the HpkeSenderChannel.

The HPKE recipient channel can be used to implement the QR code generating side of the secure channel from [MSC4388].

const alice = new HpkeSenderChannel();
const bob = new HpkeRecipientChannel();

let aad = "AAD";
let aadBytes = new TextEncoder().encode(aad);

const { message, channel: aliceUnidirectional } = alice.establishChannel(
bob.publicKey,
"It's a secret to everybody",
aadBytes,
);

const { message: initialMessage, channel: bobUnidirectional } = bob.establishChannel(message, aadBytes);

let aadTwo = "AADTWO";
let aadTwoBytes = new TextEncoder().encode(aad);

const { initialResponse, channel: bobEstablished } = bobUnidirectional.establishBidirectionalChannel(
"Initial response",
aadTwoBytes,
);
const { initialResponse: secondPlaintext, channel: aliceEstablished } =
aliceUnidirectional.establishBidirectionalChannel(initialResponse, aadTwoBytes);

const aliceCheck = aliceEstablished.checkCode;
const bobCheck = bobEstablished.checkCode;

// Compare the check codes here and only proceed if they match.

const ciphertext = bobEstablished.seal("Other message", []);
const thirdPlaintext = aliceEstablished.open(ciphertext, []);

expect(thirdPlaintext).toStrictEqual("Other message");

Constructors

Properties

Methods

Constructors

Properties

Get our Curve25519PublicKey.

This public key needs to be sent to the other side to be able to establish an HPKE channel.

Methods

  • Returns void

  • Returns void