verify-layer: verify-consistency names the signer of each head (or unsigned); identity: Travel Rule requires a replay store

- verify-consistency without --signer now says whether each head is signed and by which key, and that no expected signer was
  checked (verify-inclusion already did; the README said the output does)
- openMessage opens nothing without a replay store (seen: an object with has/add that keeps the ids for at least maxAgeS);
  before, the same signed and sealed message could be opened any number of times when no store was given

Tests: verify-layer tree 20/20, negative control 14/14; sidecar 44/44, 9/9; travel rule 19/19, negative control 19/19.
This commit is contained in:
Aere Network committed 2026-09-30 10:31:23 +03:00
1 parent 082b862d78
commit 8f5f0bd00d
9 files changed
+57 -14

No files matched your search

+8 -3
View File
@@ -35,7 +35,7 @@ const bindB = TR.bindKemKeys({ vasp: B, kem: kemB, validUntil: '2026-12-31T00:00
const accB = TR.acceptBeneficiary({ binding: bindB, presentation: pres(credB, B, A.id, 'n-acc'), registries: [reg.id], originatorId: A.id, nonce: 'n-acc', now: NOW, statusLists: [LISTA] });
const MID = 'urn:uuid:11111111-2222-4333-8444-555555555555';
const sigileaza = (o = {}) => TR.sealMessage({ from: A, beneficiary: accB.beneficiary, ivms101: IVMS, transfer: TRANSFER, presentation: pres(credA, A, B.id, MID), messageId: MID, now: NOW, ...o });
const deschide = (m, o = {}) => TR.openMessage(m, { me: B.id, kem: kemB, registries: [reg.id], now: NOW, statusLists: [LISTA], ...o });
const deschide = (m, o = {}) => TR.openMessage(m, { me: B.id, kem: kemB, registries: [reg.id], now: NOW, statusLists: [LISTA], seen: new Set(), ...o });
const are = (r, re) => !r.ok && r.motive.some((x) => re.test(x));
// ---------------------------------------------------------------- beneficiarul acceptat
@@ -99,8 +99,8 @@ test('ATAC: mesaj semnat de un strain in numele lui A -> refuzat; semnatura lui
const m2 = clon(M); m2.signature = I.signText('kem-binding', text, A); cere(are(deschide(m2), /not signed by the originator/), 'alt scop a trecut');
});
test('ATAC: alt VASP (C) incearca sa deschida mesajul lui B -> refuzat; cu cheile lui KEM in numele lui B -> refuzat', () => {
cere(are(TR.openMessage(M, { me: C.id, kem: kemC, registries: [reg.id], now: NOW, statusLists: [LISTA] }), /is for/), 'C l-a deschis');
cere(are(TR.openMessage(M, { me: B.id, kem: kemC, registries: [reg.id], now: NOW, statusLists: [LISTA] }), /other KEM keys/), 'cheile lui C au trecut');
cere(are(TR.openMessage(M, { me: C.id, kem: kemC, registries: [reg.id], now: NOW, statusLists: [LISTA], seen: new Set() }), /is for/), 'C l-a deschis');
cere(are(TR.openMessage(M, { me: B.id, kem: kemC, registries: [reg.id], now: NOW, statusLists: [LISTA], seen: new Set() }), /other KEM keys/), 'cheile lui C au trecut');
});
test('KEM hibrid: fara secretul ML-KEM corect (cheia X25519 buna) sau fara cel X25519 (ML-KEM bun), mesajul nu se descifreaza', () => {
const k1 = { public: kemB.public }; Object.defineProperty(k1, 'privat', { value: { x25519: kemB.privat.x25519, mlkem768: kemC.privat.mlkem768 } });
@@ -108,6 +108,11 @@ test('KEM hibrid: fara secretul ML-KEM corect (cheia X25519 buna) sau fara cel X
const r1 = deschide(M, { kem: k1 }), r2 = deschide(M, { kem: k2 });
cere(!r1.ok && !r2.ok && r1.motive.concat(r2.motive).every((x) => /modified|does not open/.test(x)), r1.motive.concat(r2.motive).join(' | '));
});
// B-26 (2026-09-30, revizuirea adversariala): fara magazia de reluare, acelasi mesaj se deschidea de oricate ori
test('B-26: fara magazia de reluare (seen lipsa sau fara has/add) nu se deschide nimic', () => {
cere(are(deschide(M, { seen: undefined }), /no replay store/), 'fara seen s-a deschis');
cere(are(deschide(M, { seen: {} }), /no replay store/), 'un obiect fara has/add a trecut drept magazie');
});
test('ATAC: acelasi mesaj primit a doua oara (reluare) -> refuzat; un mesaj vechi (301 s) -> refuzat', () => {
const seen = new Set(); cere(deschide(M, { seen }).ok, 'prima deschidere');
cere(are(deschide(M, { seen }), /replay/), 'reluarea a trecut');