testUncompressedKeysAreCompressed
tcmts.atproto.test.testUncompressedKeysAreCompressed · #hig3ungo · term
import { compressedKey } from "#codebase/tcmts/atproto";
export const testUncompressedKeysAreCompressed = () => {
const x = Array.from({ length: 32 }, (_, i) => i + 1);
const odd = compressedKey(new Uint8Array([4, ...x, ...x.slice(0, 31), 7]));
const even = compressedKey(new Uint8Array([4, ...x, ...x.slice(0, 31), 8]));
if (odd.length !== 33 || odd[0] !== 3 || odd[1] !== 1 || odd[32] !== 32)
throw new Error(`odd y: ${odd}`);
if (even[0] !== 2) throw new Error(`even y: ${even}`);
const already = new Uint8Array([2, ...x]);
if (compressedKey(already) !== already) throw new Error("a compressed key is kept as it is");
}
uses