Skip to content

Commit 9a05705

Browse files
committed
low-level-api: prefix getPublicKey validation message
Add prefix "dummy-data:" as required since app version 2.0 to avoid the risks of blind signing.
1 parent fd4a48d commit 9a05705

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/low-level-api/low-level-api.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@ export default class LowLevelApi {
144144
}
145145

146146
const pathBuffer = parsePath(path);
147-
const verifyMsg = Buffer.from('p=np?', 'ascii');
148-
const data = boolValidate ? Buffer.concat([pathBuffer, verifyMsg]) : pathBuffer;
147+
// Validation message including prefix "dummy-data:" as required since app version 2.0 to avoid the risks of
148+
// blind signing.
149+
const validationMessage = Buffer.from('dummy-data:p=np?', 'ascii');
150+
const data = boolValidate ? Buffer.concat([pathBuffer, validationMessage]) : pathBuffer;
149151

150152
let response: Buffer;
151153
response = await this._transport.send(
@@ -167,7 +169,7 @@ export default class LowLevelApi {
167169
offset += 32;
168170
if (boolValidate) {
169171
const signature = response.slice(offset, offset + 64);
170-
if (!await verifySignature(verifyMsg, signature, publicKey, nimiqVersion)) {
172+
if (!await verifySignature(validationMessage, signature, publicKey, nimiqVersion)) {
171173
throw new Error(
172174
'Bad signature. Keypair is invalid. Please report this.',
173175
);
@@ -291,7 +293,7 @@ export default class LowLevelApi {
291293
* Sign a message with a Nimiq key.
292294
* @param path - A path in BIP 32 format.
293295
* @param message - Message to sign as utf8 string or arbitrary bytes.
294-
* @param flags - Flags to pass. Currently supported: `preferDisplayTypeHex` and `preferDisplayTypeHash`.
296+
* @param [flags] - Flags to pass. Currently supported: `preferDisplayTypeHex` and `preferDisplayTypeHash`.
295297
* @returns An object with the signature.
296298
* @example
297299
* nim.signMessage("44'/242'/0'/0'", message).then(o => o.signature)

0 commit comments

Comments
 (0)