diff --git a/anoncreds/src/data_types/anoncreds/rev_reg_def.rs b/anoncreds/src/data_types/anoncreds/rev_reg_def.rs index 4d7a364f..26c1016e 100644 --- a/anoncreds/src/data_types/anoncreds/rev_reg_def.rs +++ b/anoncreds/src/data_types/anoncreds/rev_reg_def.rs @@ -9,47 +9,8 @@ use super::cred_def::CredentialDefinitionId; pub const CL_ACCUM: &str = "CL_ACCUM"; -pub const ISSUANCE_BY_DEFAULT: &str = "ISSUANCE_BY_DEFAULT"; -pub const ISSUANCE_ON_DEMAND: &str = "ISSUANCE_ON_DEMAND"; - impl_anoncreds_object_identifier!(RevocationRegistryDefinitionId); -#[allow(non_camel_case_types)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)] -pub enum IssuanceType { - #[default] - ISSUANCE_BY_DEFAULT, - ISSUANCE_ON_DEMAND, -} - -impl FromStr for IssuanceType { - type Err = ConversionError; - - fn from_str(s: &str) -> Result { - match s { - ISSUANCE_BY_DEFAULT => Ok(Self::ISSUANCE_BY_DEFAULT), - ISSUANCE_ON_DEMAND => Ok(Self::ISSUANCE_ON_DEMAND), - _ => Err(ConversionError::from_msg("Invalid issuance type")), - } - } -} - -impl From for usize { - fn from(value: IssuanceType) -> usize { - match value { - // Credentials are by default revoked - IssuanceType::ISSUANCE_ON_DEMAND => 1, - // Credentials are by default not revoked - IssuanceType::ISSUANCE_BY_DEFAULT => 0, - } - } -} - -impl IssuanceType { - pub fn to_bool(&self) -> bool { - *self == IssuanceType::ISSUANCE_BY_DEFAULT - } -} #[allow(non_camel_case_types)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub enum RegistryType { @@ -70,7 +31,6 @@ impl FromStr for RegistryType { #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct RevocationRegistryDefinitionValue { - pub issuance_type: IssuanceType, pub max_cred_num: u32, pub public_keys: RevocationRegistryDefinitionValuePublicKeys, pub tails_hash: String, diff --git a/anoncreds/src/ffi/revocation.rs b/anoncreds/src/ffi/revocation.rs index 32664eed..cfc2893f 100644 --- a/anoncreds/src/ffi/revocation.rs +++ b/anoncreds/src/ffi/revocation.rs @@ -16,7 +16,7 @@ use crate::services::{ prover::create_or_update_revocation_state, tails::{TailsFileReader, TailsFileWriter}, types::{ - CredentialRevocationState, IssuanceType, RegistryType, RevocationRegistry, + CredentialRevocationState, RegistryType, RevocationRegistry, RevocationRegistryDefinition, RevocationRegistryDefinitionPrivate, RevocationRegistryDelta, RevocationStatusList, }, @@ -28,7 +28,6 @@ pub extern "C" fn anoncreds_create_revocation_registry( cred_def_id: FfiStr, tag: FfiStr, rev_reg_type: FfiStr, - issuance_type: FfiStr, max_cred_num: i64, tails_dir_path: FfiStr, reg_def_p: *mut ObjectHandle, @@ -51,17 +50,12 @@ pub extern "C" fn anoncreds_create_revocation_registry( .ok_or_else(|| err_msg!("Missing registry type"))?; RegistryType::from_str(rtype).map_err(err_map!(Input))? }; - let issuance_type = match issuance_type.as_opt_str() { - Some(s) => IssuanceType::from_str(s).map_err(err_map!(Input))?, - None => IssuanceType::default(), - }; let mut tails_writer = TailsFileWriter::new(tails_dir_path.into_opt_string()); let (reg_def, reg_def_private, reg_entry, reg_init_delta) = create_revocation_registry( cred_def.load()?.cast_ref()?, cred_def_id, tag, rev_reg_type, - issuance_type, max_cred_num .try_into() .map_err(|_| err_msg!("Invalid maximum credential count"))?, diff --git a/anoncreds/src/services/issuer.rs b/anoncreds/src/services/issuer.rs index 2b38416c..bb6ab9d7 100644 --- a/anoncreds/src/services/issuer.rs +++ b/anoncreds/src/services/issuer.rs @@ -117,7 +117,6 @@ pub fn create_revocation_registry( cred_def_id: impl TryInto, tag: &str, rev_reg_type: RegistryType, - issuance_type: IssuanceType, max_cred_num: u32, tails_writer: &mut TW, ) -> Result<( @@ -129,8 +128,8 @@ pub fn create_revocation_registry( where TW: TailsWriter, { - trace!("create_revocation_registry >>> cred_def: {:?}, tag: {:?}, max_cred_num: {:?}, rev_reg_type: {:?}, issuance_type: {:?}", - cred_def, tag, max_cred_num, rev_reg_type, issuance_type); + trace!("create_revocation_registry >>> cred_def: {:?}, tag: {:?}, max_cred_num: {:?}, rev_reg_type: {:?}", + cred_def, tag, max_cred_num, rev_reg_type); let cred_def_id = cred_def_id.try_into()?; let credential_pub_key = cred_def.get_public_key().map_err(err_map!( @@ -151,7 +150,6 @@ where let revoc_reg_def_value = RevocationRegistryDefinitionValue { max_cred_num, - issuance_type, public_keys: rev_keys_pub, tails_location: tails_location.clone(), tails_hash, @@ -169,7 +167,7 @@ where }; // now update registry to reflect issuance-by-default - let (revoc_reg, revoc_init_delta) = if issuance_type == IssuanceType::ISSUANCE_BY_DEFAULT { + let (revoc_reg, revoc_init_delta) = { let tails_reader = TailsFileReader::new_tails_reader(&tails_location); let issued = BTreeSet::from_iter(1..=max_cred_num); update_revocation_registry( @@ -179,9 +177,6 @@ where BTreeSet::new(), &tails_reader, )? - } else { - let delta = revoc_reg.initial_delta(); - (revoc_reg, delta) }; let revoc_def_priv = RevocationRegistryDefinitionPrivate { @@ -289,7 +284,8 @@ pub fn create_credential( &cred_def_private.value, revocation.registry_idx, rev_reg_def.max_cred_num, - rev_reg_def.issuance_type.to_bool(), + // issuance by default + true, &mut rev_reg, &revocation.reg_def_private.value, &revocation.tails_reader, @@ -297,14 +293,7 @@ pub fn create_credential( let witness = { let empty = HashSet::new(); - let (by_default, issued, revoked) = match rev_reg_def.issuance_type { - IssuanceType::ISSUANCE_ON_DEMAND => { - (false, revocation.registry_used, &empty) - } - IssuanceType::ISSUANCE_BY_DEFAULT => { - (true, &empty, revocation.registry_used) - } - }; + let (by_default, issued, revoked) = (true, &empty, revocation.registry_used); let rev_reg_delta = CryptoRevocationRegistryDelta::from_parts(None, &rev_reg, issued, revoked); diff --git a/anoncreds/src/services/prover.rs b/anoncreds/src/services/prover.rs index babe3148..9fcbb460 100644 --- a/anoncreds/src/services/prover.rs +++ b/anoncreds/src/services/prover.rs @@ -293,7 +293,8 @@ pub fn create_or_update_revocation_state( } else { let list_size = usize::try_from(revoc_reg_def.value.max_cred_num) .map_err(|e| Error::from_msg(crate::ErrorKind::InvalidState, e.to_string()))?; - let bit: usize = revoc_reg_def.value.issuance_type.into(); + // Issuance by default + let bit: usize = 0; let list = bitvec![bit; list_size]; _create_index_deltas( rev_reg_list.state_owned().bitxor(list), @@ -306,7 +307,8 @@ pub fn create_or_update_revocation_state( Witness::new( rev_reg_idx, revoc_reg_def.value.max_cred_num, - revoc_reg_def.value.issuance_type.to_bool(), + // issuance by default + true, &rev_reg_delta, &tails_reader, )? diff --git a/anoncreds/src/services/types.rs b/anoncreds/src/services/types.rs index 3f4e1036..108f7bd9 100644 --- a/anoncreds/src/services/types.rs +++ b/anoncreds/src/services/types.rs @@ -11,7 +11,7 @@ pub use crate::data_types::anoncreds::{ presentation::Presentation, rev_reg::{RevocationRegistry, RevocationRegistryDelta, RevocationStatusList}, rev_reg_def::{ - IssuanceType, RegistryType, RevocationRegistryDefinition, + RegistryType, RevocationRegistryDefinition, RevocationRegistryDefinitionPrivate, }, schema::AttributeNames, diff --git a/anoncreds/tests/anoncreds_demos.rs b/anoncreds/tests/anoncreds_demos.rs index 17c33d4f..7a094418 100644 --- a/anoncreds/tests/anoncreds_demos.rs +++ b/anoncreds/tests/anoncreds_demos.rs @@ -15,7 +15,7 @@ use anoncreds::{ tails::{TailsFileReader, TailsFileWriter}, types::{ CredentialDefinitionConfig, CredentialRevocationConfig, CredentialRevocationState, - IssuanceType, MakeCredentialValues, PresentCredentials, PresentationRequest, RegistryType, + MakeCredentialValues, PresentCredentials, PresentationRequest, RegistryType, RevocationStatusList, SignatureType, }, verifier, @@ -286,7 +286,6 @@ fn anoncreds_with_revocation_works_for_single_issuer_single_prover() { CRED_DEF_ID, "some_tag", RegistryType::CL_ACCUM, - IssuanceType::ISSUANCE_BY_DEFAULT, MAX_CRED_NUM, &mut tf, )