swap VerificationKey for VerificationKeyAuth
This commit is contained in:
@@ -33,6 +33,7 @@ futures = { workspace = true }
|
||||
openssl = { version = "^0.10.55", features = ["vendored"], optional = true }
|
||||
|
||||
nym-coconut-interface = { path = "../../coconut-interface" }
|
||||
nym_compact_ecash = { path = "../../nym_offline_compact_ecash" }
|
||||
nym-network-defaults = { path = "../../network-defaults" }
|
||||
nym-api-requests = { path = "../../../nym-api/nym-api-requests" }
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ use crate::nyxd::error::NyxdError;
|
||||
use crate::NymApiClient;
|
||||
use nym_coconut_dkg_common::types::{EpochId, NodeIndex};
|
||||
use nym_coconut_dkg_common::verification_key::ContractVKShare;
|
||||
use nym_coconut_interface::{Base58, CoconutError, VerificationKey};
|
||||
use nym_compact_ecash::error::CompactEcashError;
|
||||
use nym_compact_ecash::{Base58, VerificationKeyAuth};
|
||||
use thiserror::Error;
|
||||
use url::Url;
|
||||
|
||||
@@ -14,7 +15,7 @@ use url::Url;
|
||||
#[derive(Clone)]
|
||||
pub struct CoconutApiClient {
|
||||
pub api_client: NymApiClient,
|
||||
pub verification_key: VerificationKey,
|
||||
pub verification_key: VerificationKeyAuth,
|
||||
pub node_id: NodeIndex,
|
||||
pub cosmos_address: cosmrs::AccountId,
|
||||
}
|
||||
@@ -43,7 +44,7 @@ pub enum CoconutApiError {
|
||||
#[error("the provided verification key is malformed: {source}")]
|
||||
MalformedVerificationKey {
|
||||
#[from]
|
||||
source: CoconutError,
|
||||
source: CompactEcashError,
|
||||
},
|
||||
|
||||
#[error("the provided account address is malformed: {source}")]
|
||||
@@ -65,7 +66,7 @@ impl TryFrom<ContractVKShare> for CoconutApiClient {
|
||||
|
||||
Ok(CoconutApiClient {
|
||||
api_client: NymApiClient::new(url_address),
|
||||
verification_key: VerificationKey::try_from_bs58(&share.share)?,
|
||||
verification_key: VerificationKeyAuth::try_from_bs58(&share.share)?,
|
||||
node_id: share.node_index,
|
||||
cosmos_address: share.owner.as_str().parse()?,
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ use nym_validator_client::client::CoconutApiClient;
|
||||
|
||||
pub async fn obtain_aggregate_verification_key(
|
||||
api_clients: &[CoconutApiClient],
|
||||
) -> Result<nym_coconut_interface::VerificationKey, Error> {
|
||||
) -> Result<VerificationKeyAuth, Error> {
|
||||
if api_clients.is_empty() {
|
||||
return Err(Error::NoValidatorsAvailable);
|
||||
}
|
||||
@@ -34,10 +34,7 @@ pub async fn obtain_aggregate_verification_key(
|
||||
.map(|api_client| api_client.verification_key.clone())
|
||||
.collect();
|
||||
|
||||
Ok(nym_coconut_interface::aggregate_verification_keys(
|
||||
&shares,
|
||||
Some(&indices),
|
||||
)?)
|
||||
Ok(aggregate_verification_keys(&shares, Some(&indices))?)
|
||||
}
|
||||
|
||||
async fn obtain_partial_credential(
|
||||
@@ -103,9 +100,7 @@ pub async fn obtain_aggregate_signature(
|
||||
let mut wallets = Vec::with_capacity(coconut_api_clients.len());
|
||||
let validators_partial_vks: Vec<_> = coconut_api_clients
|
||||
.iter()
|
||||
.map(|api_client| {
|
||||
VerificationKeyAuth::from_bytes(&api_client.verification_key.to_bytes()).unwrap()
|
||||
}) //SW : THIS IS TEMPORARY, VERIFICATION KEY AND VERIFICATIONKEYAUTH ARE IDENTICAL
|
||||
.map(|api_client| api_client.verification_key.clone())
|
||||
.collect();
|
||||
let indices: Vec<_> = coconut_api_clients
|
||||
.iter()
|
||||
@@ -124,8 +119,7 @@ pub async fn obtain_aggregate_signature(
|
||||
params,
|
||||
attributes,
|
||||
&coconut_api_client.api_client,
|
||||
&VerificationKeyAuth::from_bytes(&coconut_api_client.verification_key.to_bytes())
|
||||
.unwrap(), //SW : THIS IS TEMPORARY, VERIFICATION KEY AND VERIFICATIONKEYAUTH ARE IDENTICAL
|
||||
&coconut_api_client.verification_key,
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ use crate::utils::{
|
||||
try_deserialize_g1_projective, try_deserialize_g2_projective, try_deserialize_scalar,
|
||||
try_deserialize_scalar_vec,
|
||||
};
|
||||
use crate::Base58;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct SecretKeyAuth {
|
||||
@@ -320,6 +321,18 @@ impl VerificationKeyAuth {
|
||||
}
|
||||
}
|
||||
|
||||
impl Bytable for VerificationKeyAuth {
|
||||
fn to_byte_vec(&self) -> Vec<u8> {
|
||||
self.to_bytes().to_vec()
|
||||
}
|
||||
|
||||
fn try_from_byte_slice(slice: &[u8]) -> std::result::Result<Self, CompactEcashError> {
|
||||
Self::from_bytes(slice)
|
||||
}
|
||||
}
|
||||
|
||||
impl Base58 for VerificationKeyAuth {}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct SecretKeyUser {
|
||||
pub sk: Scalar,
|
||||
|
||||
Reference in New Issue
Block a user