removed nym-api placeholders

This commit is contained in:
Jędrzej Stuczyński
2024-02-07 17:31:30 +00:00
parent 0ee727bac1
commit 16c942d72e
3 changed files with 25 additions and 3 deletions
@@ -5,7 +5,7 @@ use crate::coconut::helpers::issued_credential_plaintext;
use cosmrs::AccountId;
use nym_credentials_interface::{
hash_to_scalar, Attribute, BlindSignRequest, BlindedSignature, Bytable, CoconutError,
CredentialSpendingData, Signature, VerificationKey,
CredentialSpendingData, VerificationKey,
};
use nym_crypto::asymmetric::identity;
use serde::{Deserialize, Serialize};
+8 -2
View File
@@ -100,9 +100,15 @@ pub async fn verify_bandwidth_credential(
let theta = &credential_data.verify_credential_request;
let voucher_value: u64 = if credential_data.typ.is_voucher() {
todo!()
credential_data
.get_bandwidth_attribute()
.ok_or(CoconutError::MissingBandwidthValue)?
.parse()
.map_err(|source| CoconutError::VoucherValueParsingFailure { source })?
} else {
todo!("return error here")
return Err(CoconutError::NotABandwidthVoucher {
typ: credential_data.typ,
});
};
// TODO: introduce a check to make sure we haven't already voted for this proposal to prevent DDOS
+16
View File
@@ -3,6 +3,7 @@
use crate::node_status_api::models::NymApiStorageError;
use nym_coconut_dkg_common::types::{ChunkIndex, DealingIndex, EpochId};
use nym_credentials::coconut::bandwidth::CredentialType;
use nym_crypto::asymmetric::{
encryption::KeyRecoveryError,
identity::{Ed25519RecoveryError, SignatureError},
@@ -14,6 +15,7 @@ use rocket::http::{ContentType, Status};
use rocket::response::Responder;
use rocket::{response, Request, Response};
use std::io::Cursor;
use std::num::ParseIntError;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, CoconutError>;
@@ -23,6 +25,20 @@ pub enum CoconutError {
#[error(transparent)]
IOError(#[from] std::io::Error),
#[error("the received bandwidth voucher did not contain deposit value")]
MissingBandwidthValue,
#[error(
"the received bandwidth credential is not a bandwidth voucher. the encoded type is: {typ}"
)]
NotABandwidthVoucher { typ: CredentialType },
#[error("failed to parse the bandwidth voucher value: {source}")]
VoucherValueParsingFailure {
#[source]
source: ParseIntError,
},
#[error("coconut api query failure: {0}")]
CoconutApiError(#[from] CoconutApiError),