//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `voting/trustees/status`. 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())
}
}
}
///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, 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()
}
}
///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())
})
}
}
///Where an election's trustee ceremony stands: transport keys, dealings, complaints, the election key, and what remains to decrypt.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/voting/trustees/status/0.1",
/// "title": "Payload",
/// "description": "Where an election's trustee ceremony stands: transport keys, dealings, complaints, the election key, and what remains to decrypt.",
/// "type": "object",
/// "required": [
/// "community",
/// "electionId"
/// ],
/// "properties": {
/// "community": {
/// "description": "The community's DID: the registrar that registered the election.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The community's DID: the registrar that registered the election.
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: the registrar that registered the election.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The community's DID: the registrar that registered the election.",
/// "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())
})
}
}
///`Response`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "type": "object",
/// "required": [
/// "complaints",
/// "confirmed",
/// "dealings",
/// "decrypted",
/// "phase",
/// "targets",
/// "threshold",
/// "transportKeys"
/// ],
/// "properties": {
/// "complaints": {
/// "type": "array",
/// "items": {
/// "type": "object",
/// "required": [
/// "dealer",
/// "justified",
/// "recipient"
/// ],
/// "properties": {
/// "dealer": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "justified": {
/// "type": "boolean"
/// },
/// "recipient": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "share": {
/// "$ref": "#/definitions/GroupScalar"
/// }
/// },
/// "additionalProperties": false
/// },
/// "maxItems": 4096
/// },
/// "confirmed": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "maxItems": 64
/// },
/// "dealings": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Dealing"
/// },
/// "maxItems": 64
/// },
/// "decrypted": {
/// "description": "The trustees whose partials have been accepted.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "maxItems": 64
/// },
/// "electionKey": {
/// "$ref": "#/definitions/ElectionKey"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "phase": {
/// "$ref": "#/definitions/TrusteePhase"
/// },
/// "targets": {
/// "description": "What remains to be decrypted, once voting has closed.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/DecryptionTarget"
/// },
/// "maxItems": 100000
/// },
/// "threshold": {
/// "type": "integer",
/// "maximum": 64.0,
/// "minimum": 2.0
/// },
/// "transportKeys": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/TransportKey"
/// },
/// "maxItems": 64
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
pub complaints: ::std::vec::Vec<ResponseComplaintsItem>,
pub confirmed: ::std::vec::Vec<TrusteeIndex>,
pub dealings: ::std::vec::Vec<Dealing>,
///The trustees whose partials have been accepted.
pub decrypted: ::std::vec::Vec<TrusteeIndex>,
#[serde(
rename = "electionKey",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub election_key: ::std::option::Option<ElectionKey>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub phase: TrusteePhase,
///What remains to be decrypted, once voting has closed.
pub targets: ::std::vec::Vec<DecryptionTarget>,
pub threshold: i64,
#[serde(rename = "transportKeys")]
pub transport_keys: ::std::vec::Vec<TransportKey>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`ResponseComplaintsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "dealer",
/// "justified",
/// "recipient"
/// ],
/// "properties": {
/// "dealer": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "justified": {
/// "type": "boolean"
/// },
/// "recipient": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "share": {
/// "$ref": "#/definitions/GroupScalar"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ResponseComplaintsItem {
pub dealer: TrusteeIndex,
pub justified: bool,
pub recipient: TrusteeIndex,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub share: ::std::option::Option<GroupScalar>,
}
impl ResponseComplaintsItem {
pub fn builder() -> builder::ResponseComplaintsItem {
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)
}
}
///`enrolling`: transport keys are being published. `dealing`: dealings are. `confirming`: each trustee confirms or complains. `keyed`: the election key is formed. `decrypting`: voting has closed and partial decryptions are being published. `done`: every target is decrypted. `failed`: the key could not be formed in time.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "TrusteePhase",
/// "description": "`enrolling`: transport keys are being published. `dealing`: dealings are. `confirming`: each trustee confirms or complains. `keyed`: the election key is formed. `decrypting`: voting has closed and partial decryptions are being published. `done`: every target is decrypted. `failed`: the key could not be formed in time.",
/// "type": "string",
/// "enum": [
/// "enrolling",
/// "dealing",
/// "confirming",
/// "keyed",
/// "decrypting",
/// "done",
/// "failed"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum TrusteePhase {
#[serde(rename = "enrolling")]
Enrolling,
#[serde(rename = "dealing")]
Dealing,
#[serde(rename = "confirming")]
Confirming,
#[serde(rename = "keyed")]
Keyed,
#[serde(rename = "decrypting")]
Decrypting,
#[serde(rename = "done")]
Done,
#[serde(rename = "failed")]
Failed,
}
impl ::std::fmt::Display for TrusteePhase {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Enrolling => f.write_str("enrolling"),
Self::Dealing => f.write_str("dealing"),
Self::Confirming => f.write_str("confirming"),
Self::Keyed => f.write_str("keyed"),
Self::Decrypting => f.write_str("decrypting"),
Self::Done => f.write_str("done"),
Self::Failed => f.write_str("failed"),
}
}
}
impl ::std::str::FromStr for TrusteePhase {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"enrolling" => Ok(Self::Enrolling),
"dealing" => Ok(Self::Dealing),
"confirming" => Ok(Self::Confirming),
"keyed" => Ok(Self::Keyed),
"decrypting" => Ok(Self::Decrypting),
"done" => Ok(Self::Done),
"failed" => Ok(Self::Failed),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for TrusteePhase {
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 TrusteePhase {
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 TrusteePhase {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[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 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>,
}
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()),
}
}
}
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
}
}
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?,
})
}
}
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),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
complaints: ::std::result::Result<
::std::vec::Vec<super::ResponseComplaintsItem>,
::std::string::String,
>,
confirmed:
::std::result::Result<::std::vec::Vec<super::TrusteeIndex>, ::std::string::String>,
dealings: ::std::result::Result<::std::vec::Vec<super::Dealing>, ::std::string::String>,
decrypted:
::std::result::Result<::std::vec::Vec<super::TrusteeIndex>, ::std::string::String>,
election_key:
::std::result::Result<::std::option::Option<super::ElectionKey>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
phase: ::std::result::Result<super::TrusteePhase, ::std::string::String>,
targets:
::std::result::Result<::std::vec::Vec<super::DecryptionTarget>, ::std::string::String>,
threshold: ::std::result::Result<i64, ::std::string::String>,
transport_keys:
::std::result::Result<::std::vec::Vec<super::TransportKey>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
complaints: Err("no value supplied for complaints".to_string()),
confirmed: Err("no value supplied for confirmed".to_string()),
dealings: Err("no value supplied for dealings".to_string()),
decrypted: Err("no value supplied for decrypted".to_string()),
election_key: Ok(Default::default()),
ext: Ok(Default::default()),
phase: Err("no value supplied for phase".to_string()),
targets: Err("no value supplied for targets".to_string()),
threshold: Err("no value supplied for threshold".to_string()),
transport_keys: Err("no value supplied for transport_keys".to_string()),
}
}
}
impl Response {
pub fn complaints<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ResponseComplaintsItem>>,
T::Error: ::std::fmt::Display,
{
self.complaints = value
.try_into()
.map_err(|e| format!("error converting supplied value for complaints: {e}"));
self
}
pub fn confirmed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::TrusteeIndex>>,
T::Error: ::std::fmt::Display,
{
self.confirmed = value
.try_into()
.map_err(|e| format!("error converting supplied value for confirmed: {e}"));
self
}
pub fn dealings<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Dealing>>,
T::Error: ::std::fmt::Display,
{
self.dealings = value
.try_into()
.map_err(|e| format!("error converting supplied value for dealings: {e}"));
self
}
pub fn decrypted<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::TrusteeIndex>>,
T::Error: ::std::fmt::Display,
{
self.decrypted = value
.try_into()
.map_err(|e| format!("error converting supplied value for decrypted: {e}"));
self
}
pub fn election_key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ElectionKey>>,
T::Error: ::std::fmt::Display,
{
self.election_key = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_key: {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 phase<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TrusteePhase>,
T::Error: ::std::fmt::Display,
{
self.phase = value
.try_into()
.map_err(|e| format!("error converting supplied value for phase: {e}"));
self
}
pub fn targets<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::DecryptionTarget>>,
T::Error: ::std::fmt::Display,
{
self.targets = value
.try_into()
.map_err(|e| format!("error converting supplied value for targets: {e}"));
self
}
pub fn threshold<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.threshold = value
.try_into()
.map_err(|e| format!("error converting supplied value for threshold: {e}"));
self
}
pub fn transport_keys<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::TransportKey>>,
T::Error: ::std::fmt::Display,
{
self.transport_keys = value
.try_into()
.map_err(|e| format!("error converting supplied value for transport_keys: {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 {
complaints: value.complaints?,
confirmed: value.confirmed?,
dealings: value.dealings?,
decrypted: value.decrypted?,
election_key: value.election_key?,
ext: value.ext?,
phase: value.phase?,
targets: value.targets?,
threshold: value.threshold?,
transport_keys: value.transport_keys?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
complaints: Ok(value.complaints),
confirmed: Ok(value.confirmed),
dealings: Ok(value.dealings),
decrypted: Ok(value.decrypted),
election_key: Ok(value.election_key),
ext: Ok(value.ext),
phase: Ok(value.phase),
targets: Ok(value.targets),
threshold: Ok(value.threshold),
transport_keys: Ok(value.transport_keys),
}
}
}
#[derive(Clone, Debug)]
pub struct ResponseComplaintsItem {
dealer: ::std::result::Result<super::TrusteeIndex, ::std::string::String>,
justified: ::std::result::Result<bool, ::std::string::String>,
recipient: ::std::result::Result<super::TrusteeIndex, ::std::string::String>,
share:
::std::result::Result<::std::option::Option<super::GroupScalar>, ::std::string::String>,
}
impl ::std::default::Default for ResponseComplaintsItem {
fn default() -> Self {
Self {
dealer: Err("no value supplied for dealer".to_string()),
justified: Err("no value supplied for justified".to_string()),
recipient: Err("no value supplied for recipient".to_string()),
share: Ok(Default::default()),
}
}
}
impl ResponseComplaintsItem {
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 justified<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.justified = value
.try_into()
.map_err(|e| format!("error converting supplied value for justified: {e}"));
self
}
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<::std::option::Option<super::GroupScalar>>,
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<ResponseComplaintsItem> for super::ResponseComplaintsItem {
type Error = super::error::ConversionError;
fn try_from(
value: ResponseComplaintsItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
dealer: value.dealer?,
justified: value.justified?,
recipient: value.recipient?,
share: value.share?,
})
}
}
impl ::std::convert::From<super::ResponseComplaintsItem> for ResponseComplaintsItem {
fn from(value: super::ResponseComplaintsItem) -> Self {
Self {
dealer: Ok(value.dealer),
justified: Ok(value.justified),
recipient: Ok(value.recipient),
share: Ok(value.share),
}
}
}
#[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/trustees/status/0.1";
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\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 \"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 \"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 \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"complaints\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"dealer\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"justified\": {\n \"type\": \"boolean\"\n },\n \"recipient\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"share\": {\n \"$ref\": \"#/$defs/GroupScalar\"\n }\n },\n \"required\": [\n \"dealer\",\n \"recipient\",\n \"justified\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 4096,\n \"type\": \"array\"\n },\n \"confirmed\": {\n \"items\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n },\n \"dealings\": {\n \"items\": {\n \"$ref\": \"#/$defs/Dealing\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n },\n \"decrypted\": {\n \"description\": \"The trustees whose partials have been accepted.\",\n \"items\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n },\n \"electionKey\": {\n \"$ref\": \"#/$defs/ElectionKey\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"phase\": {\n \"$ref\": \"#/$defs/TrusteePhase\"\n },\n \"targets\": {\n \"description\": \"What remains to be decrypted, once voting has closed.\",\n \"items\": {\n \"$ref\": \"#/$defs/DecryptionTarget\"\n },\n \"maxItems\": 100000,\n \"type\": \"array\"\n },\n \"threshold\": {\n \"maximum\": 64,\n \"minimum\": 2,\n \"type\": \"integer\"\n },\n \"transportKeys\": {\n \"items\": {\n \"$ref\": \"#/$defs/TransportKey\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"phase\",\n \"threshold\",\n \"transportKeys\",\n \"dealings\",\n \"complaints\",\n \"confirmed\",\n \"targets\",\n \"decrypted\"\n ],\n \"title\": \"Voting — Trustees — Status — 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 \"TrusteePhase\": {\n \"description\": \"`enrolling`: transport keys are being published. `dealing`: dealings are. `confirming`: each trustee confirms or complains. `keyed`: the election key is formed. `decrypting`: voting has closed and partial decryptions are being published. `done`: every target is decrypted. `failed`: the key could not be formed in time.\",\n \"enum\": [\n \"enrolling\",\n \"dealing\",\n \"confirming\",\n \"keyed\",\n \"decrypting\",\n \"done\",\n \"failed\"\n ],\n \"title\": \"TrusteePhase\",\n \"type\": \"string\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/voting/trustees/status/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Where an election's trustee ceremony stands: transport keys, dealings, complaints, the election key, and what remains to decrypt.\",\n \"properties\": {\n \"community\": {\n \"description\": \"The community's DID: the registrar that registered the election.\",\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 },\n \"required\": [\n \"community\",\n \"electionId\"\n ],\n \"title\": \"Voting — Trustees — Status — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/voting/trustees/status/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(
"{\n \"$defs\": {\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 \"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 \"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 \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"complaints\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"dealer\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"justified\": {\n \"type\": \"boolean\"\n },\n \"recipient\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"share\": {\n \"$ref\": \"#/$defs/GroupScalar\"\n }\n },\n \"required\": [\n \"dealer\",\n \"recipient\",\n \"justified\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 4096,\n \"type\": \"array\"\n },\n \"confirmed\": {\n \"items\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n },\n \"dealings\": {\n \"items\": {\n \"$ref\": \"#/$defs/Dealing\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n },\n \"decrypted\": {\n \"description\": \"The trustees whose partials have been accepted.\",\n \"items\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n },\n \"electionKey\": {\n \"$ref\": \"#/$defs/ElectionKey\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"phase\": {\n \"$ref\": \"#/$defs/TrusteePhase\"\n },\n \"targets\": {\n \"description\": \"What remains to be decrypted, once voting has closed.\",\n \"items\": {\n \"$ref\": \"#/$defs/DecryptionTarget\"\n },\n \"maxItems\": 100000,\n \"type\": \"array\"\n },\n \"threshold\": {\n \"maximum\": 64,\n \"minimum\": 2,\n \"type\": \"integer\"\n },\n \"transportKeys\": {\n \"items\": {\n \"$ref\": \"#/$defs/TransportKey\"\n },\n \"maxItems\": 64,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"phase\",\n \"threshold\",\n \"transportKeys\",\n \"dealings\",\n \"complaints\",\n \"confirmed\",\n \"targets\",\n \"decrypted\"\n ],\n \"title\": \"Voting — Trustees — Status — 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 \"TrusteePhase\": {\n \"description\": \"`enrolling`: transport keys are being published. `dealing`: dealings are. `confirming`: each trustee confirms or complains. `keyed`: the election key is formed. `decrypting`: voting has closed and partial decryptions are being published. `done`: every target is decrypted. `failed`: the key could not be formed in time.\",\n \"enum\": [\n \"enrolling\",\n \"dealing\",\n \"confirming\",\n \"keyed\",\n \"decrypting\",\n \"done\",\n \"failed\"\n ],\n \"title\": \"TrusteePhase\",\n \"type\": \"string\"\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];
/// 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/trustees/status:electionUnknown`
///
/// No election with this identifier exists for this community, or the caller may not read its board.
///
/// Declared `retryable: false`.
pub const ELECTION_UNKNOWN: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "voting/trustees/status:electionUnknown",
retryable: false,
details_schema: ::core::option::Option::None,
};
}