first key exchange thing

This commit is contained in:
Hazel Noack
2025-06-27 14:51:32 +02:00
parent 64fa44e45e
commit 885aefc96c
5 changed files with 91 additions and 12 deletions

View File

@@ -2,22 +2,18 @@ package game
import (
"crypto/ed25519"
"crypto/rand"
)
type User struct {
Name string
PublicKey ed25519.PublicKey
PrivateKey ed25519.PrivateKey
Name string
PublicKey ed25519.PublicKey
}
func NewUser(name string) User {
func NewUser(name string, publicKey ed25519.PublicKey) User {
// ed25519
public, private, _ := ed25519.GenerateKey(rand.Reader)
return User{
Name: name,
PublicKey: public,
PrivateKey: private,
Name: name,
PublicKey: publicKey,
}
}