//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `voting/ballot/cast-encrypted`. Version: `0.1`.
/// Why this specification version is deprecated (SPEC "Superseded and
/// Withdrawn Versions"), or `None` while it is current.
pub const DEPRECATION: Option<&str> = None;
#[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())
}
}
}
///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.
///
#[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 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`.*/
///
#[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).
///
#[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).
///
#[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.
///
#[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())
})
}
}
///A tallied-encrypted ballot: one EncryptedQuestion per manifest question, in the manifest's order. Never decrypted (VTI-VOT-064).
///
#[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).
///
#[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`
///
#[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).
///
#[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.
///
#[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`
///
#[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).
///
#[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).
///
#[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.
///
#[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())
})
}
}
///A binary value, multibase base58btc over the suite's canonical (compressed) encoding.
///
#[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())
})
}
}
///A voter casts a sealed or tallied-encrypted ballot, admitted by its PCS attestation and, when tallied-encrypted, by its proofs of validity.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
pub cast: EncryptedCast,
///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>,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The community's DID.
///
#[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())
})
}
}
///`Response`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
#[serde(rename = "electionId")]
pub election_id: ElectionId,
#[serde(rename = "entryHash")]
pub entry_hash: DigestMultibase,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub head: BoardHead,
///The board index of this cast's `encryptedCast` entry.
#[serde(rename = "leafIndex")]
pub leaf_index: u64,
///As voting/ballot/cast.
pub outcome: ResponseOutcome,
#[serde(rename = "receiptToken")]
pub receipt_token: Multibase,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///As voting/ballot/cast.
///
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ResponseOutcome {
#[serde(rename = "counted")]
Counted,
#[serde(rename = "replaced")]
Replaced,
#[serde(rename = "alreadyCounted")]
AlreadyCounted,
}
impl ::std::fmt::Display for ResponseOutcome {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Counted => f.write_str("counted"),
Self::Replaced => f.write_str("replaced"),
Self::AlreadyCounted => f.write_str("alreadyCounted"),
}
}
}
impl ::std::str::FromStr for ResponseOutcome {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"counted" => Ok(Self::Counted),
"replaced" => Ok(Self::Replaced),
"alreadyCounted" => Ok(Self::AlreadyCounted),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ResponseOutcome {
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 ResponseOutcome {
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 ResponseOutcome {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///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).
///
#[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`
///
#[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())
})
}
}
///A non-interactive sigma proof as its challenge and response `(c, z)` (Schnorr or Chaum–Pedersen; CONVENTIONS §9.3).
///
#[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()
}
}
/// Types for composing complex structures.
pub mod builder {
#[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 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 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 Payload {
cast: ::std::result::Result<super::EncryptedCast, ::std::string::String>,
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>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
cast: Err("no value supplied for cast".to_string()),
community: Err("no value supplied for community".to_string()),
election_id: Err("no value supplied for election_id".to_string()),
ext: Ok(Default::default()),
}
}
}
impl Payload {
pub fn cast<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::EncryptedCast>,
T::Error: ::std::fmt::Display,
{
self.cast = value
.try_into()
.map_err(|e| format!("error converting supplied value for cast: {e}"));
self
}
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
}
}
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 {
cast: value.cast?,
community: value.community?,
election_id: value.election_id?,
ext: value.ext?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
cast: Ok(value.cast),
community: Ok(value.community),
election_id: Ok(value.election_id),
ext: Ok(value.ext),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
entry_hash: ::std::result::Result<super::DigestMultibase, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
head: ::std::result::Result<super::BoardHead, ::std::string::String>,
leaf_index: ::std::result::Result<u64, ::std::string::String>,
outcome: ::std::result::Result<super::ResponseOutcome, ::std::string::String>,
receipt_token: ::std::result::Result<super::Multibase, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
election_id: Err("no value supplied for election_id".to_string()),
entry_hash: Err("no value supplied for entry_hash".to_string()),
ext: Ok(Default::default()),
head: Err("no value supplied for head".to_string()),
leaf_index: Err("no value supplied for leaf_index".to_string()),
outcome: Err("no value supplied for outcome".to_string()),
receipt_token: Err("no value supplied for receipt_token".to_string()),
}
}
}
impl Response {
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 entry_hash<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DigestMultibase>,
T::Error: ::std::fmt::Display,
{
self.entry_hash = value
.try_into()
.map_err(|e| format!("error converting supplied value for entry_hash: {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 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 leaf_index<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.leaf_index = value
.try_into()
.map_err(|e| format!("error converting supplied value for leaf_index: {e}"));
self
}
pub fn outcome<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseOutcome>,
T::Error: ::std::fmt::Display,
{
self.outcome = value
.try_into()
.map_err(|e| format!("error converting supplied value for outcome: {e}"));
self
}
pub fn receipt_token<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Multibase>,
T::Error: ::std::fmt::Display,
{
self.receipt_token = value
.try_into()
.map_err(|e| format!("error converting supplied value for receipt_token: {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 {
election_id: value.election_id?,
entry_hash: value.entry_hash?,
ext: value.ext?,
head: value.head?,
leaf_index: value.leaf_index?,
outcome: value.outcome?,
receipt_token: value.receipt_token?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
election_id: Ok(value.election_id),
entry_hash: Ok(value.entry_hash),
ext: Ok(value.ext),
head: Ok(value.head),
leaf_index: Ok(value.leaf_index),
outcome: Ok(value.outcome),
receipt_token: Ok(value.receipt_token),
}
}
}
#[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 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),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/voting/ballot/cast-encrypted/0.1";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"BoardHead\":{\"additionalProperties\":false,\"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.\",\"properties\":{\"electionId\":{\"$ref\":\"#/$defs/ElectionId\"},\"issuedAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"rootHash\":{\"$ref\":\"#/$defs/DigestMultibase\",\"description\":\"The RFC 9162 Merkle tree hash (SHA-256) of the first `treeSize` entries, as a multihash.\"},\"treeSize\":{\"minimum\":0,\"type\":\"integer\"}},\"required\":[\"electionId\",\"treeSize\",\"rootHash\",\"issuedAt\"],\"title\":\"BoardHead\",\"type\":\"object\"},\"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\"],\"minLength\":16,\"pattern\":\"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\",\"title\":\"DigestMultibase\",\"type\":\"string\"},\"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).\",\"items\":{\"$ref\":\"#/$defs/SigmaProof\"},\"maxItems\":65,\"minItems\":1,\"title\":\"DisjunctiveProof\",\"type\":\"array\"},\"ElGamalCiphertext\":{\"additionalProperties\":false,\"description\":\"`(a, b) = (r·G, M + r·Y)` under the election key `Y` (CONVENTIONS §9.2).\",\"properties\":{\"a\":{\"$ref\":\"#/$defs/GroupElement\"},\"b\":{\"$ref\":\"#/$defs/GroupElement\"}},\"required\":[\"a\",\"b\"],\"title\":\"ElGamalCiphertext\",\"type\":\"object\"},\"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.\",\"pattern\":\"^[A-Za-z0-9._-]{1,128}$\",\"title\":\"ElectionId\",\"type\":\"string\"},\"EncryptedBallot\":{\"additionalProperties\":false,\"description\":\"A tallied-encrypted ballot: one EncryptedQuestion per manifest question, in the manifest's order. Never decrypted (VTI-VOT-064).\",\"properties\":{\"electionId\":{\"$ref\":\"#/$defs/ElectionId\"},\"manifestDigest\":{\"$ref\":\"#/$defs/DigestMultibase\"},\"questions\":{\"items\":{\"$ref\":\"#/$defs/EncryptedQuestion\"},\"maxItems\":64,\"minItems\":1,\"type\":\"array\"}},\"required\":[\"electionId\",\"manifestDigest\",\"questions\"],\"title\":\"EncryptedBallot\",\"type\":\"object\"},\"EncryptedCast\":{\"additionalProperties\":false,\"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).\",\"oneOf\":[{\"required\":[\"sealed\"]},{\"required\":[\"encrypted\"]}],\"properties\":{\"attestation\":{\"$ref\":\"#/$defs/Multibase\"},\"encrypted\":{\"$ref\":\"#/$defs/EncryptedBallot\"},\"sealed\":{\"$ref\":\"#/$defs/SealedPayload\"},\"tag\":{\"$ref\":\"#/$defs/Multibase\"}},\"required\":[\"tag\",\"attestation\"],\"title\":\"EncryptedCast\",\"type\":\"object\"},\"EncryptedOption\":{\"additionalProperties\":false,\"properties\":{\"ciphertext\":{\"$ref\":\"#/$defs/ElGamalCiphertext\"},\"proof\":{\"$ref\":\"#/$defs/DisjunctiveProof\"}},\"required\":[\"ciphertext\",\"proof\"],\"title\":\"EncryptedOption\",\"type\":\"object\"},\"EncryptedQuestion\":{\"additionalProperties\":false,\"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).\",\"properties\":{\"options\":{\"items\":{\"$ref\":\"#/$defs/EncryptedOption\"},\"maxItems\":64,\"minItems\":1,\"type\":\"array\"},\"question\":{\"$ref\":\"#/$defs/Key\"},\"sumProof\":{\"$ref\":\"#/$defs/DisjunctiveProof\"}},\"required\":[\"question\",\"options\",\"sumProof\"],\"title\":\"EncryptedQuestion\",\"type\":\"object\"},\"Ext\":{\"additionalProperties\":true,\"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.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"GroupElement\":{\"description\":\"A Ristretto group element: its 32-byte compression, multibase base58btc. Never the identity (CONVENTIONS §9.1).\",\"maxLength\":64,\"minLength\":2,\"pattern\":\"^z[1-9A-HJ-NP-Za-km-z]+$\",\"title\":\"GroupElement\",\"type\":\"string\"},\"GroupScalar\":{\"description\":\"A scalar mod the Ristretto group order: 32 canonical little-endian bytes, multibase base58btc (CONVENTIONS §9.1).\",\"maxLength\":64,\"minLength\":2,\"pattern\":\"^z[1-9A-HJ-NP-Za-km-z]+$\",\"title\":\"GroupScalar\",\"type\":\"string\"},\"Key\":{\"description\":\"A question or option key, unique within its manifest or question.\",\"pattern\":\"^[A-Za-z0-9._-]{1,64}$\",\"title\":\"Key\",\"type\":\"string\"},\"Multibase\":{\"description\":\"A binary value, multibase base58btc over the suite's canonical (compressed) encoding.\",\"maxLength\":16384,\"pattern\":\"^z[1-9A-HJ-NP-Za-km-z]+$\",\"title\":\"Multibase\",\"type\":\"string\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"electionId\":{\"$ref\":\"#/$defs/ElectionId\"},\"entryHash\":{\"$ref\":\"#/$defs/DigestMultibase\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"head\":{\"$ref\":\"#/$defs/BoardHead\"},\"leafIndex\":{\"description\":\"The board index of this cast's `encryptedCast` entry.\",\"minimum\":0,\"type\":\"integer\"},\"outcome\":{\"description\":\"As voting/ballot/cast.\",\"enum\":[\"counted\",\"replaced\",\"alreadyCounted\"],\"type\":\"string\"},\"receiptToken\":{\"$ref\":\"#/$defs/Multibase\"}},\"required\":[\"electionId\",\"outcome\",\"leafIndex\",\"entryHash\",\"head\",\"receiptToken\"],\"title\":\"Voting — Ballot — Cast Encrypted — response payload\",\"type\":\"object\"},\"SealedPayload\":{\"additionalProperties\":false,\"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).\",\"properties\":{\"body\":{\"maxLength\":131072,\"minLength\":2,\"pattern\":\"^z[1-9A-HJ-NP-Za-km-z]+$\",\"type\":\"string\"},\"kem\":{\"$ref\":\"#/$defs/ElGamalCiphertext\"}},\"required\":[\"kem\",\"body\"],\"title\":\"SealedPayload\",\"type\":\"object\"},\"SigmaProof\":{\"additionalProperties\":false,\"description\":\"A non-interactive sigma proof as its challenge and response `(c, z)` (Schnorr or Chaum–Pedersen; CONVENTIONS §9.3).\",\"properties\":{\"c\":{\"$ref\":\"#/$defs/GroupScalar\"},\"z\":{\"$ref\":\"#/$defs/GroupScalar\"}},\"required\":[\"c\",\"z\"],\"title\":\"SigmaProof\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/voting/ballot/cast-encrypted/0.1\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"description\":\"A voter casts a sealed or tallied-encrypted ballot, admitted by its PCS attestation and, when tallied-encrypted, by its proofs of validity.\",\"properties\":{\"cast\":{\"$ref\":\"#/$defs/EncryptedCast\"},\"community\":{\"description\":\"The community's DID.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"electionId\":{\"$ref\":\"#/$defs/ElectionId\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"}},\"required\":[\"community\",\"electionId\",\"cast\"],\"title\":\"Voting — Ballot — Cast Encrypted — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/voting/ballot/cast-encrypted/0.1#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"BoardHead\":{\"additionalProperties\":false,\"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.\",\"properties\":{\"electionId\":{\"$ref\":\"#/$defs/ElectionId\"},\"issuedAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"rootHash\":{\"$ref\":\"#/$defs/DigestMultibase\",\"description\":\"The RFC 9162 Merkle tree hash (SHA-256) of the first `treeSize` entries, as a multihash.\"},\"treeSize\":{\"minimum\":0,\"type\":\"integer\"}},\"required\":[\"electionId\",\"treeSize\",\"rootHash\",\"issuedAt\"],\"title\":\"BoardHead\",\"type\":\"object\"},\"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\"],\"minLength\":16,\"pattern\":\"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\",\"title\":\"DigestMultibase\",\"type\":\"string\"},\"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).\",\"items\":{\"$ref\":\"#/$defs/SigmaProof\"},\"maxItems\":65,\"minItems\":1,\"title\":\"DisjunctiveProof\",\"type\":\"array\"},\"ElGamalCiphertext\":{\"additionalProperties\":false,\"description\":\"`(a, b) = (r·G, M + r·Y)` under the election key `Y` (CONVENTIONS §9.2).\",\"properties\":{\"a\":{\"$ref\":\"#/$defs/GroupElement\"},\"b\":{\"$ref\":\"#/$defs/GroupElement\"}},\"required\":[\"a\",\"b\"],\"title\":\"ElGamalCiphertext\",\"type\":\"object\"},\"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.\",\"pattern\":\"^[A-Za-z0-9._-]{1,128}$\",\"title\":\"ElectionId\",\"type\":\"string\"},\"EncryptedBallot\":{\"additionalProperties\":false,\"description\":\"A tallied-encrypted ballot: one EncryptedQuestion per manifest question, in the manifest's order. Never decrypted (VTI-VOT-064).\",\"properties\":{\"electionId\":{\"$ref\":\"#/$defs/ElectionId\"},\"manifestDigest\":{\"$ref\":\"#/$defs/DigestMultibase\"},\"questions\":{\"items\":{\"$ref\":\"#/$defs/EncryptedQuestion\"},\"maxItems\":64,\"minItems\":1,\"type\":\"array\"}},\"required\":[\"electionId\",\"manifestDigest\",\"questions\"],\"title\":\"EncryptedBallot\",\"type\":\"object\"},\"EncryptedCast\":{\"additionalProperties\":false,\"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).\",\"oneOf\":[{\"required\":[\"sealed\"]},{\"required\":[\"encrypted\"]}],\"properties\":{\"attestation\":{\"$ref\":\"#/$defs/Multibase\"},\"encrypted\":{\"$ref\":\"#/$defs/EncryptedBallot\"},\"sealed\":{\"$ref\":\"#/$defs/SealedPayload\"},\"tag\":{\"$ref\":\"#/$defs/Multibase\"}},\"required\":[\"tag\",\"attestation\"],\"title\":\"EncryptedCast\",\"type\":\"object\"},\"EncryptedOption\":{\"additionalProperties\":false,\"properties\":{\"ciphertext\":{\"$ref\":\"#/$defs/ElGamalCiphertext\"},\"proof\":{\"$ref\":\"#/$defs/DisjunctiveProof\"}},\"required\":[\"ciphertext\",\"proof\"],\"title\":\"EncryptedOption\",\"type\":\"object\"},\"EncryptedQuestion\":{\"additionalProperties\":false,\"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).\",\"properties\":{\"options\":{\"items\":{\"$ref\":\"#/$defs/EncryptedOption\"},\"maxItems\":64,\"minItems\":1,\"type\":\"array\"},\"question\":{\"$ref\":\"#/$defs/Key\"},\"sumProof\":{\"$ref\":\"#/$defs/DisjunctiveProof\"}},\"required\":[\"question\",\"options\",\"sumProof\"],\"title\":\"EncryptedQuestion\",\"type\":\"object\"},\"Ext\":{\"additionalProperties\":true,\"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.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"GroupElement\":{\"description\":\"A Ristretto group element: its 32-byte compression, multibase base58btc. Never the identity (CONVENTIONS §9.1).\",\"maxLength\":64,\"minLength\":2,\"pattern\":\"^z[1-9A-HJ-NP-Za-km-z]+$\",\"title\":\"GroupElement\",\"type\":\"string\"},\"GroupScalar\":{\"description\":\"A scalar mod the Ristretto group order: 32 canonical little-endian bytes, multibase base58btc (CONVENTIONS §9.1).\",\"maxLength\":64,\"minLength\":2,\"pattern\":\"^z[1-9A-HJ-NP-Za-km-z]+$\",\"title\":\"GroupScalar\",\"type\":\"string\"},\"Key\":{\"description\":\"A question or option key, unique within its manifest or question.\",\"pattern\":\"^[A-Za-z0-9._-]{1,64}$\",\"title\":\"Key\",\"type\":\"string\"},\"Multibase\":{\"description\":\"A binary value, multibase base58btc over the suite's canonical (compressed) encoding.\",\"maxLength\":16384,\"pattern\":\"^z[1-9A-HJ-NP-Za-km-z]+$\",\"title\":\"Multibase\",\"type\":\"string\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"electionId\":{\"$ref\":\"#/$defs/ElectionId\"},\"entryHash\":{\"$ref\":\"#/$defs/DigestMultibase\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"head\":{\"$ref\":\"#/$defs/BoardHead\"},\"leafIndex\":{\"description\":\"The board index of this cast's `encryptedCast` entry.\",\"minimum\":0,\"type\":\"integer\"},\"outcome\":{\"description\":\"As voting/ballot/cast.\",\"enum\":[\"counted\",\"replaced\",\"alreadyCounted\"],\"type\":\"string\"},\"receiptToken\":{\"$ref\":\"#/$defs/Multibase\"}},\"required\":[\"electionId\",\"outcome\",\"leafIndex\",\"entryHash\",\"head\",\"receiptToken\"],\"title\":\"Voting — Ballot — Cast Encrypted — response payload\",\"type\":\"object\"},\"SealedPayload\":{\"additionalProperties\":false,\"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).\",\"properties\":{\"body\":{\"maxLength\":131072,\"minLength\":2,\"pattern\":\"^z[1-9A-HJ-NP-Za-km-z]+$\",\"type\":\"string\"},\"kem\":{\"$ref\":\"#/$defs/ElGamalCiphertext\"}},\"required\":[\"kem\",\"body\"],\"title\":\"SealedPayload\",\"type\":\"object\"},\"SigmaProof\":{\"additionalProperties\":false,\"description\":\"A non-interactive sigma proof as its challenge and response `(c, z)` (Schnorr or Chaum–Pedersen; CONVENTIONS §9.3).\",\"properties\":{\"c\":{\"$ref\":\"#/$defs/GroupScalar\"},\"z\":{\"$ref\":\"#/$defs/GroupScalar\"}},\"required\":[\"c\",\"z\"],\"title\":\"SigmaProof\",\"type\":\"object\"}},\"$ref\":\"#/$defs/Response\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The earlier `MAJOR.MINOR` of this slug that this version declares it
/// extends (front matter `extends`, SPEC §5.2 "Declared extension"), or
/// `None`. Only the direct declaration; walk a chain with
/// [`crate::extension::extends_for`].
pub const EXTENDS: Option<&str> = None;
/// 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::NOT_OPEN,
error_codes::WRONG_LEVEL,
error_codes::BALLOT_INVALID,
error_codes::CAST_INVALID,
error_codes::ALREADY_VOTED,
];
/// 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/ballot/cast-encrypted:electionUnknown`
///
/// No election with this identifier exists for this community.
///
/// Declared `retryable: false`.
pub const ELECTION_UNKNOWN: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "voting/ballot/cast-encrypted:electionUnknown",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `voting/ballot/cast-encrypted:notOpen`
///
/// Voting is not open, or the election key is not formed.
///
/// Declared `retryable: false`.
pub const NOT_OPEN: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "voting/ballot/cast-encrypted:notOpen",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `voting/ballot/cast-encrypted:wrongLevel`
///
/// The election is open, or the cast's form (`sealed` or `encrypted`) is not the election's level.
///
/// Declared `retryable: false`.
pub const WRONG_LEVEL: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "voting/ballot/cast-encrypted:wrongLevel",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `voting/ballot/cast-encrypted:ballotInvalid`
///
/// An encrypted ballot's proofs do not verify, or it does not answer the manifest's questions in order.
///
/// Declared `retryable: false`.
pub const BALLOT_INVALID: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "voting/ballot/cast-encrypted:ballotInvalid",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `voting/ballot/cast-encrypted:castInvalid`
///
/// The attestation does not verify for this election and this ballot.
///
/// Declared `retryable: false`.
pub const CAST_INVALID: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "voting/ballot/cast-encrypted:castInvalid",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `voting/ballot/cast-encrypted:alreadyVoted`
///
/// The manifest refuses a revote and a cast under this tag is counted.
///
/// Declared `retryable: false`.
pub const ALREADY_VOTED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "voting/ballot/cast-encrypted:alreadyVoted",
retryable: false,
details_schema: ::core::option::Option::None,
};
}