diff --git a/common/cosmwasm-smart-contracts/coconut-dkg/src/types.rs b/common/cosmwasm-smart-contracts/coconut-dkg/src/types.rs index 43192e9622..f63fb39736 100644 --- a/common/cosmwasm-smart-contracts/coconut-dkg/src/types.rs +++ b/common/cosmwasm-smart-contracts/coconut-dkg/src/types.rs @@ -328,4 +328,8 @@ impl EpochState { pub fn is_dealing_exchange(&self) -> bool { matches!(self, EpochState::DealingExchange { .. }) } + + pub fn is_waiting_initialisation(&self) -> bool { + matches!(self, EpochState::WaitingInitialisation) + } } diff --git a/common/credentials-interface/src/lib.rs b/common/credentials-interface/src/lib.rs index 7edc1d6904..1337e633d5 100644 --- a/common/credentials-interface/src/lib.rs +++ b/common/credentials-interface/src/lib.rs @@ -8,11 +8,11 @@ use std::str::FromStr; use thiserror::Error; pub use nym_coconut::{ - aggregate_signature_shares_and_verify, aggregate_verification_keys, blind_sign, hash_to_scalar, - keygen, prepare_blind_sign, prove_bandwidth_credential, verify_credential, Attribute, Base58, - BlindSignRequest, BlindedSerialNumber, BlindedSignature, Bytable, CoconutError, KeyPair, - Parameters, PrivateAttribute, PublicAttribute, SecretKey, Signature, SignatureShare, - VerificationKey, VerifyCredentialRequest, + aggregate_signature_shares, aggregate_signature_shares_and_verify, aggregate_verification_keys, + blind_sign, hash_to_scalar, keygen, prepare_blind_sign, prove_bandwidth_credential, + verify_credential, Attribute, Base58, BlindSignRequest, BlindedSerialNumber, BlindedSignature, + Bytable, CoconutError, KeyPair, Parameters, PrivateAttribute, PublicAttribute, SecretKey, + Signature, SignatureShare, VerificationKey, VerifyCredentialRequest, }; pub const VOUCHER_INFO_TYPE: &str = "BandwidthVoucher"; diff --git a/common/credentials/src/coconut/bandwidth/issuance.rs b/common/credentials/src/coconut/bandwidth/issuance.rs index 396f25c8cc..a845b6ac7b 100644 --- a/common/credentials/src/coconut/bandwidth/issuance.rs +++ b/common/credentials/src/coconut/bandwidth/issuance.rs @@ -10,9 +10,9 @@ use crate::coconut::bandwidth::{ use crate::coconut::utils::scalar_serde_helper; use crate::error::Error; use nym_credentials_interface::{ - aggregate_signature_shares_and_verify, hash_to_scalar, prepare_blind_sign, Attribute, - BlindedSerialNumber, BlindedSignature, Parameters, PrivateAttribute, PublicAttribute, - Signature, SignatureShare, VerificationKey, + aggregate_signature_shares, aggregate_signature_shares_and_verify, hash_to_scalar, + prepare_blind_sign, Attribute, BlindedSerialNumber, BlindedSignature, Parameters, + PrivateAttribute, PublicAttribute, Signature, SignatureShare, VerificationKey, }; use nym_crypto::asymmetric::{encryption, identity}; use nym_validator_client::nym_api::EpochId; @@ -266,6 +266,13 @@ impl IssuanceBandwidthCredential { self.unblind_signature(validator_vk, &signing_data, blinded_signature) } + pub fn unchecked_aggregate_signature_shares( + &self, + shares: &[SignatureShare], + ) -> Result { + aggregate_signature_shares(shares).map_err(Error::SignatureAggregationError) + } + pub fn aggregate_signature_shares( &self, verification_key: &VerificationKey, diff --git a/common/credentials/src/coconut/bandwidth/voucher.rs b/common/credentials/src/coconut/bandwidth/voucher.rs index acce944fae..b65b96491a 100644 --- a/common/credentials/src/coconut/bandwidth/voucher.rs +++ b/common/credentials/src/coconut/bandwidth/voucher.rs @@ -6,7 +6,7 @@ use crate::coconut::utils::scalar_serde_helper; use crate::error::Error; use nym_api_requests::coconut::BlindSignRequestBody; use nym_credentials_interface::{ - hash_to_scalar, Attribute, BlindSignRequest, BlindedSignature, PublicAttribute, + hash_to_scalar, Attribute, BlindSignRequest, BlindedSignature, CredentialType, PublicAttribute, }; use nym_crypto::asymmetric::{encryption, identity}; use nym_validator_client::nyxd::{Coin, Hash}; @@ -123,6 +123,10 @@ impl BandwidthVoucherIssuanceData { &self.value_prehashed } + pub fn typ() -> CredentialType { + CredentialType::Voucher + } + pub fn tx_hash(&self) -> Hash { self.deposit_tx_hash } diff --git a/common/nymcoconut/src/scheme/issuance.rs b/common/nymcoconut/src/scheme/issuance.rs index 1582a55e98..3779e377d6 100644 --- a/common/nymcoconut/src/scheme/issuance.rs +++ b/common/nymcoconut/src/scheme/issuance.rs @@ -157,6 +157,10 @@ impl BlindSignRequest { ) } + pub fn verify_commitment_hash(&self, public_attributes: &[&Attribute]) -> bool { + self.commitment_hash == compute_hash(self.commitment, public_attributes) + } + pub fn get_commitment_hash(&self) -> G1Projective { self.commitment_hash }