Skip to content

Commit

Permalink
Fixes #17719
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardBraham committed Feb 21, 2023
1 parent 0223757 commit 87a1638
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/scripts/account-import-strategies/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { isValidMnemonic } from '@ethersproject/hdnode';
import { bufferToHex, isValidPrivate, toBuffer } from 'ethereumjs-util';
import {
bufferToHex,
getBinarySize,
isValidPrivate,
toBuffer,
} from 'ethereumjs-util';
import Wallet from 'ethereumjs-wallet';
import importers from 'ethereumjs-wallet/thirdparty';
import log from 'loglevel';
Expand Down Expand Up @@ -35,7 +40,10 @@ const accountImporter = {
}

try {
if (!isValidPrivate(buffer)) {
if (
!isValidPrivate(buffer) ||
getBinarySize(trimmedPrivateKey) !== 64 // isValidPrivate() will let a key of 63 hex digits through without complaining
) {
throw new Error(`t('importAccountErrorNotAValidPrivateKey')`);
}
} catch (e) {
Expand Down

0 comments on commit 87a1638

Please sign in to comment.