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