UNPKG

ts-mls

Version:

[![CI](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml/badge.svg)](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [![npm version](https://badge.fury.io/js/ts-mls.svg)](https://badge.fury.io/js/ts-mls) [![Coverage Status](https://co

22 lines 1.12 kB
import { getHpkePublicKey } from "../../src/ratchetTree"; export async function hpkeKeysMatch(publicKey, privateKey, hpke) { const encoder = new TextEncoder(); const plaintext = encoder.encode("test"); const info = encoder.encode("key check"); const { ct, enc } = await hpke.seal(await hpke.importPublicKey(publicKey), plaintext, info); const decrypted = await hpke.open(await hpke.importPrivateKey(privateKey), enc, ct, info); return new TextDecoder().decode(decrypted) === "test"; } export async function signatureKeysMatch(publicKey, privateKey, s) { const testMessage = new TextEncoder().encode("test"); const signature = await s.sign(privateKey, testMessage); return s.verify(publicKey, testMessage, signature); } export async function checkHpkeKeysMatch(group, impl) { for (const [nodeIndex, privateKey] of Object.entries(group.privatePath.privateKeys)) { const pub = getHpkePublicKey(group.ratchetTree[Number(nodeIndex)]); const x = await hpkeKeysMatch(pub, privateKey, impl.hpke); expect(x).toBe(true); } } //# sourceMappingURL=keyMatch.js.map