import IdentityKey from 'keet-identity-key';
import { CryptoManager } from './lib/crypto.js';
async function test() {
try {
// Generate a test mnemonic and identity
const mnemonic = IdentityKey.generateMnemonic();
const identityKey = await IdentityKey.from({ mnemonic });
// Generate two device keypairs
const device1 = CryptoManager.generateRawDeviceKeyPair();
const device2 = CryptoManager.generateRawDeviceKeyPair();
// Bootstrap first device
const proof1 = identityKey.bootstrap(device1.publicKey);
console.log('Bootstrap successful, proof type:', typeof proof1);
console.log('Bootstrap proof is Buffer:', Buffer.isBuffer(proof1));
// Try to attest second device
const proof2 = IdentityKey.attestDevice(device2.publicKey, device1, proof1);
console.log('AttestDevice successful, proof type:', typeof proof2);
console.log('AttestDevice proof is Buffer:', Buffer.isBuffer(proof2));
} catch (error) {
console.error('Error:', error.message);
console.error('Stack:', error.stack);
}
}
test();