Skip to main content

nym_compact_ecash/
lib.rs

1// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4#![deny(clippy::indexing_slicing)]
5#![cfg_attr(test, allow(clippy::indexing_slicing))]
6#![cfg_attr(test, allow(clippy::unwrap_used))]
7
8use nym_bls12_381_fork::Scalar;
9use std::sync::OnceLock;
10
11pub use crate::error::CompactEcashError;
12pub use crate::traits::Bytable;
13pub use common_types::{BlindedSignature, Signature};
14pub use helpers::{date_scalar, type_scalar};
15pub use nym_bls12_381_fork::G1Projective;
16pub use scheme::aggregation::aggregate_verification_keys;
17pub use scheme::aggregation::aggregate_wallets;
18pub use scheme::identify;
19pub use scheme::keygen::ttp_keygen;
20pub use scheme::keygen::{generate_keypair_user, generate_keypair_user_from_seed};
21pub use scheme::keygen::{
22    KeyPairAuth, PublicKeyUser, SecretKeyAuth, SecretKeyUser, VerificationKeyAuth,
23};
24pub use scheme::setup;
25pub use scheme::withdrawal::issue;
26pub use scheme::withdrawal::issue_verify;
27pub use scheme::withdrawal::withdrawal_request;
28pub use scheme::withdrawal::WithdrawalRequest;
29pub use scheme::PartialWallet;
30pub use scheme::PayInfo;
31pub use setup::GroupParameters;
32pub use traits::Base58;
33
34pub mod common_types;
35pub mod constants;
36pub mod error;
37mod helpers;
38pub mod proofs;
39pub mod scheme;
40pub mod tests;
41mod traits;
42pub mod utils;
43
44pub type Attribute = Scalar;
45pub type EncodedTicketType = u8;
46pub type EncodedDate = u32;
47
48pub fn ecash_parameters() -> &'static setup::Parameters {
49    static ECASH_PARAMS: OnceLock<setup::Parameters> = OnceLock::new();
50    ECASH_PARAMS.get_or_init(|| setup::Parameters::new(constants::NB_TICKETS))
51}
52
53pub fn ecash_group_parameters() -> &'static setup::GroupParameters {
54    static ECASH_PARAMS: OnceLock<setup::GroupParameters> = OnceLock::new();
55    ECASH_PARAMS.get_or_init(|| setup::GroupParameters::new(constants::ATTRIBUTES_LEN))
56}
57
58// if anything changes here you MUST correctly increase semver of this library
59pub(crate) fn binary_serialiser() -> impl bincode::Options {
60    use bincode::Options;
61    bincode::DefaultOptions::new()
62        .with_big_endian()
63        .with_varint_encoding()
64}