mirror of
https://github.com/status-im/status-go.git
synced 2025-01-14 08:44:46 +00:00
ed5a5c154d
Move to a monorepo structure with submodules - Rename status-protocol-go to status-go/protocol
24 lines
551 B
Go
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
|
|
}
|