2018-12-28 11:37:22 +00:00
|
|
|
package account
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/crypto"
|
2019-11-23 17:57:05 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
2018-12-28 11:37:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
2019-11-23 17:57:05 +00:00
|
|
|
privKey = types.EncodeHex(privKeyBytes)
|
|
|
|
pubKey = types.EncodeHex(pubKeyBytes)
|
2018-12-28 11:37:22 +00:00
|
|
|
address = addressBytes.Hex()
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|