eleven / ocho Public

Clone
git clone https://amadan.net/eleven/ocho

Plain git — no account needed to clone.

Download

Download this file

1// đŸ¤– Regenerates the cross-implementation home-blob vector that
2// ios/LChatCore/Tests/LChatCoreTests/HomeCryptoVectors.swift embeds (and
3// HomeCryptoTests.swift opens): a JS-sealed envelope with a FIXED DEK and
4// wrapped-DEK map, so Swift proving it opens byte-for-byte pins the KEK
5// derivation, AES-GCM layout, padding and framing across implementations.
6//
7// node home/test/gen-home-vector.mjs
8//
9// Paste the printed envelope into HomeCryptoVectors.swift, and refresh the Go
10// copy: node home/test/gen-home-vector.mjs > internal/client/testdata/home-vector.txt
11// (internal/client/home_test.go opens it with the same fixed DEK). The inputs (prf,
12// dekRaw, credId, wrapped) are constants in HomeCryptoTests.swift — keep them
13// in sync if you ever change them here. The envelope bytes differ per run
14// (fresh AES-GCM iv); that's fine, only the opened contents are asserted.
15import { importDEK, sealBlob, bytesToB64url } from "../web/static/crypto.js";
16
17const dekRaw = "AAcOFRwjKjE4P0ZNVFtiaXB3foWMk5qhqK-2vcTL0tk";
18const credId = "cred-abc";
19const wrapped = "LfDy9OjW1vWNWfVcpShcxANG7mcWIpsrDtS2yrlhic7KwdN1abiQIF8zOg7EdHF5p9oaI0f09LGg_Wvl";
20
21const dek = await importDEK(dekRaw);
22const obj = { v: 1, servers: [{ url: "https://test.example.com", name: "Test" }] };
23const envelope = await sealBlob(obj, dek, { [credId]: wrapped });
24console.log(bytesToB64url(envelope));
25