zkgroup/api/receipts/
receipt_credential_presentation.rs

1//
2// Copyright 2021 Signal Messenger, LLC.
3// SPDX-License-Identifier: AGPL-3.0-only
4//
5
6use partial_default::PartialDefault;
7use serde::{Deserialize, Serialize};
8
9use crate::common::serialization::ReservedByte;
10use crate::crypto::receipt_struct::ReceiptStruct;
11use crate::{crypto, ReceiptLevel, ReceiptSerialBytes, Timestamp};
12
13// Note that this type appears in gift badge messages, and thus in backups.
14// Therefore it must be possible to at least deserialize any past versions of it,
15// though they don't have to still be considered valid.
16#[derive(Serialize, Deserialize, PartialDefault)]
17pub struct ReceiptCredentialPresentation {
18    pub(crate) reserved: ReservedByte,
19    pub(crate) proof: crypto::proofs::ReceiptCredentialPresentationProof,
20    pub(crate) receipt_expiration_time: Timestamp,
21    pub(crate) receipt_level: ReceiptLevel,
22    pub(crate) receipt_serial_bytes: ReceiptSerialBytes,
23}
24
25impl ReceiptCredentialPresentation {
26    pub fn get_receipt_struct(&self) -> ReceiptStruct {
27        ReceiptStruct {
28            receipt_serial_bytes: self.receipt_serial_bytes,
29            receipt_expiration_time: self.receipt_expiration_time,
30            receipt_level: self.receipt_level,
31        }
32    }
33
34    pub fn get_receipt_expiration_time(&self) -> Timestamp {
35        self.receipt_expiration_time
36    }
37
38    pub fn get_receipt_level(&self) -> ReceiptLevel {
39        self.receipt_level
40    }
41
42    pub fn get_receipt_serial_bytes(&self) -> ReceiptSerialBytes {
43        self.receipt_serial_bytes
44    }
45}