You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
3.9 KiB

  1. ## Census HTTP service
  2. Reference implementation of a voting census service running on the Vocdoni platform
  3. #### Compile
  4. In a GO ready environment:
  5. ```
  6. go get -u github.com/vocdoni/dvote-census
  7. go build -o censusHttpService github.com/vocdoni/dvote-census/cmd/censushttp
  8. ```
  9. #### Usage
  10. `./censusHttpService <port> [publicKey]`
  11. Example:
  12. ```
  13. ./censusHttpService 1500
  14. 2018/12/17 09:54:20 Starting process HTTP service on port 1500
  15. 2018/12/17 09:54:20 Starting server in http mode
  16. ```
  17. #### add claims
  18. ```
  19. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/addClaim
  20. {"error":false,"response":""}
  21. ```
  22. If public key authentication enabled, `signature` field is required using Nancl signature.
  23. The signed message is expected to be a concatenation of the following fields: `censusID, claimData, timeStamp`
  24. ```
  25. curl -d '{"censusID":"GoT_Favorite",
  26. "claimData":"Jon Snow",
  27. "timeStamp":"1547814675",
  28. "signature":"a117c4ce12b29090884112ffe57e664f007e7ef142a1679996e2d34fd2b852fe76966e47932f1e9d3a54610d0f361383afe2d9aab096e15d136c236abb0a0d0e"}' http://localhost:1500/addClaim
  29. {"error":false,"response":""}
  30. ```
  31. #### generate proof
  32. ```
  33. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/genProof
  34. {"error":false,"response":"0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}
  35. ```
  36. #### check proof
  37. ```
  38. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x0000000000000000000000000000000000000000000000000000000000000000000123"}' http://localhost:1500/checkProof
  39. {"error":false,"response":"invalid"}
  40. ```
  41. ```
  42. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}' http://localhost:1500/checkProof
  43. {"error":false,"response":"valid"}
  44. ```
  45. #### make snapshot
  46. Snapshots are static and unmutable copies of a specific census
  47. ```
  48. curl -d '{"censusID":"GoT_Favorite"}' http://localhost:1500/snapshot
  49. {"error":false,"response":"0x8647692e073a10980d821764c65ca3fddbc606bb936f9812a7a806bfa97df152"}
  50. ```
  51. The name for the snapshot is "0x8647692e073a10980d821764c65ca3fddbc606bb936f9812a7a806bfa97df152" which represents the Root Hash.
  52. Now you can use it as censusID for checkProof, getRoot, genProof and dump. But addClaim is not longer allowed.
  53. #### dump
  54. Dump contents of a specific censusID (values)
  55. ```
  56. curl -d '{"censusID":"GoT_Favorite"}' http://localhost:1500/dump
  57. {"error":false,"response":"[\"Tyrion\",\"Jon Snow\"]"}
  58. ```
  59. ##### add claims
  60. ```
  61. curl -d '{"processID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/addClaim
  62. {"error":false,"response":""}
  63. ```
  64. ```
  65. curl -d '{"processID":"GoT_Favorite","claimData":"Tyrion"}' http://localhost:1500/addClaim
  66. {"error":false,"response":""}
  67. ```
  68. ##### generate proof
  69. ```
  70. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/genProof
  71. {"error":false,"response":"0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}
  72. ```
  73. ##### check proof
  74. ```
  75. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x0000000000000000000000000000000000000000000000000000000000000000000123"}' http://localhost:1500/checkProof
  76. {"error":false,"response":"invalid"}
  77. ```
  78. ```
  79. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}' http://localhost:1500/checkProof
  80. {"error":false,"response":"valid"}
  81. ```