* The actual message signed is a string which can be expressed as the
* following template literal:
*
- * `Nano Signed Nonce:\n${nonceBytes}`
+ * `Nano Signed Nonce:\n${nonce_bytes_as_hex}`
*
* IMPORTANT: The current version of the Nano app for Ledger devices will NOT
* prompt users to confirm the signature. If valid, the nonce will immediately
static async verify (secret: string): Promise<boolean> {
const testWallet = await Wallet.load('BIP-44', '', secret)
secret = ''
+ const nonce = crypto.randomUUID().slice(-16)
try {
await testWallet.unlock('')
- const { address, publicKey } = await testWallet.account(0)
- const testOpenBlock = await new Block(address, '0', publicKey, address)
- .receive(publicKey, 0)
- .sign(testWallet, 0)
- const testSendBlock = await new Block(address, '0', testOpenBlock.hash, address)
- .send(address, 0)
- .sign(testWallet, 0)
- const testSignature = testSendBlock.signature
- testSendBlock.signature = undefined
+ const testSignature = await testWallet.sign(0, `Nano Signed Nonce:\n${utf8.toHex(nonce)}`)
try {
- const ledgerSignature = await this.sign(0, testSendBlock, testOpenBlock)
+ const ledgerSignature = await this.sign(0, nonce)
return ledgerSignature === testSignature
} catch (err) {
throw new Error('Failed to verify wallet', { cause: err })
/**
* Sign a nonce with the Ledger device.
*
- * nonce signing is currently broken: https://github.com/LedgerHQ/app-nano/pull/14
- *
* @param {number} index - Account number
* @param {Uint8Array} nonce - 128-bit value to sign
* @returns {Promise} Status and signature
* actual message signed is a string which can be expressed as the following\r
* template literal:\r
*\r
- * `Nano Signed Nonce:\n${nonceBytes}`\r
+ * `Nano Signed Nonce:\n${nonce_bytes_as_hex}`\r
*\r
* IMPORTANT: The current version of the Nano app for Ledger devices will NOT\r
* prompt users to confirm the signature. If valid, the nonce will immediately\r