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 result:', proof1);
console.log('Bootstrap result keys:', Object.keys(proof1));
console.log('Bootstrap result type:', typeof proof1);
// Let's also check what the documentation example shows
console.log('\n--- Testing documentation example ---');
const mainDevice = device1;
const auxillaryDevice = device2;
const proof0 = identityKey.bootstrap(mainDevice.publicKey);
console.log('proof0:', proof0);
// Try the documentation example approach
const proof = IdentityKey.attestDevice(auxillaryDevice.publicKey, mainDevice, proof0);
console.log('AttestDevice successful:', proof);
} catch (error) {
console.error('Error:', error.message);
console.error('Stack:', error.stack);
}
}
test();