Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Crypto-Project-ENSTA/back-end/llms.txt

Use this file to discover all available pages before exploring further.

Calling this endpoint closes the election and produces the final results. The server marks the election status as vote_ended, then retrieves every encrypted ballot from the anonymizer service. Each ballot is decrypted using the counter’s RSA private key. The counter service then verifies the admin’s digital signature on each ballot and checks the SHA-256 hash of the voter’s N2 nonce. Ballots that pass both checks are counted; those that fail are logged as invalid_signature or invalid_n2 respectively. The endpoint returns a complete breakdown alongside the candidate tally.

Request

POST /voting/end-vote
No request body is required.

Response

status
string
required
Always "success" on a 200 response.
message
string
required
Always "Votes counted successfully" on a 200 response.
results
object
required
Breakdown of all processed ballots.

Example response

{
  "status": "success",
  "message": "Votes counted successfully",
  "results": {
    "valid": 5,
    "invalid_signature": 0,
    "invalid_n2": 1,
    "tally": {
      "Candidate A": 3,
      "Candidate B": 2
    }
  }
}

HTTP status codes

CodeMeaning
200Election closed and ballots tallied successfully.
500An unexpected error occurred while counting votes, e.g. a decryption failure.

Example

curl --request POST \
  --url https://your-api-host/voting/end-vote
{
  "status": "success",
  "message": "Votes counted successfully",
  "results": {
    "valid": 5,
    "invalid_signature": 0,
    "invalid_n2": 1,
    "tally": {
      "Candidate A": 3,
      "Candidate B": 2
    }
  }
}
The tally produced by this endpoint is also available later via GET /results/tally without needing to re-run the counting process.

Build docs developers (and LLMs) love