blockchainIDsystem/clientApp/clientAppRESTFunctions.go
clientApp/clientAppRESTFunctions.goRaw
1package main
2
3import (
4 "encoding/json"
5 "fmt"
6 "net/http"
7
8 ownrsa "./ownrsa"
9)
10
11//generate key pair
12//blind m
13//unblind m
14
15func Index(w http.ResponseWriter, r *http.Request) {
16 fmt.Fprintln(w, "serverIDsigner")
17}
18
19func IDs(w http.ResponseWriter, r *http.Request) {
20 //read the keys stored in /keys directory
21 keys := readKeys("keys.json")
22 saveKeys(keys, "keys.json")
23
24 jResp, err := json.Marshal(keys)
25 check(err)
26 fmt.Fprintln(w, string(jResp))
27}
28func NewID(w http.ResponseWriter, r *http.Request) {
29 //generate RSA keys pair
30 newKey := ownrsa.GenerateKeyPair()
31
32 key := ownrsa.PackKey(newKey)
33 fmt.Println(key)
34
35 keys := readKeys("keys.json")
36 keys = append(keys, key)
37 saveKeys(keys, "keys.json")
38
39 jResp, err := json.Marshal(keys)
40 check(err)
41 fmt.Fprintln(w, string(jResp))
42}