Demonstrates FHE voting where computation runs on encrypted data. Individual votes stay private while the program tallies results—only the final outcome (approved/rejected) is decrypted.
SPF Endpoint: localhost:8080 (via proxy)
Switching will reinitialize the WASM module
Signer Mode
Step 1: Initialize Keys
Step 2: Cast Your Vote
Step 3: Run FHE Voting Program
[[clang::fhe_program]]
voidtally_votes([[clang::encrypted]] int8_t*votes,
uint16_t num_votes,
[[clang::encrypted]] bool*didTheIssuePass) {
int16_t sum = 0;
for (uint16_t i = 0; i < num_votes; i++) {
int8_t sanitized_vote =iselect8(votes[i] == 1 || votes[i] ==-1, votes[i], 0);
sum += sanitized_vote;
}
*didTheIssuePass = sum > 0;
}
[[clang::fhe_program]]
voidtally_votes(
[[clang::encrypted]] int8_t*votes,
uint16_t num_votes,
[[clang::encrypted]] bool*didTheIssuePass)
{
int16_t sum = 0;
for (uint16_t i = 0; i < num_votes; i++) {
int8_t sanitized_vote =iselect8(votes[i] == 1 ||
votes[i] ==-1,
votes[i], 0);
sum += sanitized_vote;
}
*didTheIssuePass = sum > 0;
}