Skip to main content

nym_compact_ecash/
constants.rs

1// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use nym_bls12_381_fork::Scalar;
5use nym_network_defaults::ecash::TICKETBOOK_VALIDITY_DAYS;
6use nym_network_defaults::TICKETBOOK_SIZE;
7
8pub const PUBLIC_ATTRIBUTES_LEN: usize = 2; //expiration date and ticket type
9pub const PRIVATE_ATTRIBUTES_LEN: usize = 2; //user and wallet secret
10pub const ATTRIBUTES_LEN: usize = PUBLIC_ATTRIBUTES_LEN + PRIVATE_ATTRIBUTES_LEN; // number of attributes encoded in a single zk-nym credential
11/// Attributes the spender proves in zero knowledge: everything but the ticket type, which is revealed. The expiration date is public at issuance but hidden at spend; the spend date is shown instead.
12pub const SPEND_PROOF_HIDDEN_ATTRIBUTES_LEN: usize = ATTRIBUTES_LEN - 1;
13
14pub const CRED_VALIDITY_PERIOD_DAYS: u32 = TICKETBOOK_VALIDITY_DAYS;
15
16pub(crate) const SECONDS_PER_DAY: u32 = 86400;
17
18/// Total number of tickets in each issued ticket book.
19pub const NB_TICKETS: u64 = TICKETBOOK_SIZE;
20
21pub const TYPE_EXP: Scalar = Scalar::from_raw([
22    u64::from_le_bytes(*b"ZKNYMEXP"),
23    u64::from_le_bytes(*b"IRATIOND"),
24    u64::from_le_bytes(*b"ATE4llCB"),
25    u64::from_le_bytes(*b"MEypAxr3"),
26]);
27pub const TYPE_IDX: Scalar = Scalar::from_raw([
28    u64::from_le_bytes(*b"ZKNYMSIN"),
29    u64::from_le_bytes(*b"DICESh^7"),
30    u64::from_le_bytes(*b"gTYbhnap"),
31    u64::from_le_bytes(*b"*12n5GG6"),
32]);