arnaucube
arnaucube/darkID-prototypePublic Self-hosted repository
darkID-prototype/clientApp/clientAppRESTFunctions.go
clientApp/clientAppRESTFunctions.goRaw
 1package main
 2
 3import (
 4	"encoding/json"
 5	"fmt"
 6	"net/http"
 7
 8	"github.com/fatih/color"
 9	"github.com/gorilla/mux"
10)
11
12//TODO use rsa library instead own rsa functions
13
14func Index(w http.ResponseWriter, r *http.Request) {
15	fmt.Fprintln(w, "clientApp")
16}
17
18func GetServer(w http.ResponseWriter, r *http.Request) {
19	color.Green(config.Server)
20	fmt.Fprintln(w, config.Server)
21}
22func GetIDs(w http.ResponseWriter, r *http.Request) {
23	keys := IDs()
24
25	jResp, err := json.Marshal(keys)
26	check(err)
27	fmt.Fprintln(w, string(jResp))
28}
29func GetNewID(w http.ResponseWriter, r *http.Request) {
30	key := NewID()
31
32	fmt.Println(key)
33
34	jResp, err := json.Marshal(key)
35	check(err)
36	fmt.Fprintln(w, string(jResp))
37}
38func GetBlindAndSendToSign(w http.ResponseWriter, r *http.Request) {
39	vars := mux.Vars(r)
40	idKey := vars["idKey"]
41	color.Green(idKey)
42
43	keys := BlindAndSendToSign(idKey)
44
45	jResp, err := json.Marshal(keys)
46	check(err)
47	fmt.Fprintln(w, string(jResp))
48}
49
50func GetVerify(w http.ResponseWriter, r *http.Request) {
51	vars := mux.Vars(r)
52	packPubK := vars["pubK"]
53	color.Green(packPubK)
54
55	//keys := Verify(packPubK)
56	keys := "a"
57
58	jResp, err := json.Marshal(keys)
59	check(err)
60	fmt.Fprintln(w, string(jResp))
61}