go-dvote/service/README.md
service/README.mdRaw
1## dvot-process http service
2
3#### start http server
4
5```
6processHttp.T.Init()
7processHttp.Listen(1500, "http", "")
8```
9
10To enable authentication (using pubKey signature):
11
12```
13pubK := "39f54ce5293520b689f6658ea7f3401f4ff931fa3d90dea21ff901cdf82bb8aa"
14processHttp.Listen(1500, "http", pubK)
15```
16
17
18#### add claims
19
20```
21curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/addClaim
22
23{"error":false,"response":""}
24```
25
26```
27curl -d '{"censusID":"GoT_Favorite",
28"claimData":"Jon Snow",
29"timeStamp":"1547814675",
30"signature":"a117c4ce12b29090884112ffe57e664f007e7ef142a1679996e2d34fd2b852fe76966e47932f1e9d3a54610d0f361383afe2d9aab096e15d136c236abb0a0d0e"}' http://localhost:1500/addClaim
31
32{"error":false,"response":""}
33```
34
35The signature message is a concatenation of the following strings: `censusID, claimData, timeStamp`
36
37```
38curl -d '{"censusID":"GoT_Favorite","claimData":"Tyrion"}' http://localhost:1500/addClaim
39
40{"error":false,"response":""}
41```
42
43#### generate proof
44
45```
46curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/genProof
47
48{"error":false,"response":"0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}
49```
50
51#### check proof
52
53```
54curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x0000000000000000000000000000000000000000000000000000000000000000000123"}' http://localhost:1500/checkProof
55
56{"error":false,"response":"invalid"}
57```
58
59```
60curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}' http://localhost:1500/checkProof
61
62{"error":false,"response":"valid"}
63```
64
65#### make snapshot
66
67Snapshots are static and unmutable copies of a specific census
68
69```
70curl -d '{"censusID":"GoT_Favorite"}' http://localhost:1500/snapshot
71
72{"error":false,"response":"snaphost.GoT_Favorite.1548169813"}
73```
74
75The name for the snapshot is "snaphost.GoT_Favorite.1548169813"
76
77Now you can use it as censusID for checkProof, genProof and dump. But addClaim is not longer allowed.
78
79#### dump
80
81Dump contents of a specific censusID (values)
82
83```
84curl -d '{"censusID":"GoT_Favorite"}' http://localhost:1500/dump
85{"error":false,"response":"[\"Tyrion\",\"Jon Snow\"]"}
86```