コード例 #1
0
ファイル: priv_key.go プロジェクト: readevalprint/eris-db
// Deterministically generates new priv-key bytes from key.
func (key PrivKeyEd25519) Generate(index int) PrivKeyEd25519 {
	newBytes := binary.BinarySha256(struct {
		PrivKey []byte
		Index   int
	}{key, index})
	return PrivKeyEd25519(newBytes)
}
コード例 #2
0
ファイル: priv_account.go プロジェクト: readevalprint/eris-db
// Generates a new account with private key from SHA256 hash of a secret
func GenPrivAccountFromSecret(secret []byte) *PrivAccount {
	privKey32 := binary.BinarySha256(secret) // Not Ripemd160 because we want 32 bytes.
	privKeyBytes := new([64]byte)
	copy(privKeyBytes[:32], privKey32)
	pubKeyBytes := ed25519.MakePublicKey(privKeyBytes)
	pubKey := PubKeyEd25519(pubKeyBytes[:])
	privKey := PrivKeyEd25519(privKeyBytes[:])
	return &PrivAccount{
		Address: pubKey.Address(),
		PubKey:  pubKey,
		PrivKey: privKey,
	}
}