Skip to content

Commit c8908ea

Browse files
authored
VM, Block: large ChainID ecrecover fixes (#1139)
* vm: fixed ecrecover call in ECRECOVER precompile for large chain IDs * block: fixed cliqueSigner() address recovery from signature for large chain IDs
1 parent 2e77693 commit c8908ea

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

packages/block/src/header.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
toBuffer,
1414
unpadBuffer,
1515
zeros,
16-
bufferToInt,
1716
} from 'ethereumjs-util'
1817
import { HeaderData, JsonHeader, BlockHeaderBuffer, Blockchain, BlockOptions } from './types'
1918
import {
@@ -716,7 +715,7 @@ export class BlockHeader {
716715
}
717716
const r = extraSeal.slice(0, 32)
718717
const s = extraSeal.slice(32, 64)
719-
const v = bufferToInt(extraSeal.slice(64, 65)) + 27
718+
const v = new BN(extraSeal.slice(64, 65)).addn(27)
720719
const pubKey = ecrecover(this.cliqueSigHash(), v, r, s)
721720
return Address.fromPublicKey(pubKey)
722721
}

packages/vm/lib/evm/precompiles/01-ecrecover.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function (opts: PrecompileInput): ExecResult {
2121

2222
let publicKey
2323
try {
24-
publicKey = ecrecover(msgHash, new BN(v).toNumber(), r, s)
24+
publicKey = ecrecover(msgHash, new BN(v), r, s)
2525
} catch (e) {
2626
return {
2727
gasUsed,

0 commit comments

Comments
 (0)