package main import ( "fmt" "os" "git.pspay.io/crypto-stories/custodial/pkg/crypto" ) func main() { cwd, err := os.Getwd() if err != nil { panic(err) } var dir string = cwd + "/keys" fmt.Println("Checking for directory: " + dir) _, err = os.Stat(dir) if os.IsNotExist(err) { fmt.Println("Creating directory: " + dir) err = os.Mkdir(dir, 0755) if err != nil { panic(err) } fmt.Println("Generating a new keypair...") kp, err := crypto.KeyPair{}.Random() if err != nil { panic(err) } kp.Save(dir) fmt.Println("Keypair saved to: " + dir) } else { fmt.Println("Directory already exists: " + dir) } fmt.Println("Checking if locker/keys.go exists...") keys := cwd + "/pkg/locker/keys.go" _, err = os.Stat(keys) if os.IsNotExist(err) { fmt.Println("Creating locker/keys.go...") f, err := os.Create(keys) if err != nil { panic(err) } defer f.Close() kp := crypto.KeyPair{}.Load(dir) fmt.Println("Writing to locker/keys.go...") f.WriteString("package locker\n\nconst PRIVATE_KEY string = \"" + string(kp.PrivateKeyBase64()) + "\"") fmt.Println("Done!") } else { fmt.Println("locker/keys.go already exists") } }