Add accountdata constructor

This commit is contained in:
mcrakhman 2023-03-27 16:32:56 +02:00 committed by Mikhail Iudin
parent 79419b3f71
commit c3e6af0032
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0

View File

@ -12,6 +12,15 @@ type AccountKeys struct {
PeerId string
}
func New(peerKey crypto.PrivKey, signKey crypto.PrivKey) *AccountKeys {
peerId, _ := peer.IdFromSigningPubKey(peerKey.GetPublic())
return &AccountKeys{
PeerKey: peerKey,
SignKey: signKey,
PeerId: peerId.String(),
}
}
func NewRandom() (*AccountKeys, error) {
peerKey, _, err := crypto.GenerateEd25519Key(rand.Reader)
if err != nil {