this.signature = result.signature
} else {
const key = input ?? this.account.privateKey
- if (!key) {
+ if (key == null) {
throw new Error('No valid key found to sign block')
}
+ const account = await Account.fromPrivateKey(key)
+ try {
const signature = Ed25519.sign(
hex.toBytes(await this.hash()),
- hex.toBytes(key)
+ hex.toBytes(`${account.privateKey}${account.publicKey}`)
)
- this.signature = bytes.toHex(signature)
+ this.signature = bytes.toHex(signature.subarray(0, 64))
+ } catch (err) {
+ throw new Error(`Failed to sign block with key ${key}: ${err}`)
+ }
}
}
const signature = Ed25519.sign(
hex.toBytes(data),
hex.toBytes(key))
- return bytes.toHex(signature)
+ return bytes.toHex(signature.subarray(0, 64))
}
/**