Skip to content

Commit

Permalink
issuer id
Browse files Browse the repository at this point in the history
Signed-off-by: George Mulhearn <[email protected]>
  • Loading branch information
gmulhearn-anonyome committed Dec 4, 2024
1 parent d3d1a97 commit ab7becb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ impl Convert for OurRevocationRegistryDefinition {
type Error = Box<dyn std::error::Error>;

fn convert(self, (): Self::Args) -> Result<Self::Target, Self::Error> {
let issuer_id = self.id.to_string().split(':').next().unwrap().to_string();
Ok(AnoncredsRevocationRegistryDefinition {
issuer_id: AnoncredsIssuerId::new(issuer_id)?,
issuer_id: self.issuer_id.convert(())?,
revoc_def_type: self.revoc_def_type.convert(())?,
tag: self.tag,
cred_def_id: AnoncredsCredentialDefinitionId::new(self.cred_def_id.to_string())?,
Expand All @@ -288,6 +287,7 @@ impl Convert for AnoncredsRevocationRegistryDefinition {
fn convert(self, (rev_reg_def_id,): Self::Args) -> Result<Self::Target, Self::Error> {
Ok(OurRevocationRegistryDefinition {
id: OurRevocationRegistryDefinitionId::new(rev_reg_def_id)?,
issuer_id: self.issuer_id.convert(())?,
revoc_def_type: self.revoc_def_type.convert(())?,
tag: self.tag,
cred_def_id: OurCredentialDefinitionId::new(self.cred_def_id.to_string())?,
Expand Down Expand Up @@ -492,6 +492,7 @@ impl Convert for HashMap<OurRevocationRegistryDefinitionId, HashMap<u64, OurRevo
let mut lists = Vec::new();
for (rev_reg_def_id, timestamp_map) in self.into_iter() {
for (timestamp, entry) in timestamp_map {
// TODO - bad splitting
let issuer_id = AnoncredsIssuerId::new(
rev_reg_def_id
.to_string()
Expand All @@ -507,6 +508,7 @@ impl Convert for HashMap<OurRevocationRegistryDefinitionId, HashMap<u64, OurRevo
let rev_status_list = OurRevocationStatusList::new(
Some(&rev_reg_def_id.to_string()),
issuer_id.convert(())?,
// TODO - this seems incorrect.
Default::default(),
Some(registry),
Some(timestamp),
Expand Down
1 change: 1 addition & 0 deletions aries/aries_vcx_ledger/src/ledger/cheqd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl AnoncredsLedgerRead for CheqdAnoncredsLedgerRead {
tag: data.tag,
cred_def_id: data.cred_def_id,
value: data.value,
issuer_id: extract_issuer_id(&url)?,
})
}

Expand Down
43 changes: 23 additions & 20 deletions aries/aries_vcx_ledger/src/ledger/type_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,26 +145,25 @@ impl Convert for IndyVdrCredentialDefinition {
fn convert(self, (): Self::Args) -> Result<Self::Target, Self::Error> {
match self {
IndyVdrCredentialDefinition::CredentialDefinitionV1(cred_def) => {
if let Some((_method, issuer_id, _sig_type, _schema_id, _tag)) = cred_def.id.parts()
{
Ok(OurCredentialDefinition {
id: OurCredentialDefinitionId::new(cred_def.id.to_string())?,
schema_id: OurSchemaId::new_unchecked(cred_def.schema_id.to_string()),
signature_type: OurSignatureType::CL,
tag: cred_def.tag,
value: OurCredentialDefinitionData {
primary: serde_json::from_value(cred_def.value.primary)?,
revocation: cred_def
.value
.revocation
.map(serde_json::from_value)
.transpose()?,
},
issuer_id: IssuerId::new(issuer_id.to_string())?,
})
} else {
todo!()
}
let Some((_method, issuer_id, _sig_type, _schema_id, _tag)) = cred_def.id.parts()
else {
return Err(format!("cred def ID is not valid: {}", cred_def.id).into());
};
Ok(OurCredentialDefinition {
id: OurCredentialDefinitionId::new(cred_def.id.to_string())?,
schema_id: OurSchemaId::new_unchecked(cred_def.schema_id.to_string()),
signature_type: OurSignatureType::CL,
tag: cred_def.tag,
value: OurCredentialDefinitionData {
primary: serde_json::from_value(cred_def.value.primary)?,
revocation: cred_def
.value
.revocation
.map(serde_json::from_value)
.transpose()?,
},
issuer_id: IssuerId::new(issuer_id.to_string())?,
})
}
}
}
Expand Down Expand Up @@ -233,8 +232,12 @@ impl Convert for IndyVdrRevocationRegistryDefinition {
fn convert(self, (): Self::Args) -> Result<Self::Target, Self::Error> {
match self {
IndyVdrRevocationRegistryDefinition::RevocationRegistryDefinitionV1(rev_reg_def) => {
let Some((issuer_id, _cred_def, _type, _tag)) = rev_reg_def.id.parts() else {
return Err(format!("rev reg id is not valid: {}", rev_reg_def.id).into());
};
Ok(OurRevocationRegistryDefinition {
id: OurRevocationRegistryDefinitionId::new(rev_reg_def.id.to_string())?,
issuer_id: IssuerId::new(issuer_id.to_string())?,
revoc_def_type:
anoncreds_types::data_types::ledger::rev_reg_def::RegistryType::CL_ACCUM,
tag: rev_reg_def.tag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use anoncreds_clsignatures::RevocationKeyPrivate;
use crate::{
cl::RevocationKeyPublic,
data_types::identifiers::{
cred_def_id::CredentialDefinitionId, rev_reg_def_id::RevocationRegistryDefinitionId,
cred_def_id::CredentialDefinitionId, issuer_id::IssuerId,
rev_reg_def_id::RevocationRegistryDefinitionId,
},
utils::validation::Validatable,
};
Expand Down Expand Up @@ -51,7 +52,7 @@ pub struct RevocationRegistryDefinitionValuePublicKeys {
#[serde(rename_all = "camelCase")]
pub struct RevocationRegistryDefinition {
pub id: RevocationRegistryDefinitionId,
// pub issuer_id: IssuerId, // This is not on ledger
pub issuer_id: IssuerId,
pub revoc_def_type: RegistryType,
pub tag: String,
pub cred_def_id: CredentialDefinitionId,
Expand All @@ -61,7 +62,7 @@ pub struct RevocationRegistryDefinition {
impl Validatable for RevocationRegistryDefinition {
fn validate(&self) -> Result<(), crate::error::Error> {
self.cred_def_id.validate()?;
// self.issuer_id.validate()?;
self.issuer_id.validate()?;

Ok(())
}
Expand Down

0 comments on commit ab7becb

Please sign in to comment.