// seedqr.test.ts import { describe, it, expect } from "bun:test"; import { encodeStandardSeedQR, encodeCompactSeedQREntropy } from './seedqr'; describe('SeedQR encoding (SeedSigner test vectors)', () => { it('encodes 24-word seed to correct Standard SeedQR digit stream (Test Vector 3)', async () => { const mnemonic = 'sound federal bonus bleak light raise false engage round stock update render quote truck quality fringe palace foot recipe labor glow tortoise potato still'; const expectedDigitStream = '166206750203018810361417065805941507171219081456140818651401074412730727143709940798183613501710'; const result = await encodeStandardSeedQR(mnemonic); expect(result).toBe(expectedDigitStream); }); it('encodes 12-word seed to correct Standard and Compact SeedQR (Test Vector 4)', async () => { const mnemonic = 'forum undo fragile fade shy sign arrest garment culture tube off merit'; const expectedStandardDigitStream = '073318950739065415961602009907670428187212261116'; const expectedCompactBitStream = '01011011101111011001110101110001101010001110110001111001100100001000001100011010111111110011010110011101010000100110010101000101'; const standard = await encodeStandardSeedQR(mnemonic); expect(standard).toBe(expectedStandardDigitStream); const compactEntropy = await encodeCompactSeedQREntropy(mnemonic); const bitString = Array.from(compactEntropy) .map((byte) => byte.toString(2).padStart(8, '0')) .join(''); expect(bitString).toBe(expectedCompactBitStream); }); });