import test from 'node:test'
import assert from 'node:assert/strict'
import { generateKeyPairSync } from 'node:crypto'
import { signManifest, verifyManifestSignature } from './release-signature.mjs'

test('release signature signs and verifies an Ed25519 manifest payload', () => { const { privateKey, publicKey } = generateKeyPairSync('ed25519'); const privatePem = privateKey.export({ format: 'pem', type: 'pkcs8' }); const publicPem = publicKey.export({ format: 'pem', type: 'spki' }); const payload = '{"release":"fixture"}'; const signature = signManifest(payload, privatePem, 'fixture-key'); assert.equal(signature.status, 'signed'); assert.equal(signature.algorithm, 'Ed25519'); assert.equal(verifyManifestSignature(payload, signature, publicPem), true); assert.equal(verifyManifestSignature(`${payload}x`, signature, publicPem), false) })
