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.

136 lines
4.1 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> <namespace>[:pubKey] [<namespace>[:pubKey] ...]`
  11. Example:
  12. ```
  13. ./censusHttpService 1500 Got_Favorite
  14. 2019/02/01 20:01:15 Starting process HTTP service on port 1500 for namespace GoT_Favorite
  15. 2019/02/01 20:01:15 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. There is a time window of 10 seconds while the signature is considered valid.
  25. ```
  26. curl -d '{"censusID":"GoT_Favorite",
  27. "claimData":"Jon Snow",
  28. "timeStamp":"1547814675",
  29. "signature":"a117c4ce12b29090884112ffe57e664f007e7ef142a1679996e2d34fd2b852fe76966e47932f1e9d3a54610d0f361383afe2d9aab096e15d136c236abb0a0d0e"}' http://localhost:1500/addClaim
  30. {"error":false,"response":""}
  31. ```
  32. #### generate proof
  33. ```
  34. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/genProof
  35. {"error":false,"response":"0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}
  36. ```
  37. #### check proof
  38. ```
  39. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x0000000000000000000000000000000000000000000000000000000000000000000123"}' http://localhost:1500/checkProof
  40. {"error":false,"response":"invalid"}
  41. ```
  42. ```
  43. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}' http://localhost:1500/checkProof
  44. {"error":false,"response":"valid"}
  45. ```
  46. #### make snapshot
  47. Snapshots are static and unmutable copies of a specific census
  48. ```
  49. curl -d '{"censusID":"GoT_Favorite"}' http://localhost:1500/snapshot
  50. {"error":false,"response":"0x8647692e073a10980d821764c65ca3fddbc606bb936f9812a7a806bfa97df152"}
  51. ```
  52. The name for the snapshot is "0x8647692e073a10980d821764c65ca3fddbc606bb936f9812a7a806bfa97df152" which represents the Root Hash.
  53. Now you can use it as censusID for checkProof, getRoot, genProof and dump. But addClaim is not longer allowed.
  54. #### dump
  55. Dump contents of a specific censusID (values)
  56. ```
  57. curl -d '{"censusID":"GoT_Favorite"}' http://localhost:1500/dump
  58. {"error":false,"response":"[\"Tyrion\",\"Jon Snow\"]"}
  59. ```
  60. ##### add claims
  61. ```
  62. curl -d '{"processID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/addClaim
  63. {"error":false,"response":""}
  64. ```
  65. ```
  66. curl -d '{"processID":"GoT_Favorite","claimData":"Tyrion"}' http://localhost:1500/addClaim
  67. {"error":false,"response":""}
  68. ```
  69. ##### generate proof
  70. ```
  71. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow"}' http://localhost:1500/genProof
  72. {"error":false,"response":"0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}
  73. ```
  74. ##### check proof
  75. ```
  76. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x0000000000000000000000000000000000000000000000000000000000000000000123"}' http://localhost:1500/checkProof
  77. {"error":false,"response":"invalid"}
  78. ```
  79. ```
  80. curl -d '{"censusID":"GoT_Favorite","claimData":"Jon Snow", "proofData": "0x000000000000000000000000000000000000000000000000000000000000000352f3ca2aaf635ec2ae4452f6a65be7bca72678287a8bb08ad4babfcccd76c2fef1aac7675261bf6d12c746fb7907beea6d1f1635af93ba931eec0c6a747ecc37"}' http://localhost:1500/checkProof
  81. {"error":false,"response":"valid"}
  82. ```