@@ -1,5 +1,5 @@
1+import { crypto } from 'bitcoinjs-lib';
12import { ecdsaSign } from 'secp256k1';
2−import { keccak256 } from 'web3-utils';
33
44import { WALLET_TYPES } from './constants';
55import { ledgerSignMessage } from './ledger';
@@ -9,13 +9,9 @@ const MESSAGE = 'Bridge Authentication Token';
99
1010function signMessage(privateKey: Buffer) {
1111 const msg = '\x19Ethereum Signed Message:\n' + MESSAGE.length + MESSAGE;
12− // TODO: Signing function expects 32 length Buffer,
13− // confirm if it is okay / expected to slice it like this?
14− // Based on reading docs and comment threads, it seems that
15− // this limit is sometimes enforced, and varies depending on
16− // the implementation
17− const msgHash = Buffer.from(keccak256(msg)).slice(0, 32);
18− const { signature } = ecdsaSign(msgHash, privateKey);
12+ // #ecdsaSign requires a 32-byte buffer, hence sha256
13+ const hashed = crypto.sha256(Buffer.from(msg));
14+ const { signature } = ecdsaSign(Buffer.from(hashed), privateKey);
1915
2016 // add key recovery parameter
2117 const ethSignature = new Uint8Array(65);