meowlib/identity.go
2021-10-18 21:05:44 +02:00

42 lines
785 B
Go

package meow
type Identity struct {
nickname string
PublicKey string
PrivateKey string
Status string
Peers []Peer
}
func Create(nickname string) Identity {
var id Identity
id.nickname = nickname
kp := NewKeyPair()
id.PublicKey = kp.Public
id.PrivateKey = kp.Private
return id
}
func (*Identity) InvitePeer(name string) *Peer {
var peer Peer
peer.Me = append(peer.Me, NewKeyPair())
peer.Name = name
return &peer
}
func (*Identity) FinalizeInvitation(peer *Peer, peerPublicKey string) {
peer.PublicKey = peerPublicKey
}
func (*Identity) AddPeer(name string, peerPublicKey string) string {
var peer Peer
peer.Me = append(peer.Me, NewKeyPair())
peer.Name = name
peer.PublicKey = peerPublicKey
return peer.Me[len(peer.Me)-1].Public
}
func Save() {
}