Skip to content

Commit 5ff999c

Browse files
authored
fix noble hash keccak256 usage (#1406)
* fix noble hash keccak256 usage * fix test and implementation
1 parent 2fa77b4 commit 5ff999c

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

packages/wallet-sdk/src/sign/walletlink/WalletLinkSigner.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ describe('LegacyProvider', () => {
208208
const sendRequestSpy = jest.spyOn(relay, 'sendRequest');
209209
const provider = createAdapter({ relay });
210210

211-
const ENCODED_MESSAGE = '0xb7845733ba102a68c6eb21c3cd2feafafd1130de581d7e73be60b76d775b6704';
211+
const ENCODED_MESSAGE = '0x421b6e328c574f0ee83a68d51d01be3597d8b5391c7725dfa80247a60b5cd390';
212212
const ENCODED_TYPED_DATA_JSON = JSON.stringify(MOCK_TYPED_DATA);
213213

214214
beforeEach(() => {

packages/wallet-sdk/src/vendor-js/eth-eip712-util/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* eslint-disable */
2+
//prettier-ignore
3+
14
const util = require('./util')
25
const abi = require('./abi')
36

packages/wallet-sdk/src/vendor-js/eth-eip712-util/util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ function bufferToHex (buf) {
138138
function keccak (a, bits) {
139139
a = toBuffer(a)
140140
if (!bits) bits = 256
141-
142-
return Buffer.from(keccak_256('keccak' + bits))
141+
if (bits !== 256) {
142+
throw new Error('unsupported')
143+
}
144+
return Buffer.from(keccak_256(new Uint8Array(a)))
143145
}
144146

145147
function padToEven (str) {

0 commit comments

Comments
 (0)