arnaucube
arnaucube/go-dvotePublic Self-hosted repository
go-dvote/cmd/censushttp/README.md
cmd/censushttp/README.mdRaw
  1## Census HTTP service
  2
  3Reference implementation of a voting census service running on the Vocdoni platform
  4
  5#### Compile
  6
  7In a GO ready environment:
  8
  9```
 10go get -u github.com/vocdoni/dvote-census/...
 11go build -o censusHttpService github.com/vocdoni/dvote-census/cmd/censushttp
 12```
 13
 14#### Usage
 15
 16`./censusHttpService <port> [publicKey]`
 17
 18Example:
 19
 20```
 21./censusHttpService 1500
 222018/12/17 09:54:20 Starting process HTTP service on port 1500
 232018/12/17 09:54:20 Starting server in http mode
 24```
 25
 26#### add claims
 27
 28```
 29curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/addClaim
 30
 31{"error":false,"response":""}
 32```
 33
 34If public key authentication enabled, `signature` field is required using Nancl signature.
 35
 36The signed message is expected to be a concatenation of the following fields: `censusID, claimData, timeStamp`
 37
 38```
 39curl -d '{"censusID":"GoT_Favorite",
 40"claimData":"Jon Snow", 
 41"timeStamp":"1547814675", 
 42"signature":"a117c4ce12b29090884112ffe57e664f007e7ef142a1679996e2d34fd2b852fe76966e47932f1e9d3a54610d0f361383afe2d9aab096e15d136c236abb0a0d0e"}' http://localhost:1500/addClaim
 43
 44{"error":false,"response":""}
 45```
 46
 47
 48#### generate proof
 49
 50```
 51curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/genProof
 52
 53{"error":false,"response":"0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}
 54```
 55
 56#### check proof
 57
 58```
 59curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x0000000000000000000000000000000000000000000000000000000000000000000123"}' http://localhost:1500/checkProof
 60
 61{"error":false,"response":"invalid"}
 62```
 63
 64```
 65curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}' http://localhost:1500/checkProof
 66
 67{"error":false,"response":"valid"}
 68```
 69
 70#### make snapshot
 71
 72Snapshots are static and unmutable copies of a specific census
 73
 74```
 75curl -d '{"censusID":"GoT_Favorite"}' http://localhost:1500/snapshot
 76
 77{"error":false,"response":"0x8647692e073a10980d821764c65ca3fddbc606bb936f9812a7a806bfa97df152"}
 78```
 79
 80The name for the snapshot is "0x8647692e073a10980d821764c65ca3fddbc606bb936f9812a7a806bfa97df152" which represents the Root Hash.
 81
 82Now you can use it as censusID for checkProof, getRoot, genProof and dump. But addClaim is not longer allowed.
 83
 84#### dump
 85
 86Dump contents of a specific censusID (values)
 87
 88```
 89curl -d '{"censusID":"GoT_Favorite"}' http://localhost:1500/dump
 90{"error":false,"response":"[\"Tyrion\",\"Jon Snow\"]"}
 91```
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104##### add claims
105
106```
107curl -d '{"processID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/addClaim
108{"error":false,"response":""}
109```
110
111```
112curl -d '{"processID":"GoT_Favorite","claimData":"Tyrion"}' http://localhost:1500/addClaim
113{"error":false,"response":""}
114```
115
116##### generate proof
117
118```
119curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/genProof
120{"error":false,"response":"0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}
121```
122
123##### check proof
124
125```
126curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x0000000000000000000000000000000000000000000000000000000000000000000123"}' http://localhost:1500/checkProof
127{"error":false,"response":"invalid"}
128```
129
130```
131curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}' http://localhost:1500/checkProof
132{"error":false,"response":"valid"}
133```
134