diff --git a/src/data_types/w3c/credential_proof.rs b/src/data_types/w3c/credential_proof.rs index c89b1642..5116ec4c 100644 --- a/src/data_types/w3c/credential_proof.rs +++ b/src/data_types/w3c/credential_proof.rs @@ -1,8 +1,9 @@ use crate::data_types::w3c::presentation_proof::CredentialPresentationProof; +use crate::utils::encoded_object::EncodedObject; +use crate::Result; use anoncreds_clsignatures::{ - CredentialSignature as CLCredentialSignature, CredentialSignatureBytesProxy, - RevocationRegistry, RevocationRegistryBytesProxy, SignatureCorrectnessProof, - SignatureCorrectnessProofBytesProxy, Witness, WitnessBytesProxy, + CredentialSignature as CLCredentialSignature, RevocationRegistry, SignatureCorrectnessProof, + Witness, }; use serde::Serialize; diff --git a/src/data_types/w3c/presentation_proof.rs b/src/data_types/w3c/presentation_proof.rs index e0f4d053..449c1102 100644 --- a/src/data_types/w3c/presentation_proof.rs +++ b/src/data_types/w3c/presentation_proof.rs @@ -3,7 +3,6 @@ use crate::utils::encoded_object::EncodedObject; use crate::Result; use anoncreds_clsignatures::{AggregatedProof, SubProof}; use std::collections::HashSet; -use crate::data_types::w3c::encoded_object::EncodedObject; #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -40,14 +39,12 @@ impl CredentialPresentationProof { mapping: CredentialAttributesMapping, timestamp: Option, ) -> Result { - Ok( - CredentialPresentationProof { - type_: PresentationProofType::AnonCredsPresentationProof2023, - mapping, - timestamp, - proof_value: proof_value.encode()?, - } - ) + Ok(CredentialPresentationProof { + type_: PresentationProofType::AnonCredsPresentationProof2023, + mapping, + timestamp, + proof_value: proof_value.encode()?, + }) } pub fn get_proof_value(&self) -> Result { @@ -75,13 +72,11 @@ pub struct PresentationProofValue { impl PresentationProof { pub fn new(proof_value: PresentationProofValue, nonce: String) -> Result { - Ok( - PresentationProof { - type_: PresentationProofType::AnonCredsPresentationProof2023, - challenge: nonce, - proof_value: proof_value.encode()?, - } - ) + Ok(PresentationProof { + type_: PresentationProofType::AnonCredsPresentationProof2023, + challenge: nonce, + proof_value: proof_value.encode()?, + }) } pub fn get_proof_value(&self) -> Result { diff --git a/src/services/w3c/credential_conversion.rs b/src/services/w3c/credential_conversion.rs index c70322f2..a74681f7 100644 --- a/src/services/w3c/credential_conversion.rs +++ b/src/services/w3c/credential_conversion.rs @@ -357,7 +357,9 @@ mod tests { CredentialValuesEncoding::Auto, )); credential.set_attributes(CredentialAttributes::from(&_cred_values())); - credential.add_anoncreds_signature_proof(CredentialSignatureProof::new(_signature_data())); + credential.add_anoncreds_signature_proof( + CredentialSignatureProof::new(_signature_data()).unwrap(), + ); credential } diff --git a/src/services/w3c/issuer.rs b/src/services/w3c/issuer.rs index d63409aa..6307fd13 100644 --- a/src/services/w3c/issuer.rs +++ b/src/services/w3c/issuer.rs @@ -113,7 +113,7 @@ pub fn create_credential( rev_reg, witness, ); - let proof = CredentialSignatureProof::new(signature); + let proof = CredentialSignatureProof::new(signature)?; let credential_schema = CredentialSchema::new( cred_offer.schema_id.to_owned(), cred_offer.cred_def_id.to_owned(), diff --git a/src/services/w3c/prover.rs b/src/services/w3c/prover.rs index f9d60947..1ca8e65c 100644 --- a/src/services/w3c/prover.rs +++ b/src/services/w3c/prover.rs @@ -126,7 +126,7 @@ pub fn process_credential( signature.rev_reg, signature.witness, ); - *proof = CredentialSignatureProof::new(signature); + *proof = CredentialSignatureProof::new(signature)?; trace!("process_w3c_credential <<< "); @@ -184,7 +184,7 @@ pub fn create_presentation( let presentation_proof_value = PresentationProofValue::new(cl_proof.aggregated_proof); let presentation_proof = - PresentationProof::new(presentation_proof_value, pres_req.nonce.to_string()); + PresentationProof::new(presentation_proof_value, pres_req.nonce.to_string())?; let mut presentation = W3CPresentation::new(); presentation.set_proof(presentation_proof); @@ -195,7 +195,7 @@ pub fn create_presentation( let mapping = build_mapping(pres_req, present)?; let credential_subject = build_credential_subject(pres_req, present)?; let proof_value = CredentialPresentationProofValue::new(sub_proof); - let proof = CredentialPresentationProof::new(proof_value, mapping, present.timestamp); + let proof = CredentialPresentationProof::new(proof_value, mapping, present.timestamp)?; let mut credential = present.cred.to_owned(); credential.set_anoncreds_presentation_proof(proof); diff --git a/tests/anoncreds_demos.rs b/tests/anoncreds_demos.rs index 3416fd68..911a195f 100644 --- a/tests/anoncreds_demos.rs +++ b/tests/anoncreds_demos.rs @@ -1,6 +1,5 @@ use anoncreds::data_types::pres_request::PredicateTypes; use anoncreds::data_types::w3c::credential::CredentialAttributeValue; -use anoncreds::data_types::w3c::credential_proof::CredentialProof; use anoncreds::data_types::w3c::presentation_proof::{PredicateAttribute, PredicateAttributeType}; use anoncreds::data_types::w3c::uri::URI; use anoncreds::verifier;