//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `voting/board/read`. Version: `0.1`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///The answer to one question. Exactly one member besides `question` is present, matching the question's type, or `abstain` for an optional question left unanswered.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Answer",
/// "description": "The answer to one question. Exactly one member besides `question` is present, matching the question's type, or `abstain` for an optional question left unanswered.",
/// "type": "object",
/// "maxProperties": 2,
/// "minProperties": 2,
/// "required": [
/// "question"
/// ],
/// "properties": {
/// "abstain": {
/// "const": true
/// },
/// "choice": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Key"
/// },
/// "uniqueItems": true
/// },
/// "question": {
/// "$ref": "#/definitions/Key"
/// },
/// "ranking": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Key"
/// },
/// "uniqueItems": true
/// },
/// "scores": {
/// "type": "object",
/// "additionalProperties": {
/// "type": "integer"
/// },
/// "propertyNames": {
/// "$ref": "#/definitions/Key"
/// }
/// },
/// "text": {
/// "type": "string",
/// "maxLength": 4096
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Answer {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub abstain: ::std::option::Option<::serde_json::Value>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub choice: ::std::option::Option<Vec<Key>>,
pub question: Key,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ranking: ::std::option::Option<Vec<Key>>,
#[serde(
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub scores: ::std::collections::HashMap<Key, i64>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub text: ::std::option::Option<AnswerText>,
}
impl Answer {
pub fn builder() -> builder::Answer {
Default::default()
}
}
///`AnswerText`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 4096
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct AnswerText(::std::string::String);
impl ::std::ops::Deref for AnswerText {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<AnswerText> for ::std::string::String {
fn from(value: AnswerText) -> Self {
value.0
}
}
impl ::std::str::FromStr for AnswerText {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 4096usize {
return Err("longer than 4096 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for AnswerText {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for AnswerText {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for AnswerText {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for AnswerText {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///An open ballot: one answer per question of the manifest, in any order. The bytes a cast's proof binds are the RFC 8785 (JCS) canonicalization of this object as received.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ballot",
/// "description": "An open ballot: one answer per question of the manifest, in any order. The bytes a cast's proof binds are the RFC 8785 (JCS) canonicalization of this object as received.",
/// "type": "object",
/// "required": [
/// "answers",
/// "electionId",
/// "manifestDigest"
/// ],
/// "properties": {
/// "answers": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Answer"
/// },
/// "maxItems": 128,
/// "minItems": 1
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "manifestDigest": {
/// "$ref": "#/definitions/DigestMultibase"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Ballot {
pub answers: ::std::vec::Vec<Answer>,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
#[serde(rename = "manifestDigest")]
pub manifest_digest: DigestMultibase,
}
impl Ballot {
pub fn builder() -> builder::Ballot {
Default::default()
}
}
///One leaf of a board. A leaf's hash is the RFC 9162 leaf hash of the JCS canonicalization of this object. Entries carry no time of arrival: the order is the board's, and a timestamp would hand anyone who reads the board the timing the registrar's log would need to pair a ticket with its cast.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "BoardEntry",
/// "description": "One leaf of a board. A leaf's hash is the RFC 9162 leaf hash of the JCS canonicalization of this object. Entries carry no time of arrival: the order is the board's, and a timestamp would hand anyone who reads the board the timing the registrar's log would need to pair a ticket with its cast.",
/// "oneOf": [
/// {
/// "title": "CastEntry",
/// "type": "object",
/// "required": [
/// "cast",
/// "kind"
/// ],
/// "properties": {
/// "cast": {
/// "$ref": "#/definitions/Cast"
/// },
/// "kind": {
/// "const": "cast"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "ReplacementEntry",
/// "description": "The cast at `replaces` is no longer counted: a later cast under the same tag is.",
/// "type": "object",
/// "required": [
/// "by",
/// "kind",
/// "replaces",
/// "tag"
/// ],
/// "properties": {
/// "by": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "kind": {
/// "const": "replaced"
/// },
/// "replaces": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "tag": {
/// "$ref": "#/definitions/Multibase"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "LifecycleEntry",
/// "type": "object",
/// "required": [
/// "at",
/// "kind"
/// ],
/// "properties": {
/// "at": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "kind": {
/// "enum": [
/// "opened",
/// "closed",
/// "closedEarly",
/// "cancelled"
/// ]
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "ResultEntry",
/// "type": "object",
/// "required": [
/// "kind",
/// "result"
/// ],
/// "properties": {
/// "kind": {
/// "const": "result"
/// },
/// "result": {
/// "$ref": "#/definitions/ElectionResult"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "EncryptedCastEntry",
/// "type": "object",
/// "required": [
/// "cast",
/// "kind"
/// ],
/// "properties": {
/// "cast": {
/// "$ref": "#/definitions/EncryptedCast"
/// },
/// "kind": {
/// "const": "encryptedCast"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "TransportKeyEntry",
/// "type": "object",
/// "required": [
/// "kind",
/// "transportKey"
/// ],
/// "properties": {
/// "kind": {
/// "const": "transportKey"
/// },
/// "transportKey": {
/// "$ref": "#/definitions/TransportKey"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "DealingEntry",
/// "type": "object",
/// "required": [
/// "dealing",
/// "kind"
/// ],
/// "properties": {
/// "dealing": {
/// "$ref": "#/definitions/Dealing"
/// },
/// "kind": {
/// "const": "dealing"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "ConfirmationEntry",
/// "type": "object",
/// "required": [
/// "complaints",
/// "kind",
/// "trustee"
/// ],
/// "properties": {
/// "complaints": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "maxItems": 64
/// },
/// "kind": {
/// "const": "confirmation"
/// },
/// "trustee": {
/// "$ref": "#/definitions/TrusteeIndex"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "JustificationEntry",
/// "type": "object",
/// "required": [
/// "dealer",
/// "kind",
/// "recipient",
/// "share"
/// ],
/// "properties": {
/// "dealer": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "kind": {
/// "const": "justification"
/// },
/// "recipient": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "share": {
/// "$ref": "#/definitions/GroupScalar"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "ElectionKeyEntry",
/// "type": "object",
/// "required": [
/// "electionKey",
/// "kind"
/// ],
/// "properties": {
/// "electionKey": {
/// "$ref": "#/definitions/ElectionKey"
/// },
/// "kind": {
/// "const": "electionKey"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "PartialDecryptionsEntry",
/// "type": "object",
/// "required": [
/// "kind",
/// "partials",
/// "trustee"
/// ],
/// "properties": {
/// "kind": {
/// "const": "partials"
/// },
/// "partials": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/PartialDecryption"
/// },
/// "maxItems": 100000,
/// "minItems": 1
/// },
/// "trustee": {
/// "$ref": "#/definitions/TrusteeIndex"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "UnsealedEntry",
/// "type": "object",
/// "required": [
/// "ballot",
/// "kind",
/// "leafIndex"
/// ],
/// "properties": {
/// "ballot": {
/// "$ref": "#/definitions/Ballot"
/// },
/// "kind": {
/// "const": "unsealed"
/// },
/// "leafIndex": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "SpoiledEntry",
/// "description": "A sealed cast that did not open, or opened to no valid ballot: not counted (CONVENTIONS §9.7).",
/// "type": "object",
/// "required": [
/// "kind",
/// "leafIndex"
/// ],
/// "properties": {
/// "kind": {
/// "const": "spoiled"
/// },
/// "leafIndex": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
/// }
/// ]
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged, deny_unknown_fields)]
#[non_exhaustive]
pub enum BoardEntry {
CastEntry {
cast: Cast,
kind: ::serde_json::Value,
},
ReplacementEntry {
by: u64,
kind: ::serde_json::Value,
replaces: u64,
tag: Multibase,
},
LifecycleEntry {
at: ::chrono::DateTime<::chrono::offset::Utc>,
kind: LifecycleEntryKind,
},
ResultEntry {
kind: ::serde_json::Value,
result: ElectionResult,
},
EncryptedCastEntry {
cast: EncryptedCast,
kind: ::serde_json::Value,
},
TransportKeyEntry {
kind: ::serde_json::Value,
#[serde(rename = "transportKey")]
transport_key: TransportKey,
},
DealingEntry {
dealing: Dealing,
kind: ::serde_json::Value,
},
ConfirmationEntry {
complaints: ::std::vec::Vec<TrusteeIndex>,
kind: ::serde_json::Value,
trustee: TrusteeIndex,
},
JustificationEntry {
dealer: TrusteeIndex,
kind: ::serde_json::Value,
recipient: TrusteeIndex,
share: GroupScalar,
},
ElectionKeyEntry {
#[serde(rename = "electionKey")]
election_key: ElectionKey,
kind: ::serde_json::Value,
},
PartialDecryptionsEntry {
kind: ::serde_json::Value,
partials: ::std::vec::Vec<PartialDecryption>,
trustee: TrusteeIndex,
},
UnsealedEntry {
ballot: Ballot,
kind: ::serde_json::Value,
#[serde(rename = "leafIndex")]
leaf_index: u64,
},
SpoiledEntry {
kind: ::serde_json::Value,
#[serde(rename = "leafIndex")]
leaf_index: u64,
},
}
///A board's tree head (RFC 9162 §2.1). A head is signed by being carried in a document the ballot box signs; whoever keeps a head keeps that whole document.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "BoardHead",
/// "description": "A board's tree head (RFC 9162 §2.1). A head is signed by being carried in a document the ballot box signs; whoever keeps a head keeps that whole document.",
/// "type": "object",
/// "required": [
/// "electionId",
/// "issuedAt",
/// "rootHash",
/// "treeSize"
/// ],
/// "properties": {
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "issuedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "rootHash": {
/// "description": "The RFC 9162 Merkle tree hash (SHA-256) of the first `treeSize` entries, as a multihash.",
/// "$ref": "#/definitions/DigestMultibase"
/// },
/// "treeSize": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct BoardHead {
#[serde(rename = "electionId")]
pub election_id: ElectionId,
#[serde(rename = "issuedAt")]
pub issued_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The RFC 9162 Merkle tree hash (SHA-256) of the first `treeSize` entries, as a multihash.
#[serde(rename = "rootHash")]
pub root_hash: DigestMultibase,
#[serde(rename = "treeSize")]
pub tree_size: u64,
}
impl BoardHead {
pub fn builder() -> builder::BoardHead {
Default::default()
}
}
///A ballot and the PCS attestation that admits it (VTI-VOT-030). `attestation` is the suite's canonical encoding of the attestation made for the election point with the ballot context bound in (CONVENTIONS §3); `tag` repeats its tag so a ballot box can refuse a duplicate before the pairing check.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Cast",
/// "description": "A ballot and the PCS attestation that admits it (VTI-VOT-030). `attestation` is the suite's canonical encoding of the attestation made for the election point with the ballot context bound in (CONVENTIONS §3); `tag` repeats its tag so a ballot box can refuse a duplicate before the pairing check.",
/// "type": "object",
/// "required": [
/// "attestation",
/// "ballot",
/// "tag"
/// ],
/// "properties": {
/// "attestation": {
/// "$ref": "#/definitions/Multibase"
/// },
/// "ballot": {
/// "$ref": "#/definitions/Ballot"
/// },
/// "tag": {
/// "$ref": "#/definitions/Multibase"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Cast {
pub attestation: Multibase,
pub ballot: Ballot,
pub tag: Multibase,
}
impl Cast {
pub fn builder() -> builder::Cast {
Default::default()
}
}
///A trustee's contribution to the election key: Feldman commitments to its polynomial, a proof of knowledge of the constant term, and one share per trustee sealed to that trustee's transport key (CONVENTIONS §9.6).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Dealing",
/// "description": "A trustee's contribution to the election key: Feldman commitments to its polynomial, a proof of knowledge of the constant term, and one share per trustee sealed to that trustee's transport key (CONVENTIONS §9.6).",
/// "type": "object",
/// "required": [
/// "commitments",
/// "dealer",
/// "pok",
/// "shares"
/// ],
/// "properties": {
/// "commitments": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/GroupElement"
/// },
/// "maxItems": 64,
/// "minItems": 2
/// },
/// "dealer": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "pok": {
/// "$ref": "#/definitions/SigmaProof"
/// },
/// "shares": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/SealedShare"
/// },
/// "maxItems": 64,
/// "minItems": 2
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Dealing {
pub commitments: ::std::vec::Vec<GroupElement>,
pub dealer: TrusteeIndex,
pub pok: SigmaProof,
pub shares: ::std::vec::Vec<SealedShare>,
}
impl Dealing {
pub fn builder() -> builder::Dealing {
Default::default()
}
}
///What a partial decryption decrypts: the sealed cast at a board leaf, or the total of one option of one question.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "DecryptionTarget",
/// "description": "What a partial decryption decrypts: the sealed cast at a board leaf, or the total of one option of one question.",
/// "type": "object",
/// "oneOf": [
/// {
/// "required": [
/// "leafIndex"
/// ]
/// },
/// {
/// "required": [
/// "option",
/// "question"
/// ]
/// }
/// ],
/// "required": [
/// "ciphertext"
/// ],
/// "properties": {
/// "ciphertext": {
/// "$ref": "#/definitions/ElGamalCiphertext"
/// },
/// "leafIndex": {
/// "description": "A sealed cast's board leaf.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "option": {
/// "$ref": "#/definitions/Key"
/// },
/// "question": {
/// "$ref": "#/definitions/Key"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged, deny_unknown_fields)]
#[non_exhaustive]
pub enum DecryptionTarget {
Variant0 {
ciphertext: ElGamalCiphertext,
///A sealed cast's board leaf.
#[serde(rename = "leafIndex")]
leaf_index: u64,
},
Variant1 {
ciphertext: ElGamalCiphertext,
option: Key,
question: Key,
},
}
/**
A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.
Multihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.
This definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.
Restricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that "interoperability is not guaranteed between implementations using such values", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "DigestMultibase",
/// "description": "A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\n\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\n\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\n\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \"interoperability is not guaranteed between implementations using such values\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.",
/// "examples": [
/// "zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR"
/// ],
/// "type": "string",
/// "minLength": 16,
/// "pattern": "^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DigestMultibase(::std::string::String);
impl ::std::ops::Deref for DigestMultibase {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DigestMultibase> for ::std::string::String {
fn from(value: DigestMultibase) -> Self {
value.0
}
}
impl ::std::str::FromStr for DigestMultibase {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 16usize {
return Err("shorter than 16 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\"".into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for DigestMultibase {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for DigestMultibase {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for DigestMultibase {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for DigestMultibase {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///A disjunctive proof that a ciphertext encrypts one value of a public list: one `(c, z)` per value, in the list's order (CONVENTIONS §9.3).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "DisjunctiveProof",
/// "description": "A disjunctive proof that a ciphertext encrypts one value of a public list: one `(c, z)` per value, in the list's order (CONVENTIONS §9.3).",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/SigmaProof"
/// },
/// "maxItems": 65,
/// "minItems": 1
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct DisjunctiveProof(pub ::std::vec::Vec<SigmaProof>);
impl ::std::ops::Deref for DisjunctiveProof {
type Target = ::std::vec::Vec<SigmaProof>;
fn deref(&self) -> &::std::vec::Vec<SigmaProof> {
&self.0
}
}
impl ::std::convert::From<DisjunctiveProof> for ::std::vec::Vec<SigmaProof> {
fn from(value: DisjunctiveProof) -> Self {
value.0
}
}
impl ::std::convert::From<::std::vec::Vec<SigmaProof>> for DisjunctiveProof {
fn from(value: ::std::vec::Vec<SigmaProof>) -> Self {
Self(value)
}
}
///`(a, b) = (r·G, M + r·Y)` under the election key `Y` (CONVENTIONS §9.2).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ElGamalCiphertext",
/// "description": "`(a, b) = (r·G, M + r·Y)` under the election key `Y` (CONVENTIONS §9.2).",
/// "type": "object",
/// "required": [
/// "a",
/// "b"
/// ],
/// "properties": {
/// "a": {
/// "$ref": "#/definitions/GroupElement"
/// },
/// "b": {
/// "$ref": "#/definitions/GroupElement"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ElGamalCiphertext {
pub a: GroupElement,
pub b: GroupElement,
}
impl ElGamalCiphertext {
pub fn builder() -> builder::ElGamalCiphertext {
Default::default()
}
}
///An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ElectionId",
/// "description": "An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.",
/// "type": "string",
/// "pattern": "^[A-Za-z0-9._-]{1,128}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ElectionId(::std::string::String);
impl ::std::ops::Deref for ElectionId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ElectionId> for ::std::string::String {
fn from(value: ElectionId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ElectionId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[A-Za-z0-9._-]{1,128}$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[A-Za-z0-9._-]{1,128}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ElectionId {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ElectionId {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ElectionId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ElectionId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The election key and each trustee's public verification key, computed from the qualified dealings (CONVENTIONS §9.6). Anyone can recompute it from the board.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ElectionKey",
/// "description": "The election key and each trustee's public verification key, computed from the qualified dealings (CONVENTIONS §9.6). Anyone can recompute it from the board.",
/// "type": "object",
/// "required": [
/// "key",
/// "qualified",
/// "verification"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/GroupElement"
/// },
/// "qualified": {
/// "description": "The dealers whose dealings the key is formed from.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "maxItems": 64,
/// "minItems": 1
/// },
/// "verification": {
/// "type": "array",
/// "items": {
/// "type": "object",
/// "required": [
/// "key",
/// "trustee"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/GroupElement"
/// },
/// "trustee": {
/// "$ref": "#/definitions/TrusteeIndex"
/// }
/// },
/// "additionalProperties": false
/// },
/// "maxItems": 64,
/// "minItems": 2
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ElectionKey {
pub key: GroupElement,
///The dealers whose dealings the key is formed from.
pub qualified: ::std::vec::Vec<TrusteeIndex>,
pub verification: ::std::vec::Vec<ElectionKeyVerificationItem>,
}
impl ElectionKey {
pub fn builder() -> builder::ElectionKey {
Default::default()
}
}
///`ElectionKeyVerificationItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "key",
/// "trustee"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/GroupElement"
/// },
/// "trustee": {
/// "$ref": "#/definitions/TrusteeIndex"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ElectionKeyVerificationItem {
pub key: GroupElement,
pub trustee: TrusteeIndex,
}
impl ElectionKeyVerificationItem {
pub fn builder() -> builder::ElectionKeyVerificationItem {
Default::default()
}
}
///An election's result, computable by anyone who can read its board from the board and the registration alone (VTI-VOT-070).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ElectionResult",
/// "description": "An election's result, computable by anyone who can read its board from the board and the registration alone (VTI-VOT-070).",
/// "type": "object",
/// "required": [
/// "ballotsCounted",
/// "electionId",
/// "head",
/// "manifestDigest",
/// "questions"
/// ],
/// "properties": {
/// "ballotsCounted": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "head": {
/// "description": "The head of the board as it stood at close: the result counts exactly its entries.",
/// "$ref": "#/definitions/BoardHead"
/// },
/// "manifestDigest": {
/// "$ref": "#/definitions/DigestMultibase"
/// },
/// "questions": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/QuestionResult"
/// }
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ElectionResult {
#[serde(rename = "ballotsCounted")]
pub ballots_counted: u64,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
///The head of the board as it stood at close: the result counts exactly its entries.
pub head: BoardHead,
#[serde(rename = "manifestDigest")]
pub manifest_digest: DigestMultibase,
pub questions: ::std::vec::Vec<QuestionResult>,
}
impl ElectionResult {
pub fn builder() -> builder::ElectionResult {
Default::default()
}
}
///A tallied-encrypted ballot: one EncryptedQuestion per manifest question, in the manifest's order. Never decrypted (VTI-VOT-064).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "EncryptedBallot",
/// "description": "A tallied-encrypted ballot: one EncryptedQuestion per manifest question, in the manifest's order. Never decrypted (VTI-VOT-064).",
/// "type": "object",
/// "required": [
/// "electionId",
/// "manifestDigest",
/// "questions"
/// ],
/// "properties": {
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "manifestDigest": {
/// "$ref": "#/definitions/DigestMultibase"
/// },
/// "questions": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/EncryptedQuestion"
/// },
/// "maxItems": 64,
/// "minItems": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct EncryptedBallot {
#[serde(rename = "electionId")]
pub election_id: ElectionId,
#[serde(rename = "manifestDigest")]
pub manifest_digest: DigestMultibase,
pub questions: ::std::vec::Vec<EncryptedQuestion>,
}
impl EncryptedBallot {
pub fn builder() -> builder::EncryptedBallot {
Default::default()
}
}
///A cast of a sealed or tallied-encrypted election: exactly one of `sealed` (the Ballot's JCS bytes sealed to the election key) or `encrypted`, with the tag and the attestation over the JCS bytes of whichever is present (CONVENTIONS §3.6, §9.5).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "EncryptedCast",
/// "description": "A cast of a sealed or tallied-encrypted election: exactly one of `sealed` (the Ballot's JCS bytes sealed to the election key) or `encrypted`, with the tag and the attestation over the JCS bytes of whichever is present (CONVENTIONS §3.6, §9.5).",
/// "type": "object",
/// "oneOf": [
/// {
/// "required": [
/// "sealed"
/// ]
/// },
/// {
/// "required": [
/// "encrypted"
/// ]
/// }
/// ],
/// "required": [
/// "attestation",
/// "tag"
/// ],
/// "properties": {
/// "attestation": {
/// "$ref": "#/definitions/Multibase"
/// },
/// "encrypted": {
/// "$ref": "#/definitions/EncryptedBallot"
/// },
/// "sealed": {
/// "$ref": "#/definitions/SealedPayload"
/// },
/// "tag": {
/// "$ref": "#/definitions/Multibase"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged, deny_unknown_fields)]
#[non_exhaustive]
pub enum EncryptedCast {
Variant0 {
attestation: Multibase,
sealed: SealedPayload,
tag: Multibase,
},
Variant1 {
attestation: Multibase,
encrypted: EncryptedBallot,
tag: Multibase,
},
}
///`EncryptedOption`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "EncryptedOption",
/// "type": "object",
/// "required": [
/// "ciphertext",
/// "proof"
/// ],
/// "properties": {
/// "ciphertext": {
/// "$ref": "#/definitions/ElGamalCiphertext"
/// },
/// "proof": {
/// "$ref": "#/definitions/DisjunctiveProof"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct EncryptedOption {
pub ciphertext: ElGamalCiphertext,
pub proof: DisjunctiveProof,
}
impl EncryptedOption {
pub fn builder() -> builder::EncryptedOption {
Default::default()
}
}
///One choice question of a tallied-encrypted ballot: per option, in the manifest's order, an encryption of 0 or 1 with its proof; and a proof that the selections sum to a count the question admits (CONVENTIONS §9.5).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "EncryptedQuestion",
/// "description": "One choice question of a tallied-encrypted ballot: per option, in the manifest's order, an encryption of 0 or 1 with its proof; and a proof that the selections sum to a count the question admits (CONVENTIONS §9.5).",
/// "type": "object",
/// "required": [
/// "options",
/// "question",
/// "sumProof"
/// ],
/// "properties": {
/// "options": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/EncryptedOption"
/// },
/// "maxItems": 64,
/// "minItems": 1
/// },
/// "question": {
/// "$ref": "#/definitions/Key"
/// },
/// "sumProof": {
/// "$ref": "#/definitions/DisjunctiveProof"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct EncryptedQuestion {
pub options: ::std::vec::Vec<EncryptedOption>,
pub question: Key,
#[serde(rename = "sumProof")]
pub sum_proof: DisjunctiveProof,
}
impl EncryptedQuestion {
pub fn builder() -> builder::EncryptedQuestion {
Default::default()
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ext",
/// "description": "Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.",
/// "type": "object",
/// "minProperties": 1,
/// "additionalProperties": true,
/// "propertyNames": {
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///A Ristretto group element: its 32-byte compression, multibase base58btc. Never the identity (CONVENTIONS §9.1).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "GroupElement",
/// "description": "A Ristretto group element: its 32-byte compression, multibase base58btc. Never the identity (CONVENTIONS §9.1).",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 2,
/// "pattern": "^z[1-9A-HJ-NP-Za-km-z]+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GroupElement(::std::string::String);
impl ::std::ops::Deref for GroupElement {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GroupElement> for ::std::string::String {
fn from(value: GroupElement) -> Self {
value.0
}
}
impl ::std::str::FromStr for GroupElement {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
if value.chars().count() < 2usize {
return Err("shorter than 2 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^z[1-9A-HJ-NP-Za-km-z]+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^z[1-9A-HJ-NP-Za-km-z]+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for GroupElement {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for GroupElement {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for GroupElement {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for GroupElement {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///A scalar mod the Ristretto group order: 32 canonical little-endian bytes, multibase base58btc (CONVENTIONS §9.1).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "GroupScalar",
/// "description": "A scalar mod the Ristretto group order: 32 canonical little-endian bytes, multibase base58btc (CONVENTIONS §9.1).",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 2,
/// "pattern": "^z[1-9A-HJ-NP-Za-km-z]+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GroupScalar(::std::string::String);
impl ::std::ops::Deref for GroupScalar {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GroupScalar> for ::std::string::String {
fn from(value: GroupScalar) -> Self {
value.0
}
}
impl ::std::str::FromStr for GroupScalar {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
if value.chars().count() < 2usize {
return Err("shorter than 2 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^z[1-9A-HJ-NP-Za-km-z]+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^z[1-9A-HJ-NP-Za-km-z]+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for GroupScalar {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for GroupScalar {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for GroupScalar {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for GroupScalar {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///A question or option key, unique within its manifest or question.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Key",
/// "description": "A question or option key, unique within its manifest or question.",
/// "type": "string",
/// "pattern": "^[A-Za-z0-9._-]{1,64}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Key(::std::string::String);
impl ::std::ops::Deref for Key {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Key> for ::std::string::String {
fn from(value: Key) -> Self {
value.0
}
}
impl ::std::str::FromStr for Key {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^[A-Za-z0-9._-]{1,64}$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[A-Za-z0-9._-]{1,64}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Key {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for Key {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for Key {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for Key {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`LifecycleEntryKind`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "enum": [
/// "opened",
/// "closed",
/// "closedEarly",
/// "cancelled"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum LifecycleEntryKind {
#[serde(rename = "opened")]
Opened,
#[serde(rename = "closed")]
Closed,
#[serde(rename = "closedEarly")]
ClosedEarly,
#[serde(rename = "cancelled")]
Cancelled,
}
impl ::std::fmt::Display for LifecycleEntryKind {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Opened => f.write_str("opened"),
Self::Closed => f.write_str("closed"),
Self::ClosedEarly => f.write_str("closedEarly"),
Self::Cancelled => f.write_str("cancelled"),
}
}
}
impl ::std::str::FromStr for LifecycleEntryKind {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"opened" => Ok(Self::Opened),
"closed" => Ok(Self::Closed),
"closedEarly" => Ok(Self::ClosedEarly),
"cancelled" => Ok(Self::Cancelled),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for LifecycleEntryKind {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for LifecycleEntryKind {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for LifecycleEntryKind {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///A binary value, multibase base58btc over the suite's canonical (compressed) encoding.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Multibase",
/// "description": "A binary value, multibase base58btc over the suite's canonical (compressed) encoding.",
/// "type": "string",
/// "maxLength": 16384,
/// "pattern": "^z[1-9A-HJ-NP-Za-km-z]+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Multibase(::std::string::String);
impl ::std::ops::Deref for Multibase {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Multibase> for ::std::string::String {
fn from(value: Multibase) -> Self {
value.0
}
}
impl ::std::str::FromStr for Multibase {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 16384usize {
return Err("longer than 16384 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^z[1-9A-HJ-NP-Za-km-z]+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^z[1-9A-HJ-NP-Za-km-z]+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Multibase {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for Multibase {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for Multibase {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for Multibase {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Trustee `trustee`'s share of one decryption, `d = x_j·a`, with a Chaum–Pedersen proof against its verification key (CONVENTIONS §9.7).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "PartialDecryption",
/// "description": "Trustee `trustee`'s share of one decryption, `d = x_j·a`, with a Chaum–Pedersen proof against its verification key (CONVENTIONS §9.7).",
/// "type": "object",
/// "required": [
/// "d",
/// "proof",
/// "target"
/// ],
/// "properties": {
/// "d": {
/// "$ref": "#/definitions/GroupElement"
/// },
/// "proof": {
/// "$ref": "#/definitions/SigmaProof"
/// },
/// "target": {
/// "$ref": "#/definitions/DecryptionTarget"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PartialDecryption {
pub d: GroupElement,
pub proof: SigmaProof,
pub target: DecryptionTarget,
}
impl PartialDecryption {
pub fn builder() -> builder::PartialDecryption {
Default::default()
}
}
///Reads a range of an election board's entries, against the current head or against an earlier tree size.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/voting/board/read/0.1",
/// "title": "Payload",
/// "description": "Reads a range of an election board's entries, against the current head or against an earlier tree size.",
/// "type": "object",
/// "required": [
/// "community",
/// "electionId",
/// "from",
/// "limit"
/// ],
/// "properties": {
/// "community": {
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "from": {
/// "description": "The index of the first entry to return.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "limit": {
/// "description": "The most entries to return.",
/// "type": "integer",
/// "maximum": 1000.0,
/// "minimum": 1.0
/// },
/// "treeSize": {
/// "description": "Read against the board as it stood at this size — the size of a head the reader holds. At most the current size. Absent: the current size.",
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The community's DID.
pub community: PayloadCommunity,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The index of the first entry to return.
pub from: u64,
///The most entries to return.
pub limit: ::std::num::NonZeroU64,
///Read against the board as it stood at this size — the size of a head the reader holds. At most the current size. Absent: the current size.
#[serde(
rename = "treeSize",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub tree_size: ::std::option::Option<u64>,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The community's DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCommunity(::std::string::String);
impl ::std::ops::Deref for PayloadCommunity {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCommunity> for ::std::string::String {
fn from(value: PayloadCommunity) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCommunity {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadCommunity {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///One question's totals. `choice`: selections per option. `ranking`: per option, how many ballots placed it at each position (index 0 = first). `score`: per option, the sum and the number of ballots that scored it. `text`: the answers, in board order, withheld (`withheld: true`) below the manifest's `textReleaseThreshold`. `abstained` counts ballots that left the question unanswered.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "QuestionResult",
/// "description": "One question's totals. `choice`: selections per option. `ranking`: per option, how many ballots placed it at each position (index 0 = first). `score`: per option, the sum and the number of ballots that scored it. `text`: the answers, in board order, withheld (`withheld: true`) below the manifest's `textReleaseThreshold`. `abstained` counts ballots that left the question unanswered.",
/// "type": "object",
/// "required": [
/// "abstained",
/// "question"
/// ],
/// "properties": {
/// "abstained": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "choice": {
/// "type": "object",
/// "additionalProperties": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "propertyNames": {
/// "$ref": "#/definitions/Key"
/// }
/// },
/// "question": {
/// "$ref": "#/definitions/Key"
/// },
/// "ranking": {
/// "type": "object",
/// "additionalProperties": {
/// "type": "array",
/// "items": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "propertyNames": {
/// "$ref": "#/definitions/Key"
/// }
/// },
/// "score": {
/// "type": "object",
/// "additionalProperties": {
/// "type": "object",
/// "required": [
/// "count",
/// "sum"
/// ],
/// "properties": {
/// "count": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sum": {
/// "type": "integer"
/// }
/// },
/// "additionalProperties": false
/// },
/// "propertyNames": {
/// "$ref": "#/definitions/Key"
/// }
/// },
/// "text": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 4096
/// }
/// },
/// "withheld": {
/// "type": "boolean"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct QuestionResult {
pub abstained: u64,
#[serde(
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub choice: ::std::collections::HashMap<Key, u64>,
pub question: Key,
#[serde(
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub ranking: ::std::collections::HashMap<Key, ::std::vec::Vec<u64>>,
#[serde(
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub score: ::std::collections::HashMap<Key, QuestionResultScoreValue>,
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub text: ::std::vec::Vec<QuestionResultTextItem>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub withheld: ::std::option::Option<bool>,
}
impl QuestionResult {
pub fn builder() -> builder::QuestionResult {
Default::default()
}
}
///`QuestionResultScoreValue`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "count",
/// "sum"
/// ],
/// "properties": {
/// "count": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sum": {
/// "type": "integer"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct QuestionResultScoreValue {
pub count: u64,
pub sum: i64,
}
impl QuestionResultScoreValue {
pub fn builder() -> builder::QuestionResultScoreValue {
Default::default()
}
}
///`QuestionResultTextItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 4096
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct QuestionResultTextItem(::std::string::String);
impl ::std::ops::Deref for QuestionResultTextItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<QuestionResultTextItem> for ::std::string::String {
fn from(value: QuestionResultTextItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for QuestionResultTextItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 4096usize {
return Err("longer than 4096 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for QuestionResultTextItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for QuestionResultTextItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for QuestionResultTextItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for QuestionResultTextItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`Response`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "type": "object",
/// "required": [
/// "entries",
/// "treeSize"
/// ],
/// "properties": {
/// "entries": {
/// "description": "Consecutive entries from `from`, in board order.",
/// "type": "array",
/// "items": {
/// "type": "object",
/// "required": [
/// "entry",
/// "index"
/// ],
/// "properties": {
/// "entry": {
/// "$ref": "#/definitions/BoardEntry"
/// },
/// "index": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
/// },
/// "maxItems": 1000
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "next": {
/// "description": "The `from` of the next page. Absent when the page reaches `treeSize`.",
/// "type": "integer",
/// "minimum": 1.0
/// },
/// "treeSize": {
/// "description": "The tree size the page was read against. No entry at or beyond it is returned.",
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///Consecutive entries from `from`, in board order.
pub entries: ::std::vec::Vec<ResponseEntriesItem>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The `from` of the next page. Absent when the page reaches `treeSize`.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub next: ::std::option::Option<::std::num::NonZeroU64>,
///The tree size the page was read against. No entry at or beyond it is returned.
#[serde(rename = "treeSize")]
pub tree_size: u64,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`ResponseEntriesItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "entry",
/// "index"
/// ],
/// "properties": {
/// "entry": {
/// "$ref": "#/definitions/BoardEntry"
/// },
/// "index": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseEntriesItem {
pub entry: BoardEntry,
pub index: u64,
}
impl ResponseEntriesItem {
pub fn builder() -> builder::ResponseEntriesItem {
Default::default()
}
}
///Bytes sealed to a key: a random group element encrypted as `kem`, and the bytes under ChaCha20-Poly1305 with a key derived from it, multibase base58btc (CONVENTIONS §9.4).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "SealedPayload",
/// "description": "Bytes sealed to a key: a random group element encrypted as `kem`, and the bytes under ChaCha20-Poly1305 with a key derived from it, multibase base58btc (CONVENTIONS §9.4).",
/// "type": "object",
/// "required": [
/// "body",
/// "kem"
/// ],
/// "properties": {
/// "body": {
/// "type": "string",
/// "maxLength": 131072,
/// "minLength": 2,
/// "pattern": "^z[1-9A-HJ-NP-Za-km-z]+$"
/// },
/// "kem": {
/// "$ref": "#/definitions/ElGamalCiphertext"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct SealedPayload {
pub body: SealedPayloadBody,
pub kem: ElGamalCiphertext,
}
impl SealedPayload {
pub fn builder() -> builder::SealedPayload {
Default::default()
}
}
///`SealedPayloadBody`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 131072,
/// "minLength": 2,
/// "pattern": "^z[1-9A-HJ-NP-Za-km-z]+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct SealedPayloadBody(::std::string::String);
impl ::std::ops::Deref for SealedPayloadBody {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<SealedPayloadBody> for ::std::string::String {
fn from(value: SealedPayloadBody) -> Self {
value.0
}
}
impl ::std::str::FromStr for SealedPayloadBody {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 131072usize {
return Err("longer than 131072 characters".into());
}
if value.chars().count() < 2usize {
return Err("shorter than 2 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^z[1-9A-HJ-NP-Za-km-z]+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^z[1-9A-HJ-NP-Za-km-z]+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for SealedPayloadBody {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for SealedPayloadBody {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for SealedPayloadBody {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for SealedPayloadBody {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`SealedShare`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "SealedShare",
/// "type": "object",
/// "required": [
/// "recipient",
/// "share"
/// ],
/// "properties": {
/// "recipient": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "share": {
/// "$ref": "#/definitions/SealedPayload"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct SealedShare {
pub recipient: TrusteeIndex,
pub share: SealedPayload,
}
impl SealedShare {
pub fn builder() -> builder::SealedShare {
Default::default()
}
}
///A non-interactive sigma proof as its challenge and response `(c, z)` (Schnorr or Chaum–Pedersen; CONVENTIONS §9.3).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "SigmaProof",
/// "description": "A non-interactive sigma proof as its challenge and response `(c, z)` (Schnorr or Chaum–Pedersen; CONVENTIONS §9.3).",
/// "type": "object",
/// "required": [
/// "c",
/// "z"
/// ],
/// "properties": {
/// "c": {
/// "$ref": "#/definitions/GroupScalar"
/// },
/// "z": {
/// "$ref": "#/definitions/GroupScalar"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct SigmaProof {
pub c: GroupScalar,
pub z: GroupScalar,
}
impl SigmaProof {
pub fn builder() -> builder::SigmaProof {
Default::default()
}
}
///The group element a trustee's shares are sealed to, with a Schnorr proof of knowledge of its discrete log (CONVENTIONS §9.6).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "TransportKey",
/// "description": "The group element a trustee's shares are sealed to, with a Schnorr proof of knowledge of its discrete log (CONVENTIONS §9.6).",
/// "type": "object",
/// "required": [
/// "key",
/// "pok",
/// "trustee"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/GroupElement"
/// },
/// "pok": {
/// "$ref": "#/definitions/SigmaProof"
/// },
/// "trustee": {
/// "$ref": "#/definitions/TrusteeIndex"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct TransportKey {
pub key: GroupElement,
pub pok: SigmaProof,
pub trustee: TrusteeIndex,
}
impl TransportKey {
pub fn builder() -> builder::TransportKey {
Default::default()
}
}
///A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "TrusteeIndex",
/// "description": "A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.",
/// "type": "integer",
/// "maximum": 64.0,
/// "minimum": 1.0
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct TrusteeIndex(pub ::std::num::NonZeroU64);
impl ::std::ops::Deref for TrusteeIndex {
type Target = ::std::num::NonZeroU64;
fn deref(&self) -> &::std::num::NonZeroU64 {
&self.0
}
}
impl ::std::convert::From<TrusteeIndex> for ::std::num::NonZeroU64 {
fn from(value: TrusteeIndex) -> Self {
value.0
}
}
impl ::std::convert::From<::std::num::NonZeroU64> for TrusteeIndex {
fn from(value: ::std::num::NonZeroU64) -> Self {
Self(value)
}
}
impl ::std::str::FromStr for TrusteeIndex {
type Err = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn from_str(value: &str) -> ::std::result::Result<Self, Self::Err> {
Ok(Self(value.parse()?))
}
}
impl ::std::convert::TryFrom<&str> for TrusteeIndex {
type Error = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn try_from(value: &str) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::convert::TryFrom<String> for TrusteeIndex {
type Error = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn try_from(value: String) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::fmt::Display for TrusteeIndex {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Answer {
abstain: ::std::result::Result<
::std::option::Option<::serde_json::Value>,
::std::string::String,
>,
choice:
::std::result::Result<::std::option::Option<Vec<super::Key>>, ::std::string::String>,
question: ::std::result::Result<super::Key, ::std::string::String>,
ranking:
::std::result::Result<::std::option::Option<Vec<super::Key>>, ::std::string::String>,
scores: ::std::result::Result<
::std::collections::HashMap<super::Key, i64>,
::std::string::String,
>,
text:
::std::result::Result<::std::option::Option<super::AnswerText>, ::std::string::String>,
}
impl ::std::default::Default for Answer {
fn default() -> Self {
Self {
abstain: Ok(Default::default()),
choice: Ok(Default::default()),
question: Err("no value supplied for question".to_string()),
ranking: Ok(Default::default()),
scores: Ok(Default::default()),
text: Ok(Default::default()),
}
}
}
impl Answer {
pub fn abstain<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::serde_json::Value>>,
T::Error: ::std::fmt::Display,
{
self.abstain = value
.try_into()
.map_err(|e| format!("error converting supplied value for abstain: {e}"));
self
}
pub fn choice<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<Vec<super::Key>>>,
T::Error: ::std::fmt::Display,
{
self.choice = value
.try_into()
.map_err(|e| format!("error converting supplied value for choice: {e}"));
self
}
pub fn question<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Key>,
T::Error: ::std::fmt::Display,
{
self.question = value
.try_into()
.map_err(|e| format!("error converting supplied value for question: {e}"));
self
}
pub fn ranking<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<Vec<super::Key>>>,
T::Error: ::std::fmt::Display,
{
self.ranking = value
.try_into()
.map_err(|e| format!("error converting supplied value for ranking: {e}"));
self
}
pub fn scores<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::collections::HashMap<super::Key, i64>>,
T::Error: ::std::fmt::Display,
{
self.scores = value
.try_into()
.map_err(|e| format!("error converting supplied value for scores: {e}"));
self
}
pub fn text<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::AnswerText>>,
T::Error: ::std::fmt::Display,
{
self.text = value
.try_into()
.map_err(|e| format!("error converting supplied value for text: {e}"));
self
}
}
impl ::std::convert::TryFrom<Answer> for super::Answer {
type Error = super::error::ConversionError;
fn try_from(value: Answer) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
abstain: value.abstain?,
choice: value.choice?,
question: value.question?,
ranking: value.ranking?,
scores: value.scores?,
text: value.text?,
})
}
}
impl ::std::convert::From<super::Answer> for Answer {
fn from(value: super::Answer) -> Self {
Self {
abstain: Ok(value.abstain),
choice: Ok(value.choice),
question: Ok(value.question),
ranking: Ok(value.ranking),
scores: Ok(value.scores),
text: Ok(value.text),
}
}
}
#[derive(Clone, Debug)]
pub struct Ballot {
answers: ::std::result::Result<::std::vec::Vec<super::Answer>, ::std::string::String>,
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
manifest_digest: ::std::result::Result<super::DigestMultibase, ::std::string::String>,
}
impl ::std::default::Default for Ballot {
fn default() -> Self {
Self {
answers: Err("no value supplied for answers".to_string()),
election_id: Err("no value supplied for election_id".to_string()),
manifest_digest: Err("no value supplied for manifest_digest".to_string()),
}
}
}
impl Ballot {
pub fn answers<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Answer>>,
T::Error: ::std::fmt::Display,
{
self.answers = value
.try_into()
.map_err(|e| format!("error converting supplied value for answers: {e}"));
self
}
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn manifest_digest<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DigestMultibase>,
T::Error: ::std::fmt::Display,
{
self.manifest_digest = value
.try_into()
.map_err(|e| format!("error converting supplied value for manifest_digest: {e}"));
self
}
}
impl ::std::convert::TryFrom<Ballot> for super::Ballot {
type Error = super::error::ConversionError;
fn try_from(value: Ballot) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
answers: value.answers?,
election_id: value.election_id?,
manifest_digest: value.manifest_digest?,
})
}
}
impl ::std::convert::From<super::Ballot> for Ballot {
fn from(value: super::Ballot) -> Self {
Self {
answers: Ok(value.answers),
election_id: Ok(value.election_id),
manifest_digest: Ok(value.manifest_digest),
}
}
}
#[derive(Clone, Debug)]
pub struct BoardHead {
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
issued_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
root_hash: ::std::result::Result<super::DigestMultibase, ::std::string::String>,
tree_size: ::std::result::Result<u64, ::std::string::String>,
}
impl ::std::default::Default for BoardHead {
fn default() -> Self {
Self {
election_id: Err("no value supplied for election_id".to_string()),
issued_at: Err("no value supplied for issued_at".to_string()),
root_hash: Err("no value supplied for root_hash".to_string()),
tree_size: Err("no value supplied for tree_size".to_string()),
}
}
}
impl BoardHead {
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn issued_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.issued_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for issued_at: {e}"));
self
}
pub fn root_hash<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DigestMultibase>,
T::Error: ::std::fmt::Display,
{
self.root_hash = value
.try_into()
.map_err(|e| format!("error converting supplied value for root_hash: {e}"));
self
}
pub fn tree_size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.tree_size = value
.try_into()
.map_err(|e| format!("error converting supplied value for tree_size: {e}"));
self
}
}
impl ::std::convert::TryFrom<BoardHead> for super::BoardHead {
type Error = super::error::ConversionError;
fn try_from(
value: BoardHead,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
election_id: value.election_id?,
issued_at: value.issued_at?,
root_hash: value.root_hash?,
tree_size: value.tree_size?,
})
}
}
impl ::std::convert::From<super::BoardHead> for BoardHead {
fn from(value: super::BoardHead) -> Self {
Self {
election_id: Ok(value.election_id),
issued_at: Ok(value.issued_at),
root_hash: Ok(value.root_hash),
tree_size: Ok(value.tree_size),
}
}
}
#[derive(Clone, Debug)]
pub struct Cast {
attestation: ::std::result::Result<super::Multibase, ::std::string::String>,
ballot: ::std::result::Result<super::Ballot, ::std::string::String>,
tag: ::std::result::Result<super::Multibase, ::std::string::String>,
}
impl ::std::default::Default for Cast {
fn default() -> Self {
Self {
attestation: Err("no value supplied for attestation".to_string()),
ballot: Err("no value supplied for ballot".to_string()),
tag: Err("no value supplied for tag".to_string()),
}
}
}
impl Cast {
pub fn attestation<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Multibase>,
T::Error: ::std::fmt::Display,
{
self.attestation = value
.try_into()
.map_err(|e| format!("error converting supplied value for attestation: {e}"));
self
}
pub fn ballot<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Ballot>,
T::Error: ::std::fmt::Display,
{
self.ballot = value
.try_into()
.map_err(|e| format!("error converting supplied value for ballot: {e}"));
self
}
pub fn tag<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Multibase>,
T::Error: ::std::fmt::Display,
{
self.tag = value
.try_into()
.map_err(|e| format!("error converting supplied value for tag: {e}"));
self
}
}
impl ::std::convert::TryFrom<Cast> for super::Cast {
type Error = super::error::ConversionError;
fn try_from(value: Cast) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
attestation: value.attestation?,
ballot: value.ballot?,
tag: value.tag?,
})
}
}
impl ::std::convert::From<super::Cast> for Cast {
fn from(value: super::Cast) -> Self {
Self {
attestation: Ok(value.attestation),
ballot: Ok(value.ballot),
tag: Ok(value.tag),
}
}
}
#[derive(Clone, Debug)]
pub struct Dealing {
commitments:
::std::result::Result<::std::vec::Vec<super::GroupElement>, ::std::string::String>,
dealer: ::std::result::Result<super::TrusteeIndex, ::std::string::String>,
pok: ::std::result::Result<super::SigmaProof, ::std::string::String>,
shares: ::std::result::Result<::std::vec::Vec<super::SealedShare>, ::std::string::String>,
}
impl ::std::default::Default for Dealing {
fn default() -> Self {
Self {
commitments: Err("no value supplied for commitments".to_string()),
dealer: Err("no value supplied for dealer".to_string()),
pok: Err("no value supplied for pok".to_string()),
shares: Err("no value supplied for shares".to_string()),
}
}
}
impl Dealing {
pub fn commitments<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::GroupElement>>,
T::Error: ::std::fmt::Display,
{
self.commitments = value
.try_into()
.map_err(|e| format!("error converting supplied value for commitments: {e}"));
self
}
pub fn dealer<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TrusteeIndex>,
T::Error: ::std::fmt::Display,
{
self.dealer = value
.try_into()
.map_err(|e| format!("error converting supplied value for dealer: {e}"));
self
}
pub fn pok<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SigmaProof>,
T::Error: ::std::fmt::Display,
{
self.pok = value
.try_into()
.map_err(|e| format!("error converting supplied value for pok: {e}"));
self
}
pub fn shares<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::SealedShare>>,
T::Error: ::std::fmt::Display,
{
self.shares = value
.try_into()
.map_err(|e| format!("error converting supplied value for shares: {e}"));
self
}
}
impl ::std::convert::TryFrom<Dealing> for super::Dealing {
type Error = super::error::ConversionError;
fn try_from(value: Dealing) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
commitments: value.commitments?,
dealer: value.dealer?,
pok: value.pok?,
shares: value.shares?,
})
}
}
impl ::std::convert::From<super::Dealing> for Dealing {
fn from(value: super::Dealing) -> Self {
Self {
commitments: Ok(value.commitments),
dealer: Ok(value.dealer),
pok: Ok(value.pok),
shares: Ok(value.shares),
}
}
}
#[derive(Clone, Debug)]
pub struct ElGamalCiphertext {
a: ::std::result::Result<super::GroupElement, ::std::string::String>,
b: ::std::result::Result<super::GroupElement, ::std::string::String>,
}
impl ::std::default::Default for ElGamalCiphertext {
fn default() -> Self {
Self {
a: Err("no value supplied for a".to_string()),
b: Err("no value supplied for b".to_string()),
}
}
}
impl ElGamalCiphertext {
pub fn a<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupElement>,
T::Error: ::std::fmt::Display,
{
self.a = value
.try_into()
.map_err(|e| format!("error converting supplied value for a: {e}"));
self
}
pub fn b<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupElement>,
T::Error: ::std::fmt::Display,
{
self.b = value
.try_into()
.map_err(|e| format!("error converting supplied value for b: {e}"));
self
}
}
impl ::std::convert::TryFrom<ElGamalCiphertext> for super::ElGamalCiphertext {
type Error = super::error::ConversionError;
fn try_from(
value: ElGamalCiphertext,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
a: value.a?,
b: value.b?,
})
}
}
impl ::std::convert::From<super::ElGamalCiphertext> for ElGamalCiphertext {
fn from(value: super::ElGamalCiphertext) -> Self {
Self {
a: Ok(value.a),
b: Ok(value.b),
}
}
}
#[derive(Clone, Debug)]
pub struct ElectionKey {
key: ::std::result::Result<super::GroupElement, ::std::string::String>,
qualified:
::std::result::Result<::std::vec::Vec<super::TrusteeIndex>, ::std::string::String>,
verification: ::std::result::Result<
::std::vec::Vec<super::ElectionKeyVerificationItem>,
::std::string::String,
>,
}
impl ::std::default::Default for ElectionKey {
fn default() -> Self {
Self {
key: Err("no value supplied for key".to_string()),
qualified: Err("no value supplied for qualified".to_string()),
verification: Err("no value supplied for verification".to_string()),
}
}
}
impl ElectionKey {
pub fn key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupElement>,
T::Error: ::std::fmt::Display,
{
self.key = value
.try_into()
.map_err(|e| format!("error converting supplied value for key: {e}"));
self
}
pub fn qualified<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::TrusteeIndex>>,
T::Error: ::std::fmt::Display,
{
self.qualified = value
.try_into()
.map_err(|e| format!("error converting supplied value for qualified: {e}"));
self
}
pub fn verification<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ElectionKeyVerificationItem>>,
T::Error: ::std::fmt::Display,
{
self.verification = value
.try_into()
.map_err(|e| format!("error converting supplied value for verification: {e}"));
self
}
}
impl ::std::convert::TryFrom<ElectionKey> for super::ElectionKey {
type Error = super::error::ConversionError;
fn try_from(
value: ElectionKey,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
key: value.key?,
qualified: value.qualified?,
verification: value.verification?,
})
}
}
impl ::std::convert::From<super::ElectionKey> for ElectionKey {
fn from(value: super::ElectionKey) -> Self {
Self {
key: Ok(value.key),
qualified: Ok(value.qualified),
verification: Ok(value.verification),
}
}
}
#[derive(Clone, Debug)]
pub struct ElectionKeyVerificationItem {
key: ::std::result::Result<super::GroupElement, ::std::string::String>,
trustee: ::std::result::Result<super::TrusteeIndex, ::std::string::String>,
}
impl ::std::default::Default for ElectionKeyVerificationItem {
fn default() -> Self {
Self {
key: Err("no value supplied for key".to_string()),
trustee: Err("no value supplied for trustee".to_string()),
}
}
}
impl ElectionKeyVerificationItem {
pub fn key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupElement>,
T::Error: ::std::fmt::Display,
{
self.key = value
.try_into()
.map_err(|e| format!("error converting supplied value for key: {e}"));
self
}
pub fn trustee<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TrusteeIndex>,
T::Error: ::std::fmt::Display,
{
self.trustee = value
.try_into()
.map_err(|e| format!("error converting supplied value for trustee: {e}"));
self
}
}
impl ::std::convert::TryFrom<ElectionKeyVerificationItem> for super::ElectionKeyVerificationItem {
type Error = super::error::ConversionError;
fn try_from(
value: ElectionKeyVerificationItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
key: value.key?,
trustee: value.trustee?,
})
}
}
impl ::std::convert::From<super::ElectionKeyVerificationItem> for ElectionKeyVerificationItem {
fn from(value: super::ElectionKeyVerificationItem) -> Self {
Self {
key: Ok(value.key),
trustee: Ok(value.trustee),
}
}
}
#[derive(Clone, Debug)]
pub struct ElectionResult {
ballots_counted: ::std::result::Result<u64, ::std::string::String>,
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
head: ::std::result::Result<super::BoardHead, ::std::string::String>,
manifest_digest: ::std::result::Result<super::DigestMultibase, ::std::string::String>,
questions:
::std::result::Result<::std::vec::Vec<super::QuestionResult>, ::std::string::String>,
}
impl ::std::default::Default for ElectionResult {
fn default() -> Self {
Self {
ballots_counted: Err("no value supplied for ballots_counted".to_string()),
election_id: Err("no value supplied for election_id".to_string()),
head: Err("no value supplied for head".to_string()),
manifest_digest: Err("no value supplied for manifest_digest".to_string()),
questions: Err("no value supplied for questions".to_string()),
}
}
}
impl ElectionResult {
pub fn ballots_counted<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.ballots_counted = value
.try_into()
.map_err(|e| format!("error converting supplied value for ballots_counted: {e}"));
self
}
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn head<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BoardHead>,
T::Error: ::std::fmt::Display,
{
self.head = value
.try_into()
.map_err(|e| format!("error converting supplied value for head: {e}"));
self
}
pub fn manifest_digest<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DigestMultibase>,
T::Error: ::std::fmt::Display,
{
self.manifest_digest = value
.try_into()
.map_err(|e| format!("error converting supplied value for manifest_digest: {e}"));
self
}
pub fn questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::QuestionResult>>,
T::Error: ::std::fmt::Display,
{
self.questions = value
.try_into()
.map_err(|e| format!("error converting supplied value for questions: {e}"));
self
}
}
impl ::std::convert::TryFrom<ElectionResult> for super::ElectionResult {
type Error = super::error::ConversionError;
fn try_from(
value: ElectionResult,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
ballots_counted: value.ballots_counted?,
election_id: value.election_id?,
head: value.head?,
manifest_digest: value.manifest_digest?,
questions: value.questions?,
})
}
}
impl ::std::convert::From<super::ElectionResult> for ElectionResult {
fn from(value: super::ElectionResult) -> Self {
Self {
ballots_counted: Ok(value.ballots_counted),
election_id: Ok(value.election_id),
head: Ok(value.head),
manifest_digest: Ok(value.manifest_digest),
questions: Ok(value.questions),
}
}
}
#[derive(Clone, Debug)]
pub struct EncryptedBallot {
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
manifest_digest: ::std::result::Result<super::DigestMultibase, ::std::string::String>,
questions:
::std::result::Result<::std::vec::Vec<super::EncryptedQuestion>, ::std::string::String>,
}
impl ::std::default::Default for EncryptedBallot {
fn default() -> Self {
Self {
election_id: Err("no value supplied for election_id".to_string()),
manifest_digest: Err("no value supplied for manifest_digest".to_string()),
questions: Err("no value supplied for questions".to_string()),
}
}
}
impl EncryptedBallot {
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn manifest_digest<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DigestMultibase>,
T::Error: ::std::fmt::Display,
{
self.manifest_digest = value
.try_into()
.map_err(|e| format!("error converting supplied value for manifest_digest: {e}"));
self
}
pub fn questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::EncryptedQuestion>>,
T::Error: ::std::fmt::Display,
{
self.questions = value
.try_into()
.map_err(|e| format!("error converting supplied value for questions: {e}"));
self
}
}
impl ::std::convert::TryFrom<EncryptedBallot> for super::EncryptedBallot {
type Error = super::error::ConversionError;
fn try_from(
value: EncryptedBallot,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
election_id: value.election_id?,
manifest_digest: value.manifest_digest?,
questions: value.questions?,
})
}
}
impl ::std::convert::From<super::EncryptedBallot> for EncryptedBallot {
fn from(value: super::EncryptedBallot) -> Self {
Self {
election_id: Ok(value.election_id),
manifest_digest: Ok(value.manifest_digest),
questions: Ok(value.questions),
}
}
}
#[derive(Clone, Debug)]
pub struct EncryptedOption {
ciphertext: ::std::result::Result<super::ElGamalCiphertext, ::std::string::String>,
proof: ::std::result::Result<super::DisjunctiveProof, ::std::string::String>,
}
impl ::std::default::Default for EncryptedOption {
fn default() -> Self {
Self {
ciphertext: Err("no value supplied for ciphertext".to_string()),
proof: Err("no value supplied for proof".to_string()),
}
}
}
impl EncryptedOption {
pub fn ciphertext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElGamalCiphertext>,
T::Error: ::std::fmt::Display,
{
self.ciphertext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ciphertext: {e}"));
self
}
pub fn proof<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DisjunctiveProof>,
T::Error: ::std::fmt::Display,
{
self.proof = value
.try_into()
.map_err(|e| format!("error converting supplied value for proof: {e}"));
self
}
}
impl ::std::convert::TryFrom<EncryptedOption> for super::EncryptedOption {
type Error = super::error::ConversionError;
fn try_from(
value: EncryptedOption,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
ciphertext: value.ciphertext?,
proof: value.proof?,
})
}
}
impl ::std::convert::From<super::EncryptedOption> for EncryptedOption {
fn from(value: super::EncryptedOption) -> Self {
Self {
ciphertext: Ok(value.ciphertext),
proof: Ok(value.proof),
}
}
}
#[derive(Clone, Debug)]
pub struct EncryptedQuestion {
options:
::std::result::Result<::std::vec::Vec<super::EncryptedOption>, ::std::string::String>,
question: ::std::result::Result<super::Key, ::std::string::String>,
sum_proof: ::std::result::Result<super::DisjunctiveProof, ::std::string::String>,
}
impl ::std::default::Default for EncryptedQuestion {
fn default() -> Self {
Self {
options: Err("no value supplied for options".to_string()),
question: Err("no value supplied for question".to_string()),
sum_proof: Err("no value supplied for sum_proof".to_string()),
}
}
}
impl EncryptedQuestion {
pub fn options<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::EncryptedOption>>,
T::Error: ::std::fmt::Display,
{
self.options = value
.try_into()
.map_err(|e| format!("error converting supplied value for options: {e}"));
self
}
pub fn question<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Key>,
T::Error: ::std::fmt::Display,
{
self.question = value
.try_into()
.map_err(|e| format!("error converting supplied value for question: {e}"));
self
}
pub fn sum_proof<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DisjunctiveProof>,
T::Error: ::std::fmt::Display,
{
self.sum_proof = value
.try_into()
.map_err(|e| format!("error converting supplied value for sum_proof: {e}"));
self
}
}
impl ::std::convert::TryFrom<EncryptedQuestion> for super::EncryptedQuestion {
type Error = super::error::ConversionError;
fn try_from(
value: EncryptedQuestion,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
options: value.options?,
question: value.question?,
sum_proof: value.sum_proof?,
})
}
}
impl ::std::convert::From<super::EncryptedQuestion> for EncryptedQuestion {
fn from(value: super::EncryptedQuestion) -> Self {
Self {
options: Ok(value.options),
question: Ok(value.question),
sum_proof: Ok(value.sum_proof),
}
}
}
#[derive(Clone, Debug)]
pub struct PartialDecryption {
d: ::std::result::Result<super::GroupElement, ::std::string::String>,
proof: ::std::result::Result<super::SigmaProof, ::std::string::String>,
target: ::std::result::Result<super::DecryptionTarget, ::std::string::String>,
}
impl ::std::default::Default for PartialDecryption {
fn default() -> Self {
Self {
d: Err("no value supplied for d".to_string()),
proof: Err("no value supplied for proof".to_string()),
target: Err("no value supplied for target".to_string()),
}
}
}
impl PartialDecryption {
pub fn d<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupElement>,
T::Error: ::std::fmt::Display,
{
self.d = value
.try_into()
.map_err(|e| format!("error converting supplied value for d: {e}"));
self
}
pub fn proof<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SigmaProof>,
T::Error: ::std::fmt::Display,
{
self.proof = value
.try_into()
.map_err(|e| format!("error converting supplied value for proof: {e}"));
self
}
pub fn target<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DecryptionTarget>,
T::Error: ::std::fmt::Display,
{
self.target = value
.try_into()
.map_err(|e| format!("error converting supplied value for target: {e}"));
self
}
}
impl ::std::convert::TryFrom<PartialDecryption> for super::PartialDecryption {
type Error = super::error::ConversionError;
fn try_from(
value: PartialDecryption,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
d: value.d?,
proof: value.proof?,
target: value.target?,
})
}
}
impl ::std::convert::From<super::PartialDecryption> for PartialDecryption {
fn from(value: super::PartialDecryption) -> Self {
Self {
d: Ok(value.d),
proof: Ok(value.proof),
target: Ok(value.target),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
community: ::std::result::Result<super::PayloadCommunity, ::std::string::String>,
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
from: ::std::result::Result<u64, ::std::string::String>,
limit: ::std::result::Result<::std::num::NonZeroU64, ::std::string::String>,
tree_size: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
community: Err("no value supplied for community".to_string()),
election_id: Err("no value supplied for election_id".to_string()),
ext: Ok(Default::default()),
from: Err("no value supplied for from".to_string()),
limit: Err("no value supplied for limit".to_string()),
tree_size: Ok(Default::default()),
}
}
}
impl Payload {
pub fn community<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadCommunity>,
T::Error: ::std::fmt::Display,
{
self.community = value
.try_into()
.map_err(|e| format!("error converting supplied value for community: {e}"));
self
}
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn from<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.from = value
.try_into()
.map_err(|e| format!("error converting supplied value for from: {e}"));
self
}
pub fn limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::num::NonZeroU64>,
T::Error: ::std::fmt::Display,
{
self.limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for limit: {e}"));
self
}
pub fn tree_size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.tree_size = value
.try_into()
.map_err(|e| format!("error converting supplied value for tree_size: {e}"));
self
}
}
impl ::std::convert::TryFrom<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
community: value.community?,
election_id: value.election_id?,
ext: value.ext?,
from: value.from?,
limit: value.limit?,
tree_size: value.tree_size?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
community: Ok(value.community),
election_id: Ok(value.election_id),
ext: Ok(value.ext),
from: Ok(value.from),
limit: Ok(value.limit),
tree_size: Ok(value.tree_size),
}
}
}
#[derive(Clone, Debug)]
pub struct QuestionResult {
abstained: ::std::result::Result<u64, ::std::string::String>,
choice: ::std::result::Result<
::std::collections::HashMap<super::Key, u64>,
::std::string::String,
>,
question: ::std::result::Result<super::Key, ::std::string::String>,
ranking: ::std::result::Result<
::std::collections::HashMap<super::Key, ::std::vec::Vec<u64>>,
::std::string::String,
>,
score: ::std::result::Result<
::std::collections::HashMap<super::Key, super::QuestionResultScoreValue>,
::std::string::String,
>,
text: ::std::result::Result<
::std::vec::Vec<super::QuestionResultTextItem>,
::std::string::String,
>,
withheld: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
}
impl ::std::default::Default for QuestionResult {
fn default() -> Self {
Self {
abstained: Err("no value supplied for abstained".to_string()),
choice: Ok(Default::default()),
question: Err("no value supplied for question".to_string()),
ranking: Ok(Default::default()),
score: Ok(Default::default()),
text: Ok(Default::default()),
withheld: Ok(Default::default()),
}
}
}
impl QuestionResult {
pub fn abstained<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.abstained = value
.try_into()
.map_err(|e| format!("error converting supplied value for abstained: {e}"));
self
}
pub fn choice<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::collections::HashMap<super::Key, u64>>,
T::Error: ::std::fmt::Display,
{
self.choice = value
.try_into()
.map_err(|e| format!("error converting supplied value for choice: {e}"));
self
}
pub fn question<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Key>,
T::Error: ::std::fmt::Display,
{
self.question = value
.try_into()
.map_err(|e| format!("error converting supplied value for question: {e}"));
self
}
pub fn ranking<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<super::Key, ::std::vec::Vec<u64>>,
>,
T::Error: ::std::fmt::Display,
{
self.ranking = value
.try_into()
.map_err(|e| format!("error converting supplied value for ranking: {e}"));
self
}
pub fn score<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<super::Key, super::QuestionResultScoreValue>,
>,
T::Error: ::std::fmt::Display,
{
self.score = value
.try_into()
.map_err(|e| format!("error converting supplied value for score: {e}"));
self
}
pub fn text<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::QuestionResultTextItem>>,
T::Error: ::std::fmt::Display,
{
self.text = value
.try_into()
.map_err(|e| format!("error converting supplied value for text: {e}"));
self
}
pub fn withheld<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.withheld = value
.try_into()
.map_err(|e| format!("error converting supplied value for withheld: {e}"));
self
}
}
impl ::std::convert::TryFrom<QuestionResult> for super::QuestionResult {
type Error = super::error::ConversionError;
fn try_from(
value: QuestionResult,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
abstained: value.abstained?,
choice: value.choice?,
question: value.question?,
ranking: value.ranking?,
score: value.score?,
text: value.text?,
withheld: value.withheld?,
})
}
}
impl ::std::convert::From<super::QuestionResult> for QuestionResult {
fn from(value: super::QuestionResult) -> Self {
Self {
abstained: Ok(value.abstained),
choice: Ok(value.choice),
question: Ok(value.question),
ranking: Ok(value.ranking),
score: Ok(value.score),
text: Ok(value.text),
withheld: Ok(value.withheld),
}
}
}
#[derive(Clone, Debug)]
pub struct QuestionResultScoreValue {
count: ::std::result::Result<u64, ::std::string::String>,
sum: ::std::result::Result<i64, ::std::string::String>,
}
impl ::std::default::Default for QuestionResultScoreValue {
fn default() -> Self {
Self {
count: Err("no value supplied for count".to_string()),
sum: Err("no value supplied for sum".to_string()),
}
}
}
impl QuestionResultScoreValue {
pub fn count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.count = value
.try_into()
.map_err(|e| format!("error converting supplied value for count: {e}"));
self
}
pub fn sum<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.sum = value
.try_into()
.map_err(|e| format!("error converting supplied value for sum: {e}"));
self
}
}
impl ::std::convert::TryFrom<QuestionResultScoreValue> for super::QuestionResultScoreValue {
type Error = super::error::ConversionError;
fn try_from(
value: QuestionResultScoreValue,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
count: value.count?,
sum: value.sum?,
})
}
}
impl ::std::convert::From<super::QuestionResultScoreValue> for QuestionResultScoreValue {
fn from(value: super::QuestionResultScoreValue) -> Self {
Self {
count: Ok(value.count),
sum: Ok(value.sum),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
entries: ::std::result::Result<
::std::vec::Vec<super::ResponseEntriesItem>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
next: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
tree_size: ::std::result::Result<u64, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
entries: Err("no value supplied for entries".to_string()),
ext: Ok(Default::default()),
next: Ok(Default::default()),
tree_size: Err("no value supplied for tree_size".to_string()),
}
}
}
impl Response {
pub fn entries<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ResponseEntriesItem>>,
T::Error: ::std::fmt::Display,
{
self.entries = value
.try_into()
.map_err(|e| format!("error converting supplied value for entries: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn next<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.next = value
.try_into()
.map_err(|e| format!("error converting supplied value for next: {e}"));
self
}
pub fn tree_size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.tree_size = value
.try_into()
.map_err(|e| format!("error converting supplied value for tree_size: {e}"));
self
}
}
impl ::std::convert::TryFrom<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
entries: value.entries?,
ext: value.ext?,
next: value.next?,
tree_size: value.tree_size?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
entries: Ok(value.entries),
ext: Ok(value.ext),
next: Ok(value.next),
tree_size: Ok(value.tree_size),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseEntriesItem {
entry: ::std::result::Result<super::BoardEntry, ::std::string::String>,
index: ::std::result::Result<u64, ::std::string::String>,
}
impl ::std::default::Default for ResponseEntriesItem {
fn default() -> Self {
Self {
entry: Err("no value supplied for entry".to_string()),
index: Err("no value supplied for index".to_string()),
}
}
}
impl ResponseEntriesItem {
pub fn entry<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BoardEntry>,
T::Error: ::std::fmt::Display,
{
self.entry = value
.try_into()
.map_err(|e| format!("error converting supplied value for entry: {e}"));
self
}
pub fn index<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.index = value
.try_into()
.map_err(|e| format!("error converting supplied value for index: {e}"));
self
}
}
impl ::std::convert::TryFrom<ResponseEntriesItem> for super::ResponseEntriesItem {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseEntriesItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
entry: value.entry?,
index: value.index?,
})
}
}
impl ::std::convert::From<super::ResponseEntriesItem> for ResponseEntriesItem {
fn from(value: super::ResponseEntriesItem) -> Self {
Self {
entry: Ok(value.entry),
index: Ok(value.index),
}
}
}
#[derive(Clone, Debug)]
pub struct SealedPayload {
body: ::std::result::Result<super::SealedPayloadBody, ::std::string::String>,
kem: ::std::result::Result<super::ElGamalCiphertext, ::std::string::String>,
}
impl ::std::default::Default for SealedPayload {
fn default() -> Self {
Self {
body: Err("no value supplied for body".to_string()),
kem: Err("no value supplied for kem".to_string()),
}
}
}
impl SealedPayload {
pub fn body<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SealedPayloadBody>,
T::Error: ::std::fmt::Display,
{
self.body = value
.try_into()
.map_err(|e| format!("error converting supplied value for body: {e}"));
self
}
pub fn kem<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElGamalCiphertext>,
T::Error: ::std::fmt::Display,
{
self.kem = value
.try_into()
.map_err(|e| format!("error converting supplied value for kem: {e}"));
self
}
}
impl ::std::convert::TryFrom<SealedPayload> for super::SealedPayload {
type Error = super::error::ConversionError;
fn try_from(
value: SealedPayload,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
body: value.body?,
kem: value.kem?,
})
}
}
impl ::std::convert::From<super::SealedPayload> for SealedPayload {
fn from(value: super::SealedPayload) -> Self {
Self {
body: Ok(value.body),
kem: Ok(value.kem),
}
}
}
#[derive(Clone, Debug)]
pub struct SealedShare {
recipient: ::std::result::Result<super::TrusteeIndex, ::std::string::String>,
share: ::std::result::Result<super::SealedPayload, ::std::string::String>,
}
impl ::std::default::Default for SealedShare {
fn default() -> Self {
Self {
recipient: Err("no value supplied for recipient".to_string()),
share: Err("no value supplied for share".to_string()),
}
}
}
impl SealedShare {
pub fn recipient<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TrusteeIndex>,
T::Error: ::std::fmt::Display,
{
self.recipient = value
.try_into()
.map_err(|e| format!("error converting supplied value for recipient: {e}"));
self
}
pub fn share<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SealedPayload>,
T::Error: ::std::fmt::Display,
{
self.share = value
.try_into()
.map_err(|e| format!("error converting supplied value for share: {e}"));
self
}
}
impl ::std::convert::TryFrom<SealedShare> for super::SealedShare {
type Error = super::error::ConversionError;
fn try_from(
value: SealedShare,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
recipient: value.recipient?,
share: value.share?,
})
}
}
impl ::std::convert::From<super::SealedShare> for SealedShare {
fn from(value: super::SealedShare) -> Self {
Self {
recipient: Ok(value.recipient),
share: Ok(value.share),
}
}
}
#[derive(Clone, Debug)]
pub struct SigmaProof {
c: ::std::result::Result<super::GroupScalar, ::std::string::String>,
z: ::std::result::Result<super::GroupScalar, ::std::string::String>,
}
impl ::std::default::Default for SigmaProof {
fn default() -> Self {
Self {
c: Err("no value supplied for c".to_string()),
z: Err("no value supplied for z".to_string()),
}
}
}
impl SigmaProof {
pub fn c<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupScalar>,
T::Error: ::std::fmt::Display,
{
self.c = value
.try_into()
.map_err(|e| format!("error converting supplied value for c: {e}"));
self
}
pub fn z<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupScalar>,
T::Error: ::std::fmt::Display,
{
self.z = value
.try_into()
.map_err(|e| format!("error converting supplied value for z: {e}"));
self
}
}
impl ::std::convert::TryFrom<SigmaProof> for super::SigmaProof {
type Error = super::error::ConversionError;
fn try_from(
value: SigmaProof,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
c: value.c?,
z: value.z?,
})
}
}
impl ::std::convert::From<super::SigmaProof> for SigmaProof {
fn from(value: super::SigmaProof) -> Self {
Self {
c: Ok(value.c),
z: Ok(value.z),
}
}
}
#[derive(Clone, Debug)]
pub struct TransportKey {
key: ::std::result::Result<super::GroupElement, ::std::string::String>,
pok: ::std::result::Result<super::SigmaProof, ::std::string::String>,
trustee: ::std::result::Result<super::TrusteeIndex, ::std::string::String>,
}
impl ::std::default::Default for TransportKey {
fn default() -> Self {
Self {
key: Err("no value supplied for key".to_string()),
pok: Err("no value supplied for pok".to_string()),
trustee: Err("no value supplied for trustee".to_string()),
}
}
}
impl TransportKey {
pub fn key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupElement>,
T::Error: ::std::fmt::Display,
{
self.key = value
.try_into()
.map_err(|e| format!("error converting supplied value for key: {e}"));
self
}
pub fn pok<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SigmaProof>,
T::Error: ::std::fmt::Display,
{
self.pok = value
.try_into()
.map_err(|e| format!("error converting supplied value for pok: {e}"));
self
}
pub fn trustee<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TrusteeIndex>,
T::Error: ::std::fmt::Display,
{
self.trustee = value
.try_into()
.map_err(|e| format!("error converting supplied value for trustee: {e}"));
self
}
}
impl ::std::convert::TryFrom<TransportKey> for super::TransportKey {
type Error = super::error::ConversionError;
fn try_from(
value: TransportKey,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
key: value.key?,
pok: value.pok?,
trustee: value.trustee?,
})
}
}
impl ::std::convert::From<super::TransportKey> for TransportKey {
fn from(value: super::TransportKey) -> Self {
Self {
key: Ok(value.key),
pok: Ok(value.pok),
trustee: Ok(value.trustee),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/voting/board/read/0.1";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"Answer\": {\n \"additionalProperties\": false,\n \"description\": \"The answer to one question. Exactly one member besides `question` is present, matching the question's type, or `abstain` for an optional question left unanswered.\",\n \"maxProperties\": 2,\n \"minProperties\": 2,\n \"properties\": {\n \"abstain\": {\n \"const\": true\n },\n \"choice\": {\n \"items\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"ranking\": {\n \"items\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"scores\": {\n \"additionalProperties\": {\n \"type\": \"integer\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"text\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"question\"\n ],\n \"title\": \"Answer\",\n \"type\": \"object\"\n },\n \"Ballot\": {\n \"additionalProperties\": false,\n \"description\": \"An open ballot: one answer per question of the manifest, in any order. The bytes a cast's proof binds are the RFC 8785 (JCS) canonicalization of this object as received.\",\n \"properties\": {\n \"answers\": {\n \"items\": {\n \"$ref\": \"#/$defs/Answer\"\n },\n \"maxItems\": 128,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n }\n },\n \"required\": [\n \"electionId\",\n \"manifestDigest\",\n \"answers\"\n ],\n \"title\": \"Ballot\",\n \"type\": \"object\"\n },\n \"BoardEntry\": {\n \"description\": \"One leaf of a board. A leaf's hash is the RFC 9162 leaf hash of the JCS canonicalization of this object. Entries carry no time of arrival: the order is the board's, and a timestamp would hand anyone who reads the board the timing the registrar's log would need to pair a ticket with its cast.\",\n \"oneOf\": [\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"cast\": {\n \"$ref\": \"#/$defs/Cast\"\n },\n \"kind\": {\n \"const\": \"cast\"\n }\n },\n \"required\": [\n \"kind\",\n \"cast\"\n ],\n \"title\": \"CastEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"description\": \"The cast at `replaces` is no longer counted: a later cast under the same tag is.\",\n \"properties\": {\n \"by\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"kind\": {\n \"const\": \"replaced\"\n },\n \"replaces\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"tag\": {\n \"$ref\": \"#/$defs/Multibase\"\n }\n },\n \"required\": [\n \"kind\",\n \"tag\",\n \"replaces\",\n \"by\"\n ],\n \"title\": \"ReplacementEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"at\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"kind\": {\n \"enum\": [\n \"opened\",\n \"closed\",\n \"closedEarly\",\n \"cancelled\"\n ]\n }\n },\n \"required\": [\n \"kind\",\n \"at\"\n ],\n \"title\": \"LifecycleEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"kind\": {\n \"const\": \"result\"\n },\n \"result\": {\n \"$ref\": \"#/$defs/ElectionResult\"\n }\n },\n \"required\": [\n \"kind\",\n \"result\"\n ],\n \"title\": \"ResultEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"cast\": {\n \"$ref\": \"#/$defs/EncryptedCast\"\n },\n \"kind\": {\n \"const\": \"encryptedCast\"\n }\n },\n \"required\": [\n \"kind\",\n \"cast\"\n ],\n \"title\": \"EncryptedCastEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"kind\": {\n \"const\": \"transportKey\"\n },\n \"transportKey\": {\n \"$ref\": \"#/$defs/TransportKey\"\n }\n },\n \"required\": [\n \"kind\",\n \"transportKey\"\n ],\n \"title\": \"TransportKeyEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"dealing\": {\n \"$ref\": \"#/$defs/Dealing\"\n },\n \"kind\": {\n \"const\": \"dealing\"\n }\n },\n \"required\": [\n \"kind\",\n \"dealing\"\n ],\n \"title\": \"DealingEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"complaints\": {\n \"items\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n },\n \"kind\": {\n \"const\": \"confirmation\"\n },\n \"trustee\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n }\n },\n \"required\": [\n \"kind\",\n \"trustee\",\n \"complaints\"\n ],\n \"title\": \"ConfirmationEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"dealer\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"kind\": {\n \"const\": \"justification\"\n },\n \"recipient\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"share\": {\n \"$ref\": \"#/$defs/GroupScalar\"\n }\n },\n \"required\": [\n \"kind\",\n \"dealer\",\n \"recipient\",\n \"share\"\n ],\n \"title\": \"JustificationEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"electionKey\": {\n \"$ref\": \"#/$defs/ElectionKey\"\n },\n \"kind\": {\n \"const\": \"electionKey\"\n }\n },\n \"required\": [\n \"kind\",\n \"electionKey\"\n ],\n \"title\": \"ElectionKeyEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"kind\": {\n \"const\": \"partials\"\n },\n \"partials\": {\n \"items\": {\n \"$ref\": \"#/$defs/PartialDecryption\"\n },\n \"maxItems\": 100000,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"trustee\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n }\n },\n \"required\": [\n \"kind\",\n \"trustee\",\n \"partials\"\n ],\n \"title\": \"PartialDecryptionsEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"ballot\": {\n \"$ref\": \"#/$defs/Ballot\"\n },\n \"kind\": {\n \"const\": \"unsealed\"\n },\n \"leafIndex\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"kind\",\n \"leafIndex\",\n \"ballot\"\n ],\n \"title\": \"UnsealedEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"description\": \"A sealed cast that did not open, or opened to no valid ballot: not counted (CONVENTIONS §9.7).\",\n \"properties\": {\n \"kind\": {\n \"const\": \"spoiled\"\n },\n \"leafIndex\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"kind\",\n \"leafIndex\"\n ],\n \"title\": \"SpoiledEntry\",\n \"type\": \"object\"\n }\n ],\n \"title\": \"BoardEntry\"\n },\n \"BoardHead\": {\n \"additionalProperties\": false,\n \"description\": \"A board's tree head (RFC 9162 §2.1). A head is signed by being carried in a document the ballot box signs; whoever keeps a head keeps that whole document.\",\n \"properties\": {\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"issuedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"rootHash\": {\n \"$ref\": \"#/$defs/DigestMultibase\",\n \"description\": \"The RFC 9162 Merkle tree hash (SHA-256) of the first `treeSize` entries, as a multihash.\"\n },\n \"treeSize\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"electionId\",\n \"treeSize\",\n \"rootHash\",\n \"issuedAt\"\n ],\n \"title\": \"BoardHead\",\n \"type\": \"object\"\n },\n \"Cast\": {\n \"additionalProperties\": false,\n \"description\": \"A ballot and the PCS attestation that admits it (VTI-VOT-030). `attestation` is the suite's canonical encoding of the attestation made for the election point with the ballot context bound in (CONVENTIONS §3); `tag` repeats its tag so a ballot box can refuse a duplicate before the pairing check.\",\n \"properties\": {\n \"attestation\": {\n \"$ref\": \"#/$defs/Multibase\"\n },\n \"ballot\": {\n \"$ref\": \"#/$defs/Ballot\"\n },\n \"tag\": {\n \"$ref\": \"#/$defs/Multibase\"\n }\n },\n \"required\": [\n \"ballot\",\n \"tag\",\n \"attestation\"\n ],\n \"title\": \"Cast\",\n \"type\": \"object\"\n },\n \"Dealing\": {\n \"additionalProperties\": false,\n \"description\": \"A trustee's contribution to the election key: Feldman commitments to its polynomial, a proof of knowledge of the constant term, and one share per trustee sealed to that trustee's transport key (CONVENTIONS §9.6).\",\n \"properties\": {\n \"commitments\": {\n \"items\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"maxItems\": 64,\n \"minItems\": 2,\n \"type\": \"array\"\n },\n \"dealer\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"pok\": {\n \"$ref\": \"#/$defs/SigmaProof\"\n },\n \"shares\": {\n \"items\": {\n \"$ref\": \"#/$defs/SealedShare\"\n },\n \"maxItems\": 64,\n \"minItems\": 2,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"dealer\",\n \"commitments\",\n \"pok\",\n \"shares\"\n ],\n \"title\": \"Dealing\",\n \"type\": \"object\"\n },\n \"DecryptionTarget\": {\n \"additionalProperties\": false,\n \"description\": \"What a partial decryption decrypts: the sealed cast at a board leaf, or the total of one option of one question.\",\n \"oneOf\": [\n {\n \"required\": [\n \"leafIndex\"\n ]\n },\n {\n \"required\": [\n \"question\",\n \"option\"\n ]\n }\n ],\n \"properties\": {\n \"ciphertext\": {\n \"$ref\": \"#/$defs/ElGamalCiphertext\"\n },\n \"leafIndex\": {\n \"description\": \"A sealed cast's board leaf.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"option\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n }\n },\n \"required\": [\n \"ciphertext\"\n ],\n \"title\": \"DecryptionTarget\",\n \"type\": \"object\"\n },\n \"DigestMultibase\": {\n \"description\": \"A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\\n\\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\\n\\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\\n\\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \\\"interoperability is not guaranteed between implementations using such values\\\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.\",\n \"examples\": [\n \"zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\"\n ],\n \"minLength\": 16,\n \"pattern\": \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\",\n \"title\": \"DigestMultibase\",\n \"type\": \"string\"\n },\n \"DisjunctiveProof\": {\n \"description\": \"A disjunctive proof that a ciphertext encrypts one value of a public list: one `(c, z)` per value, in the list's order (CONVENTIONS §9.3).\",\n \"items\": {\n \"$ref\": \"#/$defs/SigmaProof\"\n },\n \"maxItems\": 65,\n \"minItems\": 1,\n \"title\": \"DisjunctiveProof\",\n \"type\": \"array\"\n },\n \"ElGamalCiphertext\": {\n \"additionalProperties\": false,\n \"description\": \"`(a, b) = (r·G, M + r·Y)` under the election key `Y` (CONVENTIONS §9.2).\",\n \"properties\": {\n \"a\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"b\": {\n \"$ref\": \"#/$defs/GroupElement\"\n }\n },\n \"required\": [\n \"a\",\n \"b\"\n ],\n \"title\": \"ElGamalCiphertext\",\n \"type\": \"object\"\n },\n \"ElectionId\": {\n \"description\": \"An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,128}$\",\n \"title\": \"ElectionId\",\n \"type\": \"string\"\n },\n \"ElectionKey\": {\n \"additionalProperties\": false,\n \"description\": \"The election key and each trustee's public verification key, computed from the qualified dealings (CONVENTIONS §9.6). Anyone can recompute it from the board.\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"qualified\": {\n \"description\": \"The dealers whose dealings the key is formed from.\",\n \"items\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"verification\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"trustee\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n }\n },\n \"required\": [\n \"trustee\",\n \"key\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 64,\n \"minItems\": 2,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"key\",\n \"qualified\",\n \"verification\"\n ],\n \"title\": \"ElectionKey\",\n \"type\": \"object\"\n },\n \"ElectionResult\": {\n \"additionalProperties\": false,\n \"description\": \"An election's result, computable by anyone who can read its board from the board and the registration alone (VTI-VOT-070).\",\n \"properties\": {\n \"ballotsCounted\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"head\": {\n \"$ref\": \"#/$defs/BoardHead\",\n \"description\": \"The head of the board as it stood at close: the result counts exactly its entries.\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n },\n \"questions\": {\n \"items\": {\n \"$ref\": \"#/$defs/QuestionResult\"\n },\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"electionId\",\n \"manifestDigest\",\n \"ballotsCounted\",\n \"questions\",\n \"head\"\n ],\n \"title\": \"ElectionResult\",\n \"type\": \"object\"\n },\n \"EncryptedBallot\": {\n \"additionalProperties\": false,\n \"description\": \"A tallied-encrypted ballot: one EncryptedQuestion per manifest question, in the manifest's order. Never decrypted (VTI-VOT-064).\",\n \"properties\": {\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n },\n \"questions\": {\n \"items\": {\n \"$ref\": \"#/$defs/EncryptedQuestion\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"electionId\",\n \"manifestDigest\",\n \"questions\"\n ],\n \"title\": \"EncryptedBallot\",\n \"type\": \"object\"\n },\n \"EncryptedCast\": {\n \"additionalProperties\": false,\n \"description\": \"A cast of a sealed or tallied-encrypted election: exactly one of `sealed` (the Ballot's JCS bytes sealed to the election key) or `encrypted`, with the tag and the attestation over the JCS bytes of whichever is present (CONVENTIONS §3.6, §9.5).\",\n \"oneOf\": [\n {\n \"required\": [\n \"sealed\"\n ]\n },\n {\n \"required\": [\n \"encrypted\"\n ]\n }\n ],\n \"properties\": {\n \"attestation\": {\n \"$ref\": \"#/$defs/Multibase\"\n },\n \"encrypted\": {\n \"$ref\": \"#/$defs/EncryptedBallot\"\n },\n \"sealed\": {\n \"$ref\": \"#/$defs/SealedPayload\"\n },\n \"tag\": {\n \"$ref\": \"#/$defs/Multibase\"\n }\n },\n \"required\": [\n \"tag\",\n \"attestation\"\n ],\n \"title\": \"EncryptedCast\",\n \"type\": \"object\"\n },\n \"EncryptedOption\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"ciphertext\": {\n \"$ref\": \"#/$defs/ElGamalCiphertext\"\n },\n \"proof\": {\n \"$ref\": \"#/$defs/DisjunctiveProof\"\n }\n },\n \"required\": [\n \"ciphertext\",\n \"proof\"\n ],\n \"title\": \"EncryptedOption\",\n \"type\": \"object\"\n },\n \"EncryptedQuestion\": {\n \"additionalProperties\": false,\n \"description\": \"One choice question of a tallied-encrypted ballot: per option, in the manifest's order, an encryption of 0 or 1 with its proof; and a proof that the selections sum to a count the question admits (CONVENTIONS §9.5).\",\n \"properties\": {\n \"options\": {\n \"items\": {\n \"$ref\": \"#/$defs/EncryptedOption\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"sumProof\": {\n \"$ref\": \"#/$defs/DisjunctiveProof\"\n }\n },\n \"required\": [\n \"question\",\n \"options\",\n \"sumProof\"\n ],\n \"title\": \"EncryptedQuestion\",\n \"type\": \"object\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"GroupElement\": {\n \"description\": \"A Ristretto group element: its 32-byte compression, multibase base58btc. Never the identity (CONVENTIONS §9.1).\",\n \"maxLength\": 64,\n \"minLength\": 2,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"title\": \"GroupElement\",\n \"type\": \"string\"\n },\n \"GroupScalar\": {\n \"description\": \"A scalar mod the Ristretto group order: 32 canonical little-endian bytes, multibase base58btc (CONVENTIONS §9.1).\",\n \"maxLength\": 64,\n \"minLength\": 2,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"title\": \"GroupScalar\",\n \"type\": \"string\"\n },\n \"Key\": {\n \"description\": \"A question or option key, unique within its manifest or question.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,64}$\",\n \"title\": \"Key\",\n \"type\": \"string\"\n },\n \"Multibase\": {\n \"description\": \"A binary value, multibase base58btc over the suite's canonical (compressed) encoding.\",\n \"maxLength\": 16384,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"title\": \"Multibase\",\n \"type\": \"string\"\n },\n \"PartialDecryption\": {\n \"additionalProperties\": false,\n \"description\": \"Trustee `trustee`'s share of one decryption, `d = x_j·a`, with a Chaum–Pedersen proof against its verification key (CONVENTIONS §9.7).\",\n \"properties\": {\n \"d\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"proof\": {\n \"$ref\": \"#/$defs/SigmaProof\"\n },\n \"target\": {\n \"$ref\": \"#/$defs/DecryptionTarget\"\n }\n },\n \"required\": [\n \"target\",\n \"d\",\n \"proof\"\n ],\n \"title\": \"PartialDecryption\",\n \"type\": \"object\"\n },\n \"QuestionResult\": {\n \"additionalProperties\": false,\n \"description\": \"One question's totals. `choice`: selections per option. `ranking`: per option, how many ballots placed it at each position (index 0 = first). `score`: per option, the sum and the number of ballots that scored it. `text`: the answers, in board order, withheld (`withheld: true`) below the manifest's `textReleaseThreshold`. `abstained` counts ballots that left the question unanswered.\",\n \"properties\": {\n \"abstained\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"choice\": {\n \"additionalProperties\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"ranking\": {\n \"additionalProperties\": {\n \"items\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"type\": \"array\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"score\": {\n \"additionalProperties\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"count\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sum\": {\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"sum\",\n \"count\"\n ],\n \"type\": \"object\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"text\": {\n \"items\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n },\n \"type\": \"array\"\n },\n \"withheld\": {\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"question\",\n \"abstained\"\n ],\n \"title\": \"QuestionResult\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"entries\": {\n \"description\": \"Consecutive entries from `from`, in board order.\",\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"entry\": {\n \"$ref\": \"#/$defs/BoardEntry\"\n },\n \"index\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"index\",\n \"entry\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 1000,\n \"type\": \"array\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"next\": {\n \"description\": \"The `from` of the next page. Absent when the page reaches `treeSize`.\",\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"treeSize\": {\n \"description\": \"The tree size the page was read against. No entry at or beyond it is returned.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"treeSize\",\n \"entries\"\n ],\n \"title\": \"Voting — Board Read — response payload\",\n \"type\": \"object\"\n },\n \"SealedPayload\": {\n \"additionalProperties\": false,\n \"description\": \"Bytes sealed to a key: a random group element encrypted as `kem`, and the bytes under ChaCha20-Poly1305 with a key derived from it, multibase base58btc (CONVENTIONS §9.4).\",\n \"properties\": {\n \"body\": {\n \"maxLength\": 131072,\n \"minLength\": 2,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"type\": \"string\"\n },\n \"kem\": {\n \"$ref\": \"#/$defs/ElGamalCiphertext\"\n }\n },\n \"required\": [\n \"kem\",\n \"body\"\n ],\n \"title\": \"SealedPayload\",\n \"type\": \"object\"\n },\n \"SealedShare\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"recipient\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"share\": {\n \"$ref\": \"#/$defs/SealedPayload\"\n }\n },\n \"required\": [\n \"recipient\",\n \"share\"\n ],\n \"title\": \"SealedShare\",\n \"type\": \"object\"\n },\n \"SigmaProof\": {\n \"additionalProperties\": false,\n \"description\": \"A non-interactive sigma proof as its challenge and response `(c, z)` (Schnorr or Chaum–Pedersen; CONVENTIONS §9.3).\",\n \"properties\": {\n \"c\": {\n \"$ref\": \"#/$defs/GroupScalar\"\n },\n \"z\": {\n \"$ref\": \"#/$defs/GroupScalar\"\n }\n },\n \"required\": [\n \"c\",\n \"z\"\n ],\n \"title\": \"SigmaProof\",\n \"type\": \"object\"\n },\n \"TransportKey\": {\n \"additionalProperties\": false,\n \"description\": \"The group element a trustee's shares are sealed to, with a Schnorr proof of knowledge of its discrete log (CONVENTIONS §9.6).\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"pok\": {\n \"$ref\": \"#/$defs/SigmaProof\"\n },\n \"trustee\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n }\n },\n \"required\": [\n \"trustee\",\n \"key\",\n \"pok\"\n ],\n \"title\": \"TransportKey\",\n \"type\": \"object\"\n },\n \"TrusteeIndex\": {\n \"description\": \"A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.\",\n \"maximum\": 64,\n \"minimum\": 1,\n \"title\": \"TrusteeIndex\",\n \"type\": \"integer\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/voting/board/read/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Reads a range of an election board's entries, against the current head or against an earlier tree size.\",\n \"properties\": {\n \"community\": {\n \"description\": \"The community's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"from\": {\n \"description\": \"The index of the first entry to return.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"limit\": {\n \"description\": \"The most entries to return.\",\n \"maximum\": 1000,\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"treeSize\": {\n \"description\": \"Read against the board as it stood at this size — the size of a head the reader holds. At most the current size. Absent: the current size.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"community\",\n \"electionId\",\n \"from\",\n \"limit\"\n ],\n \"title\": \"Voting — Board Read — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/voting/board/read/0.1#response";
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"Answer\": {\n \"additionalProperties\": false,\n \"description\": \"The answer to one question. Exactly one member besides `question` is present, matching the question's type, or `abstain` for an optional question left unanswered.\",\n \"maxProperties\": 2,\n \"minProperties\": 2,\n \"properties\": {\n \"abstain\": {\n \"const\": true\n },\n \"choice\": {\n \"items\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"ranking\": {\n \"items\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"scores\": {\n \"additionalProperties\": {\n \"type\": \"integer\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"text\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"question\"\n ],\n \"title\": \"Answer\",\n \"type\": \"object\"\n },\n \"Ballot\": {\n \"additionalProperties\": false,\n \"description\": \"An open ballot: one answer per question of the manifest, in any order. The bytes a cast's proof binds are the RFC 8785 (JCS) canonicalization of this object as received.\",\n \"properties\": {\n \"answers\": {\n \"items\": {\n \"$ref\": \"#/$defs/Answer\"\n },\n \"maxItems\": 128,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n }\n },\n \"required\": [\n \"electionId\",\n \"manifestDigest\",\n \"answers\"\n ],\n \"title\": \"Ballot\",\n \"type\": \"object\"\n },\n \"BoardEntry\": {\n \"description\": \"One leaf of a board. A leaf's hash is the RFC 9162 leaf hash of the JCS canonicalization of this object. Entries carry no time of arrival: the order is the board's, and a timestamp would hand anyone who reads the board the timing the registrar's log would need to pair a ticket with its cast.\",\n \"oneOf\": [\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"cast\": {\n \"$ref\": \"#/$defs/Cast\"\n },\n \"kind\": {\n \"const\": \"cast\"\n }\n },\n \"required\": [\n \"kind\",\n \"cast\"\n ],\n \"title\": \"CastEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"description\": \"The cast at `replaces` is no longer counted: a later cast under the same tag is.\",\n \"properties\": {\n \"by\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"kind\": {\n \"const\": \"replaced\"\n },\n \"replaces\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"tag\": {\n \"$ref\": \"#/$defs/Multibase\"\n }\n },\n \"required\": [\n \"kind\",\n \"tag\",\n \"replaces\",\n \"by\"\n ],\n \"title\": \"ReplacementEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"at\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"kind\": {\n \"enum\": [\n \"opened\",\n \"closed\",\n \"closedEarly\",\n \"cancelled\"\n ]\n }\n },\n \"required\": [\n \"kind\",\n \"at\"\n ],\n \"title\": \"LifecycleEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"kind\": {\n \"const\": \"result\"\n },\n \"result\": {\n \"$ref\": \"#/$defs/ElectionResult\"\n }\n },\n \"required\": [\n \"kind\",\n \"result\"\n ],\n \"title\": \"ResultEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"cast\": {\n \"$ref\": \"#/$defs/EncryptedCast\"\n },\n \"kind\": {\n \"const\": \"encryptedCast\"\n }\n },\n \"required\": [\n \"kind\",\n \"cast\"\n ],\n \"title\": \"EncryptedCastEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"kind\": {\n \"const\": \"transportKey\"\n },\n \"transportKey\": {\n \"$ref\": \"#/$defs/TransportKey\"\n }\n },\n \"required\": [\n \"kind\",\n \"transportKey\"\n ],\n \"title\": \"TransportKeyEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"dealing\": {\n \"$ref\": \"#/$defs/Dealing\"\n },\n \"kind\": {\n \"const\": \"dealing\"\n }\n },\n \"required\": [\n \"kind\",\n \"dealing\"\n ],\n \"title\": \"DealingEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"complaints\": {\n \"items\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n },\n \"kind\": {\n \"const\": \"confirmation\"\n },\n \"trustee\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n }\n },\n \"required\": [\n \"kind\",\n \"trustee\",\n \"complaints\"\n ],\n \"title\": \"ConfirmationEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"dealer\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"kind\": {\n \"const\": \"justification\"\n },\n \"recipient\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"share\": {\n \"$ref\": \"#/$defs/GroupScalar\"\n }\n },\n \"required\": [\n \"kind\",\n \"dealer\",\n \"recipient\",\n \"share\"\n ],\n \"title\": \"JustificationEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"electionKey\": {\n \"$ref\": \"#/$defs/ElectionKey\"\n },\n \"kind\": {\n \"const\": \"electionKey\"\n }\n },\n \"required\": [\n \"kind\",\n \"electionKey\"\n ],\n \"title\": \"ElectionKeyEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"kind\": {\n \"const\": \"partials\"\n },\n \"partials\": {\n \"items\": {\n \"$ref\": \"#/$defs/PartialDecryption\"\n },\n \"maxItems\": 100000,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"trustee\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n }\n },\n \"required\": [\n \"kind\",\n \"trustee\",\n \"partials\"\n ],\n \"title\": \"PartialDecryptionsEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"ballot\": {\n \"$ref\": \"#/$defs/Ballot\"\n },\n \"kind\": {\n \"const\": \"unsealed\"\n },\n \"leafIndex\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"kind\",\n \"leafIndex\",\n \"ballot\"\n ],\n \"title\": \"UnsealedEntry\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"description\": \"A sealed cast that did not open, or opened to no valid ballot: not counted (CONVENTIONS §9.7).\",\n \"properties\": {\n \"kind\": {\n \"const\": \"spoiled\"\n },\n \"leafIndex\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"kind\",\n \"leafIndex\"\n ],\n \"title\": \"SpoiledEntry\",\n \"type\": \"object\"\n }\n ],\n \"title\": \"BoardEntry\"\n },\n \"BoardHead\": {\n \"additionalProperties\": false,\n \"description\": \"A board's tree head (RFC 9162 §2.1). A head is signed by being carried in a document the ballot box signs; whoever keeps a head keeps that whole document.\",\n \"properties\": {\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"issuedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"rootHash\": {\n \"$ref\": \"#/$defs/DigestMultibase\",\n \"description\": \"The RFC 9162 Merkle tree hash (SHA-256) of the first `treeSize` entries, as a multihash.\"\n },\n \"treeSize\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"electionId\",\n \"treeSize\",\n \"rootHash\",\n \"issuedAt\"\n ],\n \"title\": \"BoardHead\",\n \"type\": \"object\"\n },\n \"Cast\": {\n \"additionalProperties\": false,\n \"description\": \"A ballot and the PCS attestation that admits it (VTI-VOT-030). `attestation` is the suite's canonical encoding of the attestation made for the election point with the ballot context bound in (CONVENTIONS §3); `tag` repeats its tag so a ballot box can refuse a duplicate before the pairing check.\",\n \"properties\": {\n \"attestation\": {\n \"$ref\": \"#/$defs/Multibase\"\n },\n \"ballot\": {\n \"$ref\": \"#/$defs/Ballot\"\n },\n \"tag\": {\n \"$ref\": \"#/$defs/Multibase\"\n }\n },\n \"required\": [\n \"ballot\",\n \"tag\",\n \"attestation\"\n ],\n \"title\": \"Cast\",\n \"type\": \"object\"\n },\n \"Dealing\": {\n \"additionalProperties\": false,\n \"description\": \"A trustee's contribution to the election key: Feldman commitments to its polynomial, a proof of knowledge of the constant term, and one share per trustee sealed to that trustee's transport key (CONVENTIONS §9.6).\",\n \"properties\": {\n \"commitments\": {\n \"items\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"maxItems\": 64,\n \"minItems\": 2,\n \"type\": \"array\"\n },\n \"dealer\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"pok\": {\n \"$ref\": \"#/$defs/SigmaProof\"\n },\n \"shares\": {\n \"items\": {\n \"$ref\": \"#/$defs/SealedShare\"\n },\n \"maxItems\": 64,\n \"minItems\": 2,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"dealer\",\n \"commitments\",\n \"pok\",\n \"shares\"\n ],\n \"title\": \"Dealing\",\n \"type\": \"object\"\n },\n \"DecryptionTarget\": {\n \"additionalProperties\": false,\n \"description\": \"What a partial decryption decrypts: the sealed cast at a board leaf, or the total of one option of one question.\",\n \"oneOf\": [\n {\n \"required\": [\n \"leafIndex\"\n ]\n },\n {\n \"required\": [\n \"question\",\n \"option\"\n ]\n }\n ],\n \"properties\": {\n \"ciphertext\": {\n \"$ref\": \"#/$defs/ElGamalCiphertext\"\n },\n \"leafIndex\": {\n \"description\": \"A sealed cast's board leaf.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"option\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n }\n },\n \"required\": [\n \"ciphertext\"\n ],\n \"title\": \"DecryptionTarget\",\n \"type\": \"object\"\n },\n \"DigestMultibase\": {\n \"description\": \"A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\\n\\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\\n\\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\\n\\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \\\"interoperability is not guaranteed between implementations using such values\\\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.\",\n \"examples\": [\n \"zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\"\n ],\n \"minLength\": 16,\n \"pattern\": \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\",\n \"title\": \"DigestMultibase\",\n \"type\": \"string\"\n },\n \"DisjunctiveProof\": {\n \"description\": \"A disjunctive proof that a ciphertext encrypts one value of a public list: one `(c, z)` per value, in the list's order (CONVENTIONS §9.3).\",\n \"items\": {\n \"$ref\": \"#/$defs/SigmaProof\"\n },\n \"maxItems\": 65,\n \"minItems\": 1,\n \"title\": \"DisjunctiveProof\",\n \"type\": \"array\"\n },\n \"ElGamalCiphertext\": {\n \"additionalProperties\": false,\n \"description\": \"`(a, b) = (r·G, M + r·Y)` under the election key `Y` (CONVENTIONS §9.2).\",\n \"properties\": {\n \"a\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"b\": {\n \"$ref\": \"#/$defs/GroupElement\"\n }\n },\n \"required\": [\n \"a\",\n \"b\"\n ],\n \"title\": \"ElGamalCiphertext\",\n \"type\": \"object\"\n },\n \"ElectionId\": {\n \"description\": \"An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,128}$\",\n \"title\": \"ElectionId\",\n \"type\": \"string\"\n },\n \"ElectionKey\": {\n \"additionalProperties\": false,\n \"description\": \"The election key and each trustee's public verification key, computed from the qualified dealings (CONVENTIONS §9.6). Anyone can recompute it from the board.\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"qualified\": {\n \"description\": \"The dealers whose dealings the key is formed from.\",\n \"items\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"verification\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"trustee\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n }\n },\n \"required\": [\n \"trustee\",\n \"key\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 64,\n \"minItems\": 2,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"key\",\n \"qualified\",\n \"verification\"\n ],\n \"title\": \"ElectionKey\",\n \"type\": \"object\"\n },\n \"ElectionResult\": {\n \"additionalProperties\": false,\n \"description\": \"An election's result, computable by anyone who can read its board from the board and the registration alone (VTI-VOT-070).\",\n \"properties\": {\n \"ballotsCounted\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"head\": {\n \"$ref\": \"#/$defs/BoardHead\",\n \"description\": \"The head of the board as it stood at close: the result counts exactly its entries.\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n },\n \"questions\": {\n \"items\": {\n \"$ref\": \"#/$defs/QuestionResult\"\n },\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"electionId\",\n \"manifestDigest\",\n \"ballotsCounted\",\n \"questions\",\n \"head\"\n ],\n \"title\": \"ElectionResult\",\n \"type\": \"object\"\n },\n \"EncryptedBallot\": {\n \"additionalProperties\": false,\n \"description\": \"A tallied-encrypted ballot: one EncryptedQuestion per manifest question, in the manifest's order. Never decrypted (VTI-VOT-064).\",\n \"properties\": {\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n },\n \"questions\": {\n \"items\": {\n \"$ref\": \"#/$defs/EncryptedQuestion\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"electionId\",\n \"manifestDigest\",\n \"questions\"\n ],\n \"title\": \"EncryptedBallot\",\n \"type\": \"object\"\n },\n \"EncryptedCast\": {\n \"additionalProperties\": false,\n \"description\": \"A cast of a sealed or tallied-encrypted election: exactly one of `sealed` (the Ballot's JCS bytes sealed to the election key) or `encrypted`, with the tag and the attestation over the JCS bytes of whichever is present (CONVENTIONS §3.6, §9.5).\",\n \"oneOf\": [\n {\n \"required\": [\n \"sealed\"\n ]\n },\n {\n \"required\": [\n \"encrypted\"\n ]\n }\n ],\n \"properties\": {\n \"attestation\": {\n \"$ref\": \"#/$defs/Multibase\"\n },\n \"encrypted\": {\n \"$ref\": \"#/$defs/EncryptedBallot\"\n },\n \"sealed\": {\n \"$ref\": \"#/$defs/SealedPayload\"\n },\n \"tag\": {\n \"$ref\": \"#/$defs/Multibase\"\n }\n },\n \"required\": [\n \"tag\",\n \"attestation\"\n ],\n \"title\": \"EncryptedCast\",\n \"type\": \"object\"\n },\n \"EncryptedOption\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"ciphertext\": {\n \"$ref\": \"#/$defs/ElGamalCiphertext\"\n },\n \"proof\": {\n \"$ref\": \"#/$defs/DisjunctiveProof\"\n }\n },\n \"required\": [\n \"ciphertext\",\n \"proof\"\n ],\n \"title\": \"EncryptedOption\",\n \"type\": \"object\"\n },\n \"EncryptedQuestion\": {\n \"additionalProperties\": false,\n \"description\": \"One choice question of a tallied-encrypted ballot: per option, in the manifest's order, an encryption of 0 or 1 with its proof; and a proof that the selections sum to a count the question admits (CONVENTIONS §9.5).\",\n \"properties\": {\n \"options\": {\n \"items\": {\n \"$ref\": \"#/$defs/EncryptedOption\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"sumProof\": {\n \"$ref\": \"#/$defs/DisjunctiveProof\"\n }\n },\n \"required\": [\n \"question\",\n \"options\",\n \"sumProof\"\n ],\n \"title\": \"EncryptedQuestion\",\n \"type\": \"object\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"GroupElement\": {\n \"description\": \"A Ristretto group element: its 32-byte compression, multibase base58btc. Never the identity (CONVENTIONS §9.1).\",\n \"maxLength\": 64,\n \"minLength\": 2,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"title\": \"GroupElement\",\n \"type\": \"string\"\n },\n \"GroupScalar\": {\n \"description\": \"A scalar mod the Ristretto group order: 32 canonical little-endian bytes, multibase base58btc (CONVENTIONS §9.1).\",\n \"maxLength\": 64,\n \"minLength\": 2,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"title\": \"GroupScalar\",\n \"type\": \"string\"\n },\n \"Key\": {\n \"description\": \"A question or option key, unique within its manifest or question.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,64}$\",\n \"title\": \"Key\",\n \"type\": \"string\"\n },\n \"Multibase\": {\n \"description\": \"A binary value, multibase base58btc over the suite's canonical (compressed) encoding.\",\n \"maxLength\": 16384,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"title\": \"Multibase\",\n \"type\": \"string\"\n },\n \"PartialDecryption\": {\n \"additionalProperties\": false,\n \"description\": \"Trustee `trustee`'s share of one decryption, `d = x_j·a`, with a Chaum–Pedersen proof against its verification key (CONVENTIONS §9.7).\",\n \"properties\": {\n \"d\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"proof\": {\n \"$ref\": \"#/$defs/SigmaProof\"\n },\n \"target\": {\n \"$ref\": \"#/$defs/DecryptionTarget\"\n }\n },\n \"required\": [\n \"target\",\n \"d\",\n \"proof\"\n ],\n \"title\": \"PartialDecryption\",\n \"type\": \"object\"\n },\n \"QuestionResult\": {\n \"additionalProperties\": false,\n \"description\": \"One question's totals. `choice`: selections per option. `ranking`: per option, how many ballots placed it at each position (index 0 = first). `score`: per option, the sum and the number of ballots that scored it. `text`: the answers, in board order, withheld (`withheld: true`) below the manifest's `textReleaseThreshold`. `abstained` counts ballots that left the question unanswered.\",\n \"properties\": {\n \"abstained\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"choice\": {\n \"additionalProperties\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"ranking\": {\n \"additionalProperties\": {\n \"items\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"type\": \"array\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"score\": {\n \"additionalProperties\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"count\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sum\": {\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"sum\",\n \"count\"\n ],\n \"type\": \"object\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"text\": {\n \"items\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n },\n \"type\": \"array\"\n },\n \"withheld\": {\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"question\",\n \"abstained\"\n ],\n \"title\": \"QuestionResult\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"entries\": {\n \"description\": \"Consecutive entries from `from`, in board order.\",\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"entry\": {\n \"$ref\": \"#/$defs/BoardEntry\"\n },\n \"index\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"index\",\n \"entry\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 1000,\n \"type\": \"array\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"next\": {\n \"description\": \"The `from` of the next page. Absent when the page reaches `treeSize`.\",\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"treeSize\": {\n \"description\": \"The tree size the page was read against. No entry at or beyond it is returned.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"treeSize\",\n \"entries\"\n ],\n \"title\": \"Voting — Board Read — response payload\",\n \"type\": \"object\"\n },\n \"SealedPayload\": {\n \"additionalProperties\": false,\n \"description\": \"Bytes sealed to a key: a random group element encrypted as `kem`, and the bytes under ChaCha20-Poly1305 with a key derived from it, multibase base58btc (CONVENTIONS §9.4).\",\n \"properties\": {\n \"body\": {\n \"maxLength\": 131072,\n \"minLength\": 2,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"type\": \"string\"\n },\n \"kem\": {\n \"$ref\": \"#/$defs/ElGamalCiphertext\"\n }\n },\n \"required\": [\n \"kem\",\n \"body\"\n ],\n \"title\": \"SealedPayload\",\n \"type\": \"object\"\n },\n \"SealedShare\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"recipient\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"share\": {\n \"$ref\": \"#/$defs/SealedPayload\"\n }\n },\n \"required\": [\n \"recipient\",\n \"share\"\n ],\n \"title\": \"SealedShare\",\n \"type\": \"object\"\n },\n \"SigmaProof\": {\n \"additionalProperties\": false,\n \"description\": \"A non-interactive sigma proof as its challenge and response `(c, z)` (Schnorr or Chaum–Pedersen; CONVENTIONS §9.3).\",\n \"properties\": {\n \"c\": {\n \"$ref\": \"#/$defs/GroupScalar\"\n },\n \"z\": {\n \"$ref\": \"#/$defs/GroupScalar\"\n }\n },\n \"required\": [\n \"c\",\n \"z\"\n ],\n \"title\": \"SigmaProof\",\n \"type\": \"object\"\n },\n \"TransportKey\": {\n \"additionalProperties\": false,\n \"description\": \"The group element a trustee's shares are sealed to, with a Schnorr proof of knowledge of its discrete log (CONVENTIONS §9.6).\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"pok\": {\n \"$ref\": \"#/$defs/SigmaProof\"\n },\n \"trustee\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n }\n },\n \"required\": [\n \"trustee\",\n \"key\",\n \"pok\"\n ],\n \"title\": \"TransportKey\",\n \"type\": \"object\"\n },\n \"TrusteeIndex\": {\n \"description\": \"A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.\",\n \"maximum\": 64,\n \"minimum\": 1,\n \"title\": \"TrusteeIndex\",\n \"type\": \"integer\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] =
&[error_codes::ELECTION_UNKNOWN, error_codes::OUT_OF_RANGE];
/// One constant per extended error code this specification declares
/// (SPEC §7.3 item 9), named for its local part.
///
/// Emit these rather than a string literal: the code is read from the
/// specification, so it cannot name a code the specification never
/// declared.
pub mod error_codes {
/// `voting/board/read:electionUnknown`
///
/// No election with this identifier exists for this community, or the caller may not see it.
///
/// Declared `retryable: false`.
pub const ELECTION_UNKNOWN: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "voting/board/read:electionUnknown",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `voting/board/read:outOfRange`
///
/// `treeSize` is greater than the board's current size, or `from` is greater than the tree size read against.
///
/// Declared `retryable: false`.
pub const OUT_OF_RANGE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "voting/board/read:outOfRange",
retryable: false,
details_schema: ::core::option::Option::None,
};
}