Skip errors on blind sign within threshold (#2976)

This commit is contained in:
Bogdan-Ștefan Neacşu
2023-02-08 11:54:12 +02:00
committed by GitHub
parent f8345e03c6
commit 590a4644e2
4 changed files with 22 additions and 4 deletions
+6
View File
@@ -82,6 +82,11 @@ pub(crate) async fn get_credential(state: &State, shared_storage: PersistentStor
let config = Config::try_from_nym_network_details(&network_details)?;
let client = validator_client::Client::new_query(config)?;
let epoch_id = client.nyxd.get_current_epoch().await?.epoch_id;
let threshold = client
.nyxd
.get_current_epoch_threshold()
.await?
.ok_or(CredentialClientError::NoThreshold)?;
let coconut_api_clients = CoconutApiClient::all_coconut_api_clients(&client, epoch_id).await?;
let params = Parameters::new(TOTAL_ATTRIBUTES).unwrap();
@@ -98,6 +103,7 @@ pub(crate) async fn get_credential(state: &State, shared_storage: PersistentStor
&params,
&bandwidth_credential_attributes,
&coconut_api_clients,
threshold,
)
.await?;
println!("Signature: {:?}", signature.to_bs58());
+3
View File
@@ -34,4 +34,7 @@ pub enum CredentialClientError {
#[error("Could not use shared storage")]
SharedStorageError(#[from] StorageError),
#[error("Threshold not set yet")]
NoThreshold,
}
+10 -4
View File
@@ -92,6 +92,7 @@ pub async fn obtain_aggregate_signature(
params: &Parameters,
attributes: &BandwidthVoucher,
coconut_api_clients: &[CoconutApiClient],
threshold: u64,
) -> Result<Signature, Error> {
if coconut_api_clients.is_empty() {
return Err(Error::NoValidatorsAvailable);
@@ -110,15 +111,20 @@ pub async fn obtain_aggregate_signature(
.collect();
for coconut_api_client in coconut_api_clients.iter() {
let signature = obtain_partial_credential(
if let Ok(signature) = obtain_partial_credential(
params,
attributes,
&coconut_api_client.api_client,
&coconut_api_client.verification_key,
)
.await?;
let share = SignatureShare::new(signature, coconut_api_client.node_id);
shares.push(share)
.await
{
let share = SignatureShare::new(signature, coconut_api_client.node_id);
shares.push(share)
}
}
if shares.len() < threshold as usize {
return Err(Error::NotEnoughShares);
}
let mut attributes = Vec::with_capacity(private_attributes.len() + public_attributes.len());
+3
View File
@@ -29,4 +29,7 @@ pub enum Error {
#[error("Could not parse the key - {0}")]
ParsePublicKey(#[from] KeyRecoveryError),
#[error("Could not gather enough signature shares")]
NotEnoughShares,
}