mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 06:46:10 +00:00
Use offset 1000 for fake private keys
This commit is contained in:
parent
3e622644e7
commit
356573f1ca
@ -6,7 +6,7 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
import
|
import
|
||||||
options, sequtils,
|
options, sequtils, stew/endians2,
|
||||||
chronicles, eth/trie/[db],
|
chronicles, eth/trie/[db],
|
||||||
../beacon_chain/[beacon_chain_db, block_pool, extras, ssz, state_transition,
|
../beacon_chain/[beacon_chain_db, block_pool, extras, ssz, state_transition,
|
||||||
validator_pool, beacon_node_types],
|
validator_pool, beacon_node_types],
|
||||||
@ -17,18 +17,25 @@ func preset*(): string =
|
|||||||
" [Preset: " & const_preset & ']'
|
" [Preset: " & const_preset & ']'
|
||||||
|
|
||||||
func makeFakeValidatorPrivKey*(i: int): ValidatorPrivKey =
|
func makeFakeValidatorPrivKey*(i: int): ValidatorPrivKey =
|
||||||
var i = i + 1 # 0 does not work, as private key...
|
# 0 is not a valid BLS private key - 1000 helps interop with rust BLS library,
|
||||||
copyMem(result.x[0].addr, i.addr, min(sizeof(result.x), sizeof(i)))
|
# lighthouse.
|
||||||
|
# TODO: switch to https://github.com/ethereum/eth2.0-pm/issues/60
|
||||||
|
var bytes = uint64(i + 1000).toBytesLE()
|
||||||
|
copyMem(addr result.x[0], addr bytes[0], sizeof(bytes))
|
||||||
|
|
||||||
func makeFakeHash*(i: int): Eth2Digest =
|
func makeFakeHash*(i: int): Eth2Digest =
|
||||||
copyMem(result.data[0].addr, i.unsafeAddr, min(sizeof(result.data), sizeof(i)))
|
var bytes = uint64(i).toBytesLE()
|
||||||
|
static: doAssert sizeof(bytes) <= sizeof(result.data)
|
||||||
|
copyMem(addr result.data[0], addr bytes[0], sizeof(bytes))
|
||||||
|
|
||||||
func hackPrivKey(v: Validator): ValidatorPrivKey =
|
func hackPrivKey(v: Validator): ValidatorPrivKey =
|
||||||
## Extract private key, per above hack
|
## Extract private key, per above hack
|
||||||
var i: int
|
var bytes: array[8, byte]
|
||||||
|
static: doAssert sizeof(bytes) <= sizeof(v.withdrawal_credentials.data)
|
||||||
|
|
||||||
copyMem(
|
copyMem(
|
||||||
i.addr, v.withdrawal_credentials.data[0].unsafeAddr,
|
addr bytes, unsafeAddr v.withdrawal_credentials.data[0], sizeof(bytes))
|
||||||
min(sizeof(v.withdrawal_credentials.data), sizeof(i)))
|
let i = int(uint64.fromBytesLE(bytes))
|
||||||
makeFakeValidatorPrivKey(i)
|
makeFakeValidatorPrivKey(i)
|
||||||
|
|
||||||
func makeDeposit(i: int, flags: UpdateFlags): Deposit =
|
func makeDeposit(i: int, flags: UpdateFlags): Deposit =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user