status-go/account/address.go
Pedro Pombeiro ed5a5c154d
Move to monorepo structure (#1684)
Move to a monorepo structure with submodules

- Rename status-protocol-go to status-go/protocol
2019-11-21 17:19:22 +01:00

24 lines
551 B
Go

package account
import (
"github.com/ethereum/go-ethereum/crypto"
protocol "github.com/status-im/status-go/protocol/types"
)
func CreateAddress() (address, pubKey, privKey string, err error) {
key, err := crypto.GenerateKey()
if err != nil {
return "", "", "", err
}
privKeyBytes := crypto.FromECDSA(key)
pubKeyBytes := crypto.FromECDSAPub(&key.PublicKey)
addressBytes := crypto.PubkeyToAddress(key.PublicKey)
privKey = protocol.EncodeHex(privKeyBytes)
pubKey = protocol.EncodeHex(pubKeyBytes)
address = addressBytes.Hex()
return
}