---
# System prepended metadata

title: Генерация и импорт ключей валидаторов

---

# Генерация и импорт ключей валидаторов 
## Important Note:  Касательно Pyrmont vs Mainnet
1) Для валидаторов в генезисе:
	1.1. creating `./deposit <...> --chain=mainnet` (если использовать pyrmont, то при генерации генезиса возникает ошибка)
	1.2. creating `bazel run //validator:validator -- accounts import <...> --pyrmont`
1) Для валидаторов с активацией депозитом:
	1.1. creating `./deposit <...> --chain=pyrmont` 
	1.2. creating `bazel run //validator:validator -- accounts import <...> --pyrmont`

проблема возникает в координаторе при валидации депозита (кажется это по запросу валидатора)
проблема связанна c вычислением значения домена, которое используется для валидации подписи 


````go
// validatorStatus searches for the requested validator''s state and deposit to retrieve its inclusion estimate. Also returns the validators index.
func (vs *Server) validatorStatus(...) (*ethpb.ValidatorStatusResponse, types.ValidatorIndex) {
	...
	switch resp.Status {
	case ethpb.ValidatorStatus_UNKNOWN_STATUS:
		domain, err := signing.ComputeDomain(
			params.BeaconConfig().DomainDeposit,
			nil, /*forkVersion*/
			nil, /*genesisValidatorsRoot*/
		)
		....
		if err := deposit.VerifyDepositSignature(dep.Data, domain); err != nil {
		^^^^^^^^^^^^^^^^^^^^^^^^ error here ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
			resp.Status = ethpb.ValidatorStatus_INVALID
			log.WithError(err).Warn("Invalid Eth1 deposit")
			return resp, nonExistentIndex
		}
		// Set validator deposit status if their deposit is visible.
		resp.Status = depositStatus(dep.Data.Amount)
		resp.Eth1DepositBlockNumber = eth1BlockNumBigInt.Uint64()

		return resp, nonExistentIndex
	case ethpb.ValidatorStatus_DEPOSITED, ethpb.ValidatorStatus_PENDING, ethpb.ValidatorStatus_PARTIALLY_DEPOSITED:
	...
	default:
		return resp, idx
	}
}
````

````go
// VerifyDepositSignature verifies the correctness of Eth1 deposit BLS signature
func VerifyDepositSignature(dd *ethpb.Deposit_Data, domain []byte) error {
	...
	signingData := &ethpb.SigningData{
		ObjectRoot: root[:],
		Domain:     domain,
	}
	ctrRoot, err := signingData.HashTreeRoot()
	...
	if !sig.Verify(publicKey, ctrRoot[:]) {
	^^^^^^^^^^^^^ error here ^^^^^^^^^^^^
		return signing.ErrSigFailedToVerify
	}
	return nil
}
````

````go
func ComputeDomain(domainType [DomainByteLength]byte, forkVersion, genesisValidatorsRoot []byte) ([]byte, error) {
	if forkVersion == nil {
		forkVersion = params.BeaconConfig().GenesisForkVersion
		^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	}
	...
	return domain(domainType, forkDataRoot[:]), nil
}
````

## Пример генерации ключей

### NODE-0: 258 validators for genesis with 3 creators 

#### create

````shell
./deposit new-mnemonic \
--num_validators=86 \
--eth1_withdrawal_address=0xa7e558cc6efa1c41270ef4aa227b3dd6b4a3951e \
--mnemonic_language=english \
--folder=/home/mezin/work/tmp/_staking-deposit-cli-v1.2.0/ \
--chain=mainnet \
--keystore_password=1qaz2wsx3edc
````


````shell
./deposit existing-mnemonic \
--mnemonic="ill example harsh matter inner borrow health impact brief velvet inform job feed spot air fee error style illness infant flower tomato stable census" \
--validator_start_index=86 \
--num_validators=86 \
--eth1_withdrawal_address=0xe43bb1b64fc7068d313d24d01d8ccca785b22c72 \
--folder=/home/mezin/work/tmp/_staking-deposit-cli-v1.2.0/ \
--chain=mainnet \
--keystore_password=1qaz2wsx3edc
````

````shell
./deposit existing-mnemonic \
--mnemonic="ill example harsh matter inner borrow health impact brief velvet inform job feed spot air fee error style illness infant flower tomato stable census" \
--validator_start_index=172 \
--num_validators=86 \
--eth1_withdrawal_address=0xe43bb1b64fc7068d313d24d01d8ccca785b22c72 \
--folder=/home/mezin/work/tmp/_staking-deposit-cli-v1.2.0/ \
--chain=mainnet \
--keystore_password=1qaz2wsx3edc
````


#### import

````shell
bazel run //validator:validator -- accounts import \
 --keys-dir=/home/mezin/go/src/tesseract/.data/node-0/validator_keys \
 --wallet-dir=/home/mezin/go/src/tesseract/.data/node-0/wallet-dir \
 --wallet-password-file=/home/mezin/go/src/tesseract/.data/node-0/password.txt \
 --account-password-file=/home/mezin/go/src/tesseract/.data/node-0/password.txt \
 --pyrmont \
 --accept-terms-of-use
````


### NODE-1: 258 validators for deposit with 1 creator 

#### create

````shell
./deposit new-mnemonic \
--num_validators=258 \
--eth1_withdrawal_address=0x6e9e76fa278190cfb2404e5923d3ccd7e8f6c51d \
--mnemonic_language=english \
--folder=/home/mezin/work/tmp/_staking-deposit-cli-v1.2.0/ \
--chain=pyrmont \
--keystore_password=1qaz2wsx3edc
````


#### import

````shell
bazel run //validator:validator -- accounts import \
 --keys-dir=/home/mezin/go/src/tesseract/.data/node-1/validator_keys \
 --wallet-dir=/home/mezin/go/src/tesseract/.data/node-1/wallet-dir \
 --wallet-password-file=/home/mezin/go/src/tesseract/.data/node-1/password.txt \
 --account-password-file=/home/mezin/go/src/tesseract/.data/node-1/password.txt \
 --pyrmont \
 --accept-terms-of-use
````