fc2eedfc66
add offline ecash library minor changes in coconut benchmarks add ecash smart contract change contract traits from coconut to ecash first wave of andrew's suggestion first wave of andrew's suggestion second wave of andrew's suggestion for ecash lib andrew's suggestion for ecash contract licensing commit safety comments for most unwraps more unwrap handling change chrono crate for time latest cargo lock error revamp small visibility fix small fix remove indexedmap from contract + some tweaks add cw2 version in ecash contract remove envryption key from contract change types from coconut to ecash types adapt api model for credential issuance adapt issued credential storage on API add signatures cache on API change API routes for new blind signing modify issued_credential table add issuance logic client-side credential and signature storage client side utils for credential issuance first wave of fix some of andrew's suggestions remove encryption key from deposit freepass issuance client side freepass issuance API side andrew's suggested fixes other suggested fix adapt change from PR below allow offline verification flag credential spending models credential spending models for client credential preperation for the client credential preperation for the client credential storage for spending on client bloom filter for API spent credential storage on validators API route for spending online and offline ecash API routes in the client lib credential storage on gateway ecash verifier to replace coconut verifier accept credentials on gateway bandwidth expiration for gateways client ask for more bandwidth if it runs out credential import adapt nym validator rewarder and sdk fix tests api tests and add constants cargo fmt and lock and small test fix cargo fmt and lock and small test fix cargo lock move stuff where they belong in ecash and static parameters move some constants, error handling and phase out time crate error revamp part 2 secret key by ref instead of clone change l in wallet and v visibility rework payinfo rework monster tuples fix expiration date signature cloning minor fixes final bits and bobs fixes final bits and bobs fixes rename l accessor to tickets_spent wave of fixes second wave of fixes change hash domain value removed benchmark flag remove useless stringification in storage nuke Bandwidth voucher change timestamps to offsetdatetime key name change post-rebase fixes update nym-connect 'time' dep due to broken semver upload ecash contract to the build server make wasm zknym-lib compile but it won't work properly just yet make wasm zknym-lib compile but it won't work properly just yet fix typo in ecash contract deps make sure to use 0.1.0 sphinx packet optimise pairings in 'check_vk_pairing' derive serde for ecash types simplified g1 tuple byte conversion further optimise the pairing unified signature type + renamed nym-api coconut module to ecash using bincode serialiser for more complex binary types using multimiller loop instead of rayon for verifying coin indices signatures batching signature verification wherever possible feature-locked rayon clippy refactor ecash contract a bit + introduce deposit storage reworked find_proposal_id various minor fixed add offline_zk_nyms to nym-node everywhere add missing #query change test value to fit new serialization optimised deposits storage removed duplicate decompression code using deposit_id instead of transaction hash removed freepasses split up ecash handling unified shared state fixed deposit_id parsing log recovered deposit id removed online verification add detailed build info to ecash contract fixed deserialisation of deposit amount received from nyxd queries changed deposit to only persist attached pubkey first iteration of split of verification and redemption basic tool for setting up new network expanded the tool with the option to bypass DKG rename + init network without DKG setting up locally running apis ecash key migration more local functionalities wip fixing sql schemas gateway immediately submitting redemption proposal and getting it passed if valid most of the gateway logic for split redemption with error recovery fixed gateway not persisting ecash signers simplify creation of compatible client create properly serialised ecash key from the beginning rebuild missing tickets and proposals on startup stop ticket issuance during DKG transition fixing build issues split out ecash storage on nym-api side master-verification-key route caching all the signatures and keys implemented aggregated routes for nym-apis swagger UI for ecash endpoints added explicit annotation for index and expiration signatures revamped client ticketbook storage save all recovery information in the same underlying storage wrapper for bloomfilter being more aggressive with marking tickets as used ensure client has correct signatures before making deposit fix deserialisation of AggregatedExpirationDateSignatureResponse + add ticketbook table split nym-api ecash routes handlers into multiple files fixed deserialisation of encoded expiration date add tt_gamma1 to challenge and change naming for paper consistency rotating double spending bloomfilter nym-api test fixes + make sure to insert initial BF params fixed ecash benchmark code updated contract schema updated CI to not upload gateway/mixnode binaries ticket bandwidth revocation added default deserialisation for zk nym config post-rebase fixes
226 lines
7.4 KiB
Rust
226 lines
7.4 KiB
Rust
// Copyright 2022-2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use crate::client::mix_traffic::transceiver::ErasedGatewayError;
|
|
use nym_crypto::asymmetric::identity::Ed25519RecoveryError;
|
|
use nym_gateway_client::error::GatewayClientError;
|
|
use nym_topology::gateway::GatewayConversionError;
|
|
use nym_topology::NymTopologyError;
|
|
use nym_validator_client::ValidatorClientError;
|
|
use std::error::Error;
|
|
use std::path::PathBuf;
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
pub enum ClientCoreError {
|
|
#[error("I/O error: {0}")]
|
|
IoError(#[from] std::io::Error),
|
|
|
|
#[error("gateway client error ({gateway_id}): {source}")]
|
|
GatewayClientError {
|
|
gateway_id: String,
|
|
source: GatewayClientError,
|
|
},
|
|
|
|
#[error("custom gateway client error: {source}")]
|
|
ErasedGatewayClientError {
|
|
#[from]
|
|
source: ErasedGatewayError,
|
|
},
|
|
|
|
#[error("ed25519 error: {0}")]
|
|
Ed25519RecoveryError(#[from] Ed25519RecoveryError),
|
|
|
|
#[error("validator client error: {0}")]
|
|
ValidatorClientError(#[from] ValidatorClientError),
|
|
|
|
#[error("no gateway with id: {0}")]
|
|
NoGatewayWithId(String),
|
|
|
|
#[error("no gateways on network")]
|
|
NoGatewaysOnNetwork,
|
|
|
|
#[error("there are no more new gateways on the network - it seems this client has already registered with all nodes it could have")]
|
|
NoNewGatewaysAvailable,
|
|
|
|
#[error("list of nym apis is empty")]
|
|
ListOfNymApisIsEmpty,
|
|
|
|
#[error("the current network topology seem to be insufficient to route any packets through")]
|
|
InsufficientNetworkTopology(#[from] NymTopologyError),
|
|
|
|
#[error("experienced a failure with our reply surb persistent storage: {source}")]
|
|
SurbStorageError {
|
|
source: Box<dyn Error + Send + Sync>,
|
|
},
|
|
|
|
#[error("experienced a failure with our cryptographic keys persistent storage: {source}")]
|
|
KeyStoreError {
|
|
source: Box<dyn Error + Send + Sync>,
|
|
},
|
|
|
|
#[error("experienced a failure with our gateways details storage: {source}")]
|
|
GatewaysDetailsStoreError {
|
|
source: Box<dyn Error + Send + Sync>,
|
|
},
|
|
|
|
#[error("experienced a failure with our credentials storage: {source}")]
|
|
CredentialStoreError {
|
|
source: Box<dyn Error + Send + Sync>,
|
|
},
|
|
|
|
#[error("the gateway id is invalid - {0}")]
|
|
UnableToCreatePublicKeyFromGatewayId(Ed25519RecoveryError),
|
|
|
|
#[error("The gateway is malformed: {source}")]
|
|
MalformedGateway {
|
|
#[from]
|
|
source: GatewayConversionError,
|
|
},
|
|
|
|
#[error("failed to establish connection to gateway: {source}")]
|
|
GatewayConnectionFailure {
|
|
#[from]
|
|
source: tungstenite::Error,
|
|
},
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
#[error("failed to establish gateway connection (wasm)")]
|
|
GatewayJsConnectionFailure,
|
|
|
|
#[error("gateway connection was abruptly closed")]
|
|
GatewayConnectionAbruptlyClosed,
|
|
|
|
#[error("timed out while trying to establish gateway connection")]
|
|
GatewayConnectionTimeout,
|
|
|
|
#[error("no ping measurements for the gateway ({identity}) performed")]
|
|
NoGatewayMeasurements { identity: String },
|
|
|
|
#[error("failed to register receiver for reconstructed mixnet messages")]
|
|
FailedToRegisterReceiver,
|
|
|
|
#[error("unexpected exit")]
|
|
UnexpectedExit,
|
|
|
|
#[error("this operation would have resulted in the gateway {gateway_id:?} key being overwritten without permission")]
|
|
ForbiddenGatewayKeyOverwrite { gateway_id: String },
|
|
|
|
#[error(
|
|
"this operation would have resulted in clients keys being overwritten without permission"
|
|
)]
|
|
ForbiddenKeyOverwrite,
|
|
|
|
#[error("the client doesn't have any gateway set as active")]
|
|
NoActiveGatewaySet,
|
|
|
|
#[error("gateway details for gateway {gateway_id:?} are unavailable")]
|
|
UnavailableGatewayDetails {
|
|
gateway_id: String,
|
|
#[source]
|
|
source: Box<dyn Error + Send + Sync>,
|
|
},
|
|
|
|
#[error("gateway shared key is unavailable whilst we have full node information")]
|
|
UnavailableSharedKey,
|
|
|
|
#[error("attempted to obtain fresh gateway details whilst already knowing about one")]
|
|
UnexpectedGatewayDetails,
|
|
|
|
#[error("the provided gateway details (for gateway {gateway_id}) do not correspond to the shared keys")]
|
|
MismatchedGatewayDetails { gateway_id: String },
|
|
|
|
#[error("unable to upgrade config file from `{current_version}`")]
|
|
ConfigFileUpgradeFailure { current_version: String },
|
|
|
|
#[error("unable to upgrade config file to `{new_version}`")]
|
|
UnableToUpgradeConfigFile { new_version: String },
|
|
|
|
#[error("failed to upgrade config file: {message}")]
|
|
UpgradeFailure { message: String },
|
|
|
|
#[error("the provided gateway details don't much the stored data")]
|
|
MismatchedStoredGatewayDetails,
|
|
|
|
#[error("custom selection of gateway was expected")]
|
|
CustomGatewaySelectionExpected,
|
|
|
|
#[error("the persisted gateway details were set for a custom setup")]
|
|
UnexpectedPersistedCustomGatewayDetails,
|
|
|
|
#[error("this client has performed gateway initialisation in another session")]
|
|
NoInitClientPresent,
|
|
|
|
#[error("there are no gateways supporting the wss protocol available")]
|
|
NoWssGateways,
|
|
|
|
#[error("the specified gateway '{gateway}' does not support the wss protocol")]
|
|
UnsupportedWssProtocol { gateway: String },
|
|
|
|
#[error(
|
|
"failed to load custom topology using path '{}'. detailed message: {source}", file_path.display()
|
|
)]
|
|
CustomTopologyLoadFailure {
|
|
file_path: PathBuf,
|
|
#[source]
|
|
source: std::io::Error,
|
|
},
|
|
|
|
#[error(
|
|
"failed to save config file for client-{typ} id {id} using path '{}'. detailed message: {source}", path.display()
|
|
)]
|
|
ConfigSaveFailure {
|
|
typ: String,
|
|
id: String,
|
|
path: PathBuf,
|
|
#[source]
|
|
source: std::io::Error,
|
|
},
|
|
|
|
#[error("the provided gateway identity {gateway_id} is malformed: {source}")]
|
|
MalformedGatewayIdentity {
|
|
gateway_id: String,
|
|
|
|
#[source]
|
|
source: Ed25519RecoveryError,
|
|
},
|
|
|
|
#[error("the account owner of gateway {gateway_id} ({raw_owner}) is malformed: {err}")]
|
|
MalformedGatewayOwnerAccountAddress {
|
|
gateway_id: String,
|
|
|
|
raw_owner: String,
|
|
|
|
// just use the string formatting as opposed to underlying type to avoid having to import cosmrs
|
|
err: String,
|
|
},
|
|
|
|
#[error(
|
|
"the listening address of gateway {gateway_id} ({raw_listener}) is malformed: {source}"
|
|
)]
|
|
MalformedListener {
|
|
gateway_id: String,
|
|
|
|
raw_listener: String,
|
|
|
|
#[source]
|
|
source: url::ParseError,
|
|
},
|
|
|
|
#[error("this client (id: '{client_id}') has already been initialised before. If you want to add additional gateway, use `add-gateway` command")]
|
|
AlreadyInitialised { client_id: String },
|
|
|
|
#[error("this client has already registered with gateway {gateway_id}")]
|
|
AlreadyRegistered { gateway_id: String },
|
|
}
|
|
|
|
/// Set of messages that the client can send to listeners via the task manager
|
|
#[derive(thiserror::Error, Debug)]
|
|
pub enum ClientCoreStatusMessage {
|
|
// NOTE: The nym-connect frontend listens for these strings, so don't change them until we have a more robust mechanism in place
|
|
#[error("The connected gateway is slow, or the connection to it is slow")]
|
|
GatewayIsSlow,
|
|
// NOTE: The nym-connect frontend listens for these strings, so don't change them until we have a more robust mechanism in place
|
|
#[error("The connected gateway is very slow, or the connection to it is very slow")]
|
|
GatewayIsVerySlow,
|
|
}
|