//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/pcs/trustee/decrypt`. Version: `0.1`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///The voting/trustees/decrypt request, signed as the trustee.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "DecryptDocument",
/// "description": "The voting/trustees/decrypt request, signed as the trustee.",
/// "type": "object",
/// "required": [
/// "id",
/// "issuedAt",
/// "issuer",
/// "payload",
/// "proof",
/// "recipient",
/// "type"
/// ],
/// "properties": {
/// "expiresAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "id": {
/// "type": "string",
/// "pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
/// },
/// "issuedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "issuer": {
/// "description": "The signer.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "payload": {
/// "description": "That task's request payload.",
/// "type": "object"
/// },
/// "proof": {
/// "description": "A Data Integrity proof by an `authentication` key of `issuer`.",
/// "type": "object"
/// },
/// "recipient": {
/// "description": "The ballot box.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "type": {
/// "const": "https://trusttasks.org/spec/voting/trustees/decrypt/0.1"
/// }
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[non_exhaustive]
pub struct DecryptDocument {
#[serde(
rename = "expiresAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub expires_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
pub id: DecryptDocumentId,
#[serde(rename = "issuedAt")]
pub issued_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The signer.
pub issuer: DecryptDocumentIssuer,
///That task's request payload.
pub payload: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///A Data Integrity proof by an `authentication` key of `issuer`.
pub proof: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///The ballot box.
pub recipient: DecryptDocumentRecipient,
#[serde(rename = "type")]
pub type_: ::serde_json::Value,
}
impl DecryptDocument {
pub fn builder() -> builder::DecryptDocument {
Default::default()
}
}
///`DecryptDocumentId`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DecryptDocumentId(::std::string::String);
impl ::std::ops::Deref for DecryptDocumentId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DecryptDocumentId> for ::std::string::String {
fn from(value: DecryptDocumentId) -> Self {
value.0
}
}
impl ::std::str::FromStr for DecryptDocumentId {
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(
"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
)
.unwrap()
},
);
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$\""
.into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for DecryptDocumentId {
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 DecryptDocumentId {
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 DecryptDocumentId {
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 DecryptDocumentId {
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 signer.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The signer.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DecryptDocumentIssuer(::std::string::String);
impl ::std::ops::Deref for DecryptDocumentIssuer {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DecryptDocumentIssuer> for ::std::string::String {
fn from(value: DecryptDocumentIssuer) -> Self {
value.0
}
}
impl ::std::str::FromStr for DecryptDocumentIssuer {
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 DecryptDocumentIssuer {
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 DecryptDocumentIssuer {
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 DecryptDocumentIssuer {
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 DecryptDocumentIssuer {
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 ballot box.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The ballot box.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DecryptDocumentRecipient(::std::string::String);
impl ::std::ops::Deref for DecryptDocumentRecipient {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DecryptDocumentRecipient> for ::std::string::String {
fn from(value: DecryptDocumentRecipient) -> Self {
value.0
}
}
impl ::std::str::FromStr for DecryptDocumentRecipient {
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 DecryptDocumentRecipient {
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 DecryptDocumentRecipient {
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 DecryptDocumentRecipient {
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 DecryptDocumentRecipient {
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())
})
}
}
///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())
})
}
}
///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 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())
})
}
}
///The trustee's VTA makes its partial decryption of each target, with proofs, and returns the voting/trustees/decrypt request signed as the trustee.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/vta/pcs/trustee/decrypt/0.1",
/// "title": "Payload",
/// "description": "The trustee's VTA makes its partial decryption of each target, with proofs, and returns the voting/trustees/decrypt request signed as the trustee.",
/// "type": "object",
/// "required": [
/// "closedAt",
/// "community",
/// "contextId",
/// "electionId",
/// "targets",
/// "trustee"
/// ],
/// "properties": {
/// "closedAt": {
/// "description": "When voting closed, from the election's summary. The VTA refuses before then.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "community": {
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "contextId": {
/// "description": "The VTA context the trustee's keys live in.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "targets": {
/// "description": "The targets voting/trustees/status lists.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/DecryptionTarget"
/// },
/// "maxItems": 100000,
/// "minItems": 1
/// },
/// "trustee": {
/// "description": "The trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///When voting closed, from the election's summary. The VTA refuses before then.
#[serde(rename = "closedAt")]
pub closed_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The community's DID.
pub community: PayloadCommunity,
///The VTA context the trustee's keys live in.
#[serde(rename = "contextId")]
pub context_id: PayloadContextId,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The targets voting/trustees/status lists.
pub targets: ::std::vec::Vec<DecryptionTarget>,
///The trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.
pub trustee: PayloadTrustee,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The community's DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCommunity(::std::string::String);
impl ::std::ops::Deref for PayloadCommunity {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCommunity> for ::std::string::String {
fn from(value: PayloadCommunity) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCommunity {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadCommunity {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The VTA context the trustee's keys live in.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The VTA context the trustee's keys live in.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadContextId(::std::string::String);
impl ::std::ops::Deref for PayloadContextId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadContextId> for ::std::string::String {
fn from(value: PayloadContextId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadContextId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 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 PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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 trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadTrustee(::std::string::String);
impl ::std::ops::Deref for PayloadTrustee {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadTrustee> for ::std::string::String {
fn from(value: PayloadTrustee) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadTrustee {
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 PayloadTrustee {
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 PayloadTrustee {
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 PayloadTrustee {
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 PayloadTrustee {
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": [
/// "document"
/// ],
/// "properties": {
/// "document": {
/// "title": "DecryptDocument",
/// "description": "The voting/trustees/decrypt request, signed as the trustee.",
/// "type": "object",
/// "required": [
/// "id",
/// "issuedAt",
/// "issuer",
/// "payload",
/// "proof",
/// "recipient",
/// "type"
/// ],
/// "properties": {
/// "expiresAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "id": {
/// "type": "string",
/// "pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
/// },
/// "issuedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "issuer": {
/// "description": "The signer.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "payload": {
/// "description": "That task's request payload.",
/// "type": "object"
/// },
/// "proof": {
/// "description": "A Data Integrity proof by an `authentication` key of `issuer`.",
/// "type": "object"
/// },
/// "recipient": {
/// "description": "The ballot box.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "type": {
/// "const": "https://trusttasks.org/spec/voting/trustees/decrypt/0.1"
/// }
/// }
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
pub document: DecryptDocument,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct DecryptDocument {
expires_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
id: ::std::result::Result<super::DecryptDocumentId, ::std::string::String>,
issued_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
issuer: ::std::result::Result<super::DecryptDocumentIssuer, ::std::string::String>,
payload: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
proof: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
recipient: ::std::result::Result<super::DecryptDocumentRecipient, ::std::string::String>,
type_: ::std::result::Result<::serde_json::Value, ::std::string::String>,
}
impl ::std::default::Default for DecryptDocument {
fn default() -> Self {
Self {
expires_at: Ok(Default::default()),
id: Err("no value supplied for id".to_string()),
issued_at: Err("no value supplied for issued_at".to_string()),
issuer: Err("no value supplied for issuer".to_string()),
payload: Err("no value supplied for payload".to_string()),
proof: Err("no value supplied for proof".to_string()),
recipient: Err("no value supplied for recipient".to_string()),
type_: Err("no value supplied for type_".to_string()),
}
}
}
impl DecryptDocument {
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for expires_at: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DecryptDocumentId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for 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 issuer<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DecryptDocumentIssuer>,
T::Error: ::std::fmt::Display,
{
self.issuer = value
.try_into()
.map_err(|e| format!("error converting supplied value for issuer: {e}"));
self
}
pub fn payload<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.payload = value
.try_into()
.map_err(|e| format!("error converting supplied value for payload: {e}"));
self
}
pub fn proof<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.proof = value
.try_into()
.map_err(|e| format!("error converting supplied value for proof: {e}"));
self
}
pub fn recipient<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DecryptDocumentRecipient>,
T::Error: ::std::fmt::Display,
{
self.recipient = value
.try_into()
.map_err(|e| format!("error converting supplied value for recipient: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::serde_json::Value>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<DecryptDocument> for super::DecryptDocument {
type Error = super::error::ConversionError;
fn try_from(
value: DecryptDocument,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
expires_at: value.expires_at?,
id: value.id?,
issued_at: value.issued_at?,
issuer: value.issuer?,
payload: value.payload?,
proof: value.proof?,
recipient: value.recipient?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::DecryptDocument> for DecryptDocument {
fn from(value: super::DecryptDocument) -> Self {
Self {
expires_at: Ok(value.expires_at),
id: Ok(value.id),
issued_at: Ok(value.issued_at),
issuer: Ok(value.issuer),
payload: Ok(value.payload),
proof: Ok(value.proof),
recipient: Ok(value.recipient),
type_: Ok(value.type_),
}
}
}
#[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 Payload {
closed_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
community: ::std::result::Result<super::PayloadCommunity, ::std::string::String>,
context_id: ::std::result::Result<super::PayloadContextId, ::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>,
targets:
::std::result::Result<::std::vec::Vec<super::DecryptionTarget>, ::std::string::String>,
trustee: ::std::result::Result<super::PayloadTrustee, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
closed_at: Err("no value supplied for closed_at".to_string()),
community: Err("no value supplied for community".to_string()),
context_id: Err("no value supplied for context_id".to_string()),
election_id: Err("no value supplied for election_id".to_string()),
ext: Ok(Default::default()),
targets: Err("no value supplied for targets".to_string()),
trustee: Err("no value supplied for trustee".to_string()),
}
}
}
impl Payload {
pub fn closed_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.closed_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for closed_at: {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 context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadContextId>,
T::Error: ::std::fmt::Display,
{
self.context_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for context_id: {e}"));
self
}
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn 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 trustee<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadTrustee>,
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<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
closed_at: value.closed_at?,
community: value.community?,
context_id: value.context_id?,
election_id: value.election_id?,
ext: value.ext?,
targets: value.targets?,
trustee: value.trustee?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
closed_at: Ok(value.closed_at),
community: Ok(value.community),
context_id: Ok(value.context_id),
election_id: Ok(value.election_id),
ext: Ok(value.ext),
targets: Ok(value.targets),
trustee: Ok(value.trustee),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
document: ::std::result::Result<super::DecryptDocument, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
document: Err("no value supplied for document".to_string()),
ext: Ok(Default::default()),
}
}
}
impl Response {
pub fn document<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DecryptDocument>,
T::Error: ::std::fmt::Display,
{
self.document = value
.try_into()
.map_err(|e| format!("error converting supplied value for document: {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<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
document: value.document?,
ext: value.ext?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
document: Ok(value.document),
ext: Ok(value.ext),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/pcs/trustee/decrypt/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(
"{\n \"$defs\": {\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 \"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 \"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 \"document\": {\n \"description\": \"The voting/trustees/decrypt request, signed as the trustee.\",\n \"properties\": {\n \"expiresAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"id\": {\n \"pattern\": \"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$\",\n \"type\": \"string\"\n },\n \"issuedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"issuer\": {\n \"description\": \"The signer.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"payload\": {\n \"description\": \"That task's request payload.\",\n \"type\": \"object\"\n },\n \"proof\": {\n \"description\": \"A Data Integrity proof by an `authentication` key of `issuer`.\",\n \"type\": \"object\"\n },\n \"recipient\": {\n \"description\": \"The ballot box.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"https://trusttasks.org/spec/voting/trustees/decrypt/0.1\"\n }\n },\n \"required\": [\n \"id\",\n \"type\",\n \"issuer\",\n \"recipient\",\n \"issuedAt\",\n \"payload\",\n \"proof\"\n ],\n \"title\": \"DecryptDocument\",\n \"type\": \"object\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n }\n },\n \"required\": [\n \"document\"\n ],\n \"title\": \"VTA PCS — Trustee Decrypt — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/vta/pcs/trustee/decrypt/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"The trustee's VTA makes its partial decryption of each target, with proofs, and returns the voting/trustees/decrypt request signed as the trustee.\",\n \"properties\": {\n \"closedAt\": {\n \"description\": \"When voting closed, from the election's summary. The VTA refuses before then.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"community\": {\n \"description\": \"The community's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"contextId\": {\n \"description\": \"The VTA context the trustee's keys live in.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"targets\": {\n \"description\": \"The targets voting/trustees/status lists.\",\n \"items\": {\n \"$ref\": \"#/$defs/DecryptionTarget\"\n },\n \"maxItems\": 100000,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"trustee\": {\n \"description\": \"The trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"contextId\",\n \"community\",\n \"electionId\",\n \"trustee\",\n \"targets\",\n \"closedAt\"\n ],\n \"title\": \"VTA PCS — Trustee Decrypt — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vta/pcs/trustee/decrypt/0.1#response";
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\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 \"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 \"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 \"document\": {\n \"description\": \"The voting/trustees/decrypt request, signed as the trustee.\",\n \"properties\": {\n \"expiresAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"id\": {\n \"pattern\": \"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$\",\n \"type\": \"string\"\n },\n \"issuedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"issuer\": {\n \"description\": \"The signer.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"payload\": {\n \"description\": \"That task's request payload.\",\n \"type\": \"object\"\n },\n \"proof\": {\n \"description\": \"A Data Integrity proof by an `authentication` key of `issuer`.\",\n \"type\": \"object\"\n },\n \"recipient\": {\n \"description\": \"The ballot box.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"https://trusttasks.org/spec/voting/trustees/decrypt/0.1\"\n }\n },\n \"required\": [\n \"id\",\n \"type\",\n \"issuer\",\n \"recipient\",\n \"issuedAt\",\n \"payload\",\n \"proof\"\n ],\n \"title\": \"DecryptDocument\",\n \"type\": \"object\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n }\n },\n \"required\": [\n \"document\"\n ],\n \"title\": \"VTA PCS — Trustee Decrypt — response payload\",\n \"type\": \"object\"\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::TRUSTEE_NOT_HELD,
error_codes::KEY_NOT_HELD,
error_codes::NOT_CLOSED,
];
/// 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 {
/// `vta/pcs/trustee/decrypt:trusteeNotHeld`
///
/// The VTA holds no `authentication` key of `trustee` that the caller may act as, or the manifest does not name `trustee` as a trustee.
///
/// Declared `retryable: false`.
pub const TRUSTEE_NOT_HELD: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/trustee/decrypt:trusteeNotHeld",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/pcs/trustee/decrypt:keyNotHeld`
///
/// This VTA holds no key share of the trustee for this election.
///
/// Declared `retryable: false`.
pub const KEY_NOT_HELD: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/trustee/decrypt:keyNotHeld",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/pcs/trustee/decrypt:notClosed`
///
/// Voting has not closed: no decryption is made before it does (VTI-VOT-063).
///
/// Declared `retryable: false`.
pub const NOT_CLOSED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/trustee/decrypt:notClosed",
retryable: false,
details_schema: ::core::option::Option::None,
};
}