Skip to content

Commit

Permalink
remove tails path from credential revocation config
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
  • Loading branch information
andrewwhitehead committed Aug 3, 2023
1 parent 1f71f4c commit eaf465e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 41 deletions.
9 changes: 0 additions & 9 deletions src/ffi/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::error::Result;
use crate::services::{
issuer::create_credential,
prover::process_credential,
tails::TailsFileReader,
types::{Credential, CredentialRevocationConfig, MakeCredentialValues},
utils::encode_credential_attribute,
};
Expand All @@ -30,7 +29,6 @@ struct RevocationConfig {
reg_def: AnoncredsObject,
reg_def_private: AnoncredsObject,
reg_idx: u32,
tails_path: String,
}

impl RevocationConfig {
Expand All @@ -39,7 +37,6 @@ impl RevocationConfig {
reg_def: self.reg_def.cast_ref()?,
reg_def_private: self.reg_def_private.cast_ref()?,
registry_idx: self.reg_idx,
tails_reader: TailsFileReader::new_tails_reader(self.tails_path.as_str()),
})
}
}
Expand Down Expand Up @@ -103,19 +100,13 @@ pub extern "C" fn anoncreds_create_credential(
None
} else {
let revocation = unsafe { &*revocation };
let tails_path = revocation
.tails_path
.as_opt_str()
.ok_or_else(|| err_msg!("Missing tails file path"))?
.to_string();
Some(RevocationConfig {
reg_def: revocation.reg_def.load()?,
reg_def_private: revocation.reg_def_private.load()?,
reg_idx: revocation
.reg_idx
.try_into()
.map_err(|_| err_msg!("Invalid revocation index"))?,
tails_path,
})
};

Expand Down
5 changes: 1 addition & 4 deletions src/services/types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::tails::TailsReader;
use crate::cl::{RevocationRegistry as CryptoRevocationRegistry, Witness};
pub use crate::data_types::{
cred_def::{CredentialDefinitionPrivate, CredentialKeyCorrectnessProof, SignatureType},
Expand Down Expand Up @@ -219,18 +218,16 @@ pub struct CredentialRevocationConfig<'a> {
pub reg_def: &'a RevocationRegistryDefinition,
pub reg_def_private: &'a RevocationRegistryDefinitionPrivate,
pub registry_idx: u32,
pub tails_reader: TailsReader,
}

impl<'a> std::fmt::Debug for CredentialRevocationConfig<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"CredentialRevocationConfig {{ reg_def: {:?}, private: {:?}, idx: {}, reader: {:?} }}",
"CredentialRevocationConfig {{ reg_def: {:?}, private: {:?}, idx: {} }}",
self.reg_def,
secret!(self.reg_def_private),
secret!(self.registry_idx),
self.tails_reader,
)
}
}
4 changes: 1 addition & 3 deletions tests/anoncreds_demos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anoncreds::data_types::rev_reg_def::RevocationRegistryDefinitionId;
use anoncreds::data_types::schema::SchemaId;
use anoncreds::issuer;
use anoncreds::prover;
use anoncreds::tails::{TailsFileReader, TailsFileWriter};
use anoncreds::tails::TailsFileWriter;
use anoncreds::types::{CredentialRevocationConfig, PresentCredentials};
use anoncreds::verifier;
use serde_json::json;
Expand Down Expand Up @@ -243,7 +243,6 @@ fn anoncreds_demo_works_with_revocation_for_single_issuer_single_prover() {

// Get the location of the tails_file so it can be read
let tails_location = gvt_rev_reg_def.value.tails_location.clone();
let tr = TailsFileReader::new_tails_reader(tails_location.as_str());

let issue_cred = issuer::create_credential(
&gvt_cred_def,
Expand All @@ -257,7 +256,6 @@ fn anoncreds_demo_works_with_revocation_for_single_issuer_single_prover() {
reg_def: &gvt_rev_reg_def,
reg_def_private: &gvt_rev_reg_def_priv,
registry_idx: fixtures::GVT_REV_IDX,
tails_reader: tr,
}),
)
.expect("Error creating credential");
Expand Down
24 changes: 9 additions & 15 deletions tests/utils/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use anoncreds::{
schema::{Schema, SchemaId},
},
issuer, prover,
tails::{TailsFileReader, TailsFileWriter},
tails::TailsFileWriter,
types::{
CredentialDefinitionConfig, CredentialRequest, CredentialRevocationConfig,
MakeCredentialValues, PresentCredentials, PresentationRequest, RegistryType, SignatureType,
Expand Down Expand Up @@ -268,20 +268,14 @@ impl<'a> Mock<'a> {
}

let (rev_config, rev_id) = match issuer_wallet.rev_defs.get(rev_reg_id) {
Some(stored_rev_def) => {
let tr = TailsFileReader::new_tails_reader(
stored_rev_def.public.value.tails_location.as_str(),
);
(
Some(CredentialRevocationConfig {
reg_def: &stored_rev_def.public,
reg_def_private: &stored_rev_def.private,
registry_idx: rev_idx,
tails_reader: tr,
}),
Some(RevocationRegistryId::new_unchecked(rev_reg_id)),
)
}
Some(stored_rev_def) => (
Some(CredentialRevocationConfig {
reg_def: &stored_rev_def.public,
reg_def_private: &stored_rev_def.private,
registry_idx: rev_idx,
}),
Some(RevocationRegistryId::new_unchecked(rev_reg_id)),
),
None => (None, None),
};

Expand Down
3 changes: 0 additions & 3 deletions wrappers/python/anoncreds/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ class RevocationConfig(Structure):
("rev_reg_def", ObjectHandle),
("rev_reg_def_private", ObjectHandle),
("rev_reg_index", c_int64),
("tails_path", c_char_p),
]

@classmethod
Expand All @@ -407,13 +406,11 @@ def create(
rev_reg_def: AnoncredsObject,
rev_reg_def_private: AnoncredsObject,
rev_reg_index: int,
tails_path: str,
) -> "RevocationConfig":
config = RevocationConfig(
rev_reg_def=rev_reg_def.handle,
rev_reg_def_private=rev_reg_def_private.handle,
rev_reg_index=rev_reg_index,
tails_path=encode_str(tails_path),
)
keepalive(config, rev_reg_def, rev_reg_def_private)
return config
Expand Down
3 changes: 0 additions & 3 deletions wrappers/python/anoncreds/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ def __init__(
rev_reg_def: Union[str, "RevocationRegistryDefinition"],
rev_reg_def_private: Union[str, "RevocationRegistryDefinitionPrivate"],
rev_reg_index: int,
tails_path: str,
):
if not isinstance(rev_reg_def, bindings.AnoncredsObject):
rev_reg_def = RevocationRegistryDefinition.load(rev_reg_def)
Expand All @@ -641,15 +640,13 @@ def __init__(
)
self.rev_reg_def_private = rev_reg_def_private
self.rev_reg_index = rev_reg_index
self.tails_path = tails_path

@property
def _native(self) -> bindings.RevocationConfig:
return bindings.RevocationConfig.create(
self.rev_reg_def,
self.rev_reg_def_private,
self.rev_reg_index,
self.tails_path,
)

class NonrevokedIntervalOverride:
Expand Down
4 changes: 0 additions & 4 deletions wrappers/python/demo/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from time import time

from anoncreds import (
generate_nonce,
create_link_secret,
Expand All @@ -14,7 +12,6 @@
PresentCredentials,
RevocationRegistryDefinition,
RevocationStatusList,
NonrevokedIntervalOverride,
Schema,
)

Expand Down Expand Up @@ -92,7 +89,6 @@
rev_reg_def_pub,
rev_reg_def_private,
rev_idx,
rev_reg_def_pub.tails_location,
),
)

Expand Down

0 comments on commit eaf465e

Please sign in to comment.