Exemple #1
0
func coreConvertPrivValidatorToErisKey(b []byte) (key *kstore.Key, err error) {

	pv := new(PrivValidator)
	wire.ReadJSON(pv, b, &err)
	if err != nil {
		return nil, err
	}

	keyStore := kstore.NewKeyStorePlain(DefaultKeyStore)

	key = &kstore.Key{
		Id:         uuid.NewRandom(),
		Type:       kstore.KeyType{kstore.CurveTypeEd25519, kstore.AddrTypeRipemd160},
		Address:    pv.Address,
		PrivateKey: pv.PrivKey[:],
	}

	err = keyStore.StoreKey(key, "")
	return key, err
}
Exemple #2
0
func coreConvertErisKeyToPrivValidator(addrBytes []byte) (*PrivValidator, error) {
	keyStore := kstore.NewKeyStorePlain(DefaultKeyStore)
	key, err := keyStore.GetKey(addrBytes, "")
	ifExit(err)

	pub, err := key.Pubkey()
	if err != nil {
		return nil, err
	}

	var pubKey account.PubKeyEd25519
	copy(pubKey[:], pub)

	var privKey account.PrivKeyEd25519
	copy(privKey[:], key.PrivateKey)

	return &PrivValidator{
		Address: addrBytes,
		PubKey:  pubKey,
		PrivKey: privKey,
	}, nil
}