Overview
Submitting results creates a new block containing election data from a polling station. Each submission is cryptographically signed and includes a Merkle root for efficient verification.Submit Command
The basic submit command sends results to a submission node:Parameters
node_addr: The HTTP address of the submission node (e.g.,http://localhost:8080)station_id: Unique identifier for the polling stationcandidate_id: Unique identifier for the candidatevotes: Number of votes received
Example Usage
Each submission creates a new block in the blockchain. Multiple results can be included in a single block by extending the implementation.
How Submission Works
When you submit results, the following process occurs:1. Block Creation
The CLI creates a new block containing:2. Merkle Tree Generation
A Merkle tree is constructed from the election results, providing:- Efficient verification of individual results
- Tamper-evident data structure
- Root hash included in the block
3. Digital Signature
The block is signed using your node’s private key:- Ensures authenticity of the submission
- Links the block to your node’s identity
- Prevents repudiation
4. HTTP Submission
The signed block is sent to the submission node via HTTP POST:Submission Nodes
Submission nodes are specialized nodes that:- Accept result submissions from authorized users
- Validate block structure and signatures
- Propagate accepted blocks to the P2P network
- Maintain an audit trail of all submissions
Running a Submission Node
To run your own submission node:Submission nodes should implement authorization to prevent spam. Future versions will include access control mechanisms.
Block Structure
Each submitted block contains:| Field | Description |
|---|---|
height | Sequential block number |
prev_hash | Hash of the previous block |
creator | Public key hash of block creator |
creator_pub_key | Full public key for verification |
signature | Digital signature of block contents |
signature_pub_key_hash | Hash of signing public key |
merkle_root | Root hash of results Merkle tree |
results | Array of candidate results |
timestamp | Block creation time |
hash | Hash of entire block |
Validation and Consensus
Submitted blocks undergo validation:- Structure Validation: Correct format and required fields
- Signature Verification: Valid signature from known public key
- Chain Continuity: Correct previous hash and height
- Result Validation: Valid station and candidate IDs
- Merkle Verification: Results match Merkle root
Error Handling
Common Errors
Failed to submit block: 400 The submission node rejected your block. Possible reasons:- Invalid signature
- Incorrect previous hash
- Malformed results data
- Verify the node address
- Ensure the node is running
- Check network connectivity
- Verify IDs match your setup SQL
- Check for typos in the command
Best Practices
Batch submissions when possible
Batch submissions when possible
While the current implementation submits one result at a time, future versions will support batching multiple results into a single block for efficiency.
Verify before submitting
Verify before submitting
Double-check vote counts before submission. Blockchain immutability means corrections require new blocks.
Keep private keys secure
Keep private keys secure
Your private database contains signing keys. Protect it:
- Restrict file permissions
- Regular backups
- Never commit to version control
Monitor submission confirmations
Monitor submission confirmations
Wait for confirmation before considering a submission successful. Network delays may occur.