diff options
Diffstat (limited to 'client/main.go')
-rw-r--r-- | client/main.go | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/client/main.go b/client/main.go index d996531..22e5230 100644 --- a/client/main.go +++ b/client/main.go @@ -2,12 +2,58 @@ package main import ( "crypto/ed25519" + "encoding/base64" "flag" + "fmt" + "os" + "strings" ) func main() { flag.Parse() - if flag.Arg(0) == "register" { + + if flag.Arg(0) == "setup" { + // Create keys + pubKey, privKey, err := ed25519.GenerateKey(nil) + if err != nil { + panic(err) + } + err = os.WriteFile("pubkey", pubKey, 644) + if err != nil { + panic(err) + } + err = os.WriteFile("privkey", privKey, 600) + if err != nil { + panic(err) + } + // Create servers file + _, err = os.Create("servers") + if err != nil { + panic(err) + } + fmt.Printf("Success! Your user ID: %s", base64.RawURLEncoding.EncodeToString(pubKey)) + return + } + + pubKeyBytes, err := os.ReadFile("pubkey") + if err != nil { + panic(err) + } + pubKey := ed25519.PublicKey(pubKeyBytes) + privKeyBytes, err := os.ReadFile("privkey") + if err != nil { + panic(err) + } + privKey := ed25519.PublicKey(privKeyBytes) + serversBytes, err := os.ReadFile("servers") + if err != nil { + panic(err) + } + servers := strings.Split(string(serversBytes), "\n") + + + if flag.Arg(0) == "associate" { + } } |