package peer

import (
	"crypto/rand"
	"log"

	"golang.org/x/crypto/nacl/box"
	"golang.org/x/crypto/nacl/sign"
)

type cryptoKeys struct {
	PubKey      []byte
	PrivKey     []byte
	PubSignKey  []byte
	PrivSignKey []byte
}

func generateKeys() cryptoKeys {
	pubKey, privKey, err := box.GenerateKey(rand.Reader)
	if err != nil {
		log.Fatalf("Failed to generate encryption keys: %v", err)
	}

	pubSignKey, privSignKey, err := sign.GenerateKey(rand.Reader)
	if err != nil {
		log.Fatalf("Failed to generate signing keys: %v", err)
	}

	return cryptoKeys{pubKey[:], privKey[:], pubSignKey[:], privSignKey[:]}
}
