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

18 lines 901 B
import json from "../../test_vectors/psk_secret.json"; import { getCiphersuiteFromId, getCiphersuiteImpl } from "../../src/crypto/ciphersuite"; import { computePskSecret } from "../../src/presharedkey"; import { bytesToHex, hexToBytes } from "@noble/ciphers/utils"; for (const [index, x] of json.entries()) { test(`psk_secret test vectors ${index}`, async () => { const impl = await getCiphersuiteImpl(getCiphersuiteFromId(x.cipher_suite)); await testPskSecret(x.psk_secret, x.psks, impl); }); } function toExternalPsk(p) { return [{ psktype: "external", pskId: hexToBytes(p.psk_id), pskNonce: hexToBytes(p.psk_nonce) }, hexToBytes(p.psk)]; } async function testPskSecret(secret, psks, impl) { const computedSecret = await computePskSecret(psks.map(toExternalPsk), impl); expect(bytesToHex(computedSecret)).toBe(secret); } //# sourceMappingURL=pskSecret.test.js.map