Files
fhe/examples/shadow-governance/tasks/tally.ts
T
Zach Kelling 961c42e204 feat: add FHE example apps for all Pars PIPs
- data-seal: Verifiable Data Integrity Seal (PIP-0010/LP-0535)
  FHE-encrypted tamper-proof sealing with Public/ZK/Private modes,
  batch sealing, homomorphic verification

- content-provenance: AI & Media Content Provenance (PIP-0011/LP-7110)
  Model manifests, output attestation via homomorphic comparison,
  media derivation DAGs

- encrypted-crdt: Encrypted CRDT (PIP-0013/LP-6500)
  LWW-Register with FHE values, OR-Set with tag-based add/remove,
  Lamport timestamp conflict resolution, deterministic merge

- shadow-governance: Shadow Government Protocol (PIP-7010)
  Anonymous ministries, encrypted voting with homomorphic tallying,
  nullifier-based anti-fraud, quorum enforcement

Each example includes Solidity contracts, Hardhat tests, CLI tasks,
and README linking to corresponding PIP and LP specifications.
2026-02-13 14:16:46 -08:00

35 lines
1.2 KiB
TypeScript

import { task } from "hardhat/config";
task("task:tally", "Start tally and finalize a proposal")
.addParam("contract", "ShadowGovernance contract address")
.addParam("proposal", "Proposal ID")
.setAction(async ({ contract, proposal }, hre) => {
const [signer] = await hre.ethers.getSigners();
const gov = await hre.ethers.getContractAt("ShadowGovernance", contract);
const p = await gov.getProposal(parseInt(proposal));
const statusNames = ["Active", "Tallying", "Passed", "Rejected", "Cancelled"];
if (Number(p.status) === 0) {
console.log("Starting tally...");
const tx = await gov.startTally(parseInt(proposal));
await tx.wait();
}
// Try to finalize
try {
const tx = await gov.finalize(parseInt(proposal));
await tx.wait();
const tally = await gov.getTally(parseInt(proposal));
const result = await gov.getProposal(parseInt(proposal));
console.log(`\nResult: ${statusNames[Number(result.status)]}`);
console.log(` Yes: ${tally.yesVotes.toString()}`);
console.log(` No: ${tally.noVotes.toString()}`);
console.log(` Voters: ${result.voterCount.toString()}`);
} catch (e: any) {
console.log("Decryption still pending. Try again later.");
}
});