Skip to content

Commit

Permalink
fix noble hash keccak256 usage (#1406)
Browse files Browse the repository at this point in the history
* fix noble hash keccak256 usage

* fix test and implementation
  • Loading branch information
cb-jake authored Sep 24, 2024
1 parent 2fa77b4 commit 5ff999c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe('LegacyProvider', () => {
const sendRequestSpy = jest.spyOn(relay, 'sendRequest');
const provider = createAdapter({ relay });

const ENCODED_MESSAGE = '0xb7845733ba102a68c6eb21c3cd2feafafd1130de581d7e73be60b76d775b6704';
const ENCODED_MESSAGE = '0x421b6e328c574f0ee83a68d51d01be3597d8b5391c7725dfa80247a60b5cd390';
const ENCODED_TYPED_DATA_JSON = JSON.stringify(MOCK_TYPED_DATA);

beforeEach(() => {
Expand Down
3 changes: 3 additions & 0 deletions packages/wallet-sdk/src/vendor-js/eth-eip712-util/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable */
//prettier-ignore

const util = require('./util')
const abi = require('./abi')

Expand Down
6 changes: 4 additions & 2 deletions packages/wallet-sdk/src/vendor-js/eth-eip712-util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ function bufferToHex (buf) {
function keccak (a, bits) {
a = toBuffer(a)
if (!bits) bits = 256

return Buffer.from(keccak_256('keccak' + bits))
if (bits !== 256) {
throw new Error('unsupported')
}
return Buffer.from(keccak_256(new Uint8Array(a)))
}

function padToEven (str) {
Expand Down

0 comments on commit 5ff999c

Please sign in to comment.