votingClient
Initialize with
initializeFromShyConfig— see the Web SDK overview for the common setup pattern.
Read methods
await client.getAllSubmissions()
// → Poll[]
await client.getSubmission('polls', scopingId)
// → Poll
await client.getSubmissionTally('polls', scopingId)
// → Tally | null — null until poll closes
await client.getSubmissionRecords('polls', scopingId)
// → VoteRecord[] (List 1 — no identity)
await client.getSubmissionParticipantCount('polls', scopingId)
// → number
Ballot build and submit
Enrolling the device
Ballots are attested by the IDV enclave using a credential this device gets once, right after verification. A Didit session id is never sent with a ballot or placed on the ledger.
import { createEnrollmentCommitment, enrollDeviceSecret } from '@shyware/sdk/clients/embodiments/votingClient'
// Before verification: keep secretHex on the device; send commitmentHex as
// `deviceCommitment` when your backend creates the Didit session.
const { secretHex, commitmentHex } = await createEnrollmentCommitment()
// After Didit approves: trade the session (once) for the device credential.
const device = await enrollDeviceSecret({ manifest, sessionId, userId, enrollmentSecretHex: secretHex })
// → { userId, deviceId, secretHex, identityKeyHex } — keep it on the device
buildVote(args)
Constructs a transaction envelope without submitting.
const envelope = await client.buildVote({
scopingId: 'proposal-42',
payload: 'yes', // string for plurality; string[] for approval/ranked
device, // this device's enrolled credential (see below); never a Didit session id
partitionId, // optional — audit partitioning
keypair // the per-poll device keypair
})
// → { txJson, submissionId, submissionNonce, beaconBlockHash, encSecret? }
txJson is a JSON-serialized TxTypeBallotCast (type 2) payload ready for submitVote. submissionNonce is the 32-byte random hex that the caller must retain as the private receipt — retain it together with the original beaconBlockHash for self-verification. submissionId = H(beaconBlockHash || submissionNonce) is the direction-free public identifier.
submitVote(txJson)
await client.submitVote(envelope.txJson)
POSTs to {api.base_url}/ballots. Returns the server response.
voteSubmission(args) — combined
await client.voteSubmission({
scopingId: 'proposal-42',
payload: 'yes',
device,
keypair
})
Combines buildVote and submitVote. In recoverable posture it returns the envelope; explicitly save its nonce, original beacon, and choice using your configured receipt store. In write-only posture it returns { writeOnly: true }.
Receipt methods
// Offline verification against the public vote list
await client.verifyReceipt(hexNonce, expectedChoice, votes, { beaconBlockHash })
// → boolean
// Read receipt from managed store
await client.getPrivateReceipt(scopingId)
// → { submissionNonce, choice, scopingId } | null
// Save receipt to managed store
await client.savePrivateReceipt(scopingId, receipt)
// Post-close Sybil-audit signal — confirm your identity_hash appears in List 2
await client.confirmReceipt(scopingId)
// Recovery aid: every (poll_id, identity_hash) pair the caller's OWN signed-in
// account has used, via the reconcile store's off-chain recovery index.
// Gated server-side on the caller's own auth token — never enumerable.
await client.listMyIdentities()
// → { identities: [{ pollId, identityHash }, ...] }
verifyReceipt recomputes submissionId = H(beaconBlockHash || hexNonce) and scans the public votes list for a matching record. It does not contact the server — the original beacon and the full vote list are required.
Posture
const signals = await client.readBrowserRuntimeSignals(manifest, options?)
// → { playIntegrity, deviceAttestation, hostileNetwork, ... }
const posture = client.resolveEffectivePosture(manifest, signals)
// → "recoverable" | "write_only"
When posture resolves to "write_only", voteSubmission returns { writeOnly: true }. Low-level builders still return signing material: callers must clear it after submission and avoid logging or mirroring it. The SDK cannot wipe application-owned analytics or logs.
Voting methods
| Voting method | choices format |
|---|---|
yes_no | ["yes"] or ["no"] |
plurality | ["option_id"] |
approval | ["opt_a", "opt_b"] |
ranked_choice | ["first", "second", "third"] in preference order |
Write-only posture in hostile jurisdictions
For coercion-resistant deployments, set default_posture: "coercion_resistant" and all three write_only_on_* fallbacks to true. After voteSubmission returns in write-only mode:
- the combined method returns only the write-only status
- no
ballotNoncestored - no
encSecretstored - a party seizing the device cannot derive vote direction
Deployment guide
Civic deployment (recoverable posture)
The standard configuration for domestic advisory referenda and civic participation.
Identity model:
- IDV provider: Didit (biometric) —
identity_hash = SHA-256(document_key ‖ poll_id), derived by the IDV attestation enclave from Didit'sid_verificationdocument data (document type, issuing country, document number). Didit's real API has no stable per-person identifier field, so the enclave uses the one real document behind each verification instead — see IDV attestation enclave. sk_vgenerated on device; retain per account/poll for replacements in recoverable posture, or in memory only during a write-only session — IDV does not hold it- Recovery: biometric re-verification on any device re-derives the same
identity_hashfor the same real document, no password or seed phrase. If Didit's document matching ever produces a differentidentity_hashfor the same real person on a different device,client.listMyIdentities()(gated on the caller's own signed-in account) looks up everyidentity_hashthat account has used, via the reconcile store's off-chain recovery index — not part of the on-chain uniqueness check itself. - Receipt store: CockroachDB-backed off-chain runtime; operator read-only
Provisioning:
cd <deployment>/deploy/signing && terragrunt apply
shyware-abci \
--config shyconfig.json \
--db-path /opt/<deployment>/data \
--addr :26658
See Infrastructure provisioning for the full Terragrunt module.
Hostile-regime deployment (coercion_resistant posture)
For sovereign referenda in adversarial jurisdictions where the operator cannot be assumed neutral.
shyconfig:
{
"contract_version": "shyvoting-v1",
"deployment": {
"default_posture": "coercion_resistant",
"runtime_fallbacks": {
"write_only_on_missing_play_integrity": true,
"write_only_on_hostile_network": true,
"write_only_on_untrusted_device_attestation": true
}
}
}
Exports: the SDK does not automatically generate ballot CSV files. Retaining a ballot identifier allows lookup of its public payload, so an app promising no participation record must not retain or export it automatically.
Jurisdictional gap: the off-chain receipt store is hosted in a rule-of-law jurisdiction that discloses linkage records only under a valid court order. A hostile government has no standing to obtain such an order in a non-cooperative foreign jurisdiction. Legal separation is an operational safeguard, not a protocol guarantee against access or collusion.
Export classification: deployment eligibility requires a separate legal assessment; the SDK and jurisdictional separation do not establish an export authorization.
Infrastructure: CometBFT multi-validator cluster, jurisdictionally distributed. Provisioning:
cd <deployment>/deploy/signing && terragrunt apply
cd <deployment>/deploy/validator && \
HETZNER_NETWORK_ID=<id> HETZNER_SSH_PUBLIC_KEY=<key> \
CLOUDFLARE_TUNNEL_TOKEN=<token> terragrunt apply