/** * TAP SDK — Crypto Module * * BLS12-381 signatures for cryptographic attestations. * * @example * ```typescript * import { generateKeypair, signAttestation, verifyAttestation } from '@moltos/tap-sdk/crypto'; * * // Generate keys * const { privateKey, publicKey } = generateKeypair(); * * // Sign attestation * const signed = signAttestation({ * agentId: 'agent_001', * targetId: 'agent_002', * score: 85, * timestamp: Date.now(), * nonce: 'random-nonce' * }, privateKey); * * // Verify * const valid = verifyAttestation(signed); * ``` */ interface BLSPublicKey { type: 'BLS12_381'; bytes: Uint8Array; toHex(): string; } interface BLSPrivateKey { bytes: Uint8Array; toHex(): string; } interface BLSSignature { type: 'BLS12_381'; bytes: Uint8Array; toHex(): string; aggregate(other: BLSSignature): BLSSignature; } interface AttestationPayload { agentId: string; targetId: string; score: number; timestamp: number; nonce: string; metadata?: Record; } interface SignedAttestation { payload: AttestationPayload; signature: BLSSignature; publicKey: BLSPublicKey; proof: { type: 'bls12_381'; scheme: 'basic' | 'proof_of_possession'; }; } /** * Enable/disable stub mode (for testing without real BLS) */ declare function setStubMode(enabled: boolean): void; /** * Check if running in stub mode */ declare function isStubMode(): boolean; /** * Generate new BLS keypair * * NOTE: Currently returns stub keys. Real BLS12-381 coming in v0.2. */ declare function generateKeypair(): { privateKey: BLSPrivateKey; publicKey: BLSPublicKey; mnemonic: string; }; /** * Derive keypair from mnemonic */ declare function deriveKeypair(mnemonic: string, path?: string): { privateKey: BLSPrivateKey; publicKey: BLSPublicKey; }; /** * Hash payload for signing */ declare function hashPayload(payload: AttestationPayload): Uint8Array; /** * Sign attestation payload */ declare function signAttestation(payload: AttestationPayload, privateKey: BLSPrivateKey): SignedAttestation; /** * Verify attestation signature * * NOTE: In stub mode, always returns true with console warning. */ declare function verifyAttestation(signed: SignedAttestation): boolean; /** * Batch verify multiple attestations */ declare function batchVerifyAttestations(attestations: SignedAttestation[]): { valid: boolean[]; allValid: boolean; }; /** * Aggregate multiple signatures into one * * BLS allows aggregating signatures from different signers * into a single signature that can be verified efficiently. */ declare function aggregateSignatures(signatures: Array): BLSSignature; /** * Verify aggregated signature */ declare function verifyAggregate(message: Uint8Array, aggregateSig: BLSSignature, publicKeys: BLSPublicKey[]): boolean; declare const _default: { generateKeypair: typeof generateKeypair; deriveKeypair: typeof deriveKeypair; signAttestation: typeof signAttestation; verifyAttestation: typeof verifyAttestation; batchVerifyAttestations: typeof batchVerifyAttestations; aggregateSignatures: typeof aggregateSignatures; verifyAggregate: typeof verifyAggregate; hashPayload: typeof hashPayload; setStubMode: typeof setStubMode; isStubMode: typeof isStubMode; }; export { type AttestationPayload, type BLSPrivateKey, type BLSPublicKey, type BLSSignature, type SignedAttestation, aggregateSignatures, batchVerifyAttestations, _default as default, deriveKeypair, generateKeypair, hashPayload, isStubMode, setStubMode, signAttestation, verifyAggregate, verifyAttestation };