Skip to content

Commit

Permalink
Rename tails variables in prover code (#901)
Browse files Browse the repository at this point in the history
* Rename tails variables in prover code

Signed-off-by: Patrik Stas <[email protected]>
  • Loading branch information
Patrik-Stas authored Jul 20, 2023
1 parent e1414a8 commit def6295
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion agents/node/vcxagent-core/src/utils/proofs.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports.holderSelectCredentialsForProof = async function holderSelectCred
}
const revRegId = resolvedCreds.attrs[attrName][0].cred_info.rev_reg_id
if (revRegId && mapRevRegIdToTailsFilePath) {
selectedCreds.attrs[attrName].tails_file = await mapRevRegIdToTailsFilePath(revRegId)
selectedCreds.attrs[attrName].tails_dir = await mapRevRegIdToTailsFilePath(revRegId)
}
} else {
logger.info(`No credential was resolved for requested attribute key ${attrName}, will have to be supplied via self-attested attributes.`)
Expand Down
36 changes: 18 additions & 18 deletions aries_vcx/src/common/proofs/prover/prover_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct CredInfoProver {
pub rev_reg_id: Option<String>,
pub cred_rev_id: Option<String>,
pub revocation_interval: Option<NonRevokedInterval>,
pub tails_file: Option<String>,
pub tails_dir: Option<String>,
pub timestamp: Option<u64>,
pub revealed: Option<bool>,
}
Expand Down Expand Up @@ -107,7 +107,7 @@ pub fn credential_def_identifiers(
timestamp: None,
rev_reg_id: cred_info.rev_reg_id.clone(),
cred_rev_id: cred_info.cred_rev_id.clone(),
tails_file: selected_cred.tails_dir.clone(),
tails_dir: selected_cred.tails_dir.clone(),
revealed: cred_info.revealed,
});
}
Expand Down Expand Up @@ -142,8 +142,8 @@ pub async fn build_rev_states_json(
let mut timestamps: HashMap<String, u64> = HashMap::new();

for cred_info in credentials_identifiers.iter_mut() {
if let (Some(rev_reg_id), Some(cred_rev_id), Some(tails_file)) =
(&cred_info.rev_reg_id, &cred_info.cred_rev_id, &cred_info.tails_file)
if let (Some(rev_reg_id), Some(cred_rev_id), Some(tails_dir)) =
(&cred_info.rev_reg_id, &cred_info.cred_rev_id, &cred_info.tails_dir)
{
if rtn.get(rev_reg_id).is_none() {
// Does this make sense in case cred_info's for same rev_reg_ids have different revocation intervals
Expand All @@ -160,7 +160,7 @@ pub async fn build_rev_states_json(

let rev_state_json = anoncreds
.create_revocation_state(
tails_file,
tails_dir,
&rev_reg_def_json,
&rev_reg_delta_json,
timestamp,
Expand Down Expand Up @@ -274,7 +274,7 @@ pub mod pool_tests {
cred_def_id: CRED_DEF_ID.to_string(),
rev_reg_id: None,
cred_rev_id: Some(CRED_REV_ID.to_string()),
tails_file: Some(get_temp_dir_path().to_str().unwrap().to_string()),
tails_dir: Some(get_temp_dir_path().to_str().unwrap().to_string()),
revocation_interval: None,
timestamp: None,
revealed: None,
Expand Down Expand Up @@ -340,7 +340,7 @@ pub mod unit_tests {
rev_reg_id: Some(REV_REG_ID.to_string()),
cred_rev_id: Some(CRED_REV_ID.to_string()),
revocation_interval: None,
tails_file: None,
tails_dir: None,
timestamp: None,
revealed: None,
};
Expand All @@ -352,7 +352,7 @@ pub mod unit_tests {
rev_reg_id: Some(ADDRESS_REV_REG_ID.to_string()),
cred_rev_id: Some(ADDRESS_CRED_REV_ID.to_string()),
revocation_interval: None,
tails_file: None,
tails_dir: None,
timestamp: None,
revealed: None,
};
Expand Down Expand Up @@ -382,7 +382,7 @@ pub mod unit_tests {
rev_reg_id: Some(REV_REG_ID.to_string()),
cred_rev_id: Some(CRED_REV_ID.to_string()),
revocation_interval: None,
tails_file: None,
tails_dir: None,
timestamp: None,
revealed: None,
};
Expand All @@ -394,7 +394,7 @@ pub mod unit_tests {
rev_reg_id: Some(ADDRESS_REV_REG_ID.to_string()),
cred_rev_id: Some(ADDRESS_CRED_REV_ID.to_string()),
revocation_interval: None,
tails_file: None,
tails_dir: None,
timestamp: None,
revealed: None,
};
Expand All @@ -421,7 +421,7 @@ pub mod unit_tests {
from: Some(123),
to: Some(456),
}),
tails_file: Some(get_temp_dir_path().to_str().unwrap().to_string()),
tails_dir: Some(get_temp_dir_path().to_str().unwrap().to_string()),
timestamp: None,
revealed: None,
};
Expand All @@ -436,7 +436,7 @@ pub mod unit_tests {
from: None,
to: Some(987),
}),
tails_file: None,
tails_dir: None,
timestamp: None,
revealed: None,
};
Expand All @@ -459,7 +459,7 @@ pub mod unit_tests {
},
"interval":null
},
"tails_file": get_temp_dir_path().to_str().unwrap().to_string(),
"tails_dir": get_temp_dir_path().to_str().unwrap().to_string(),
},
"zip_2":{
"credential": {
Expand Down Expand Up @@ -542,7 +542,7 @@ pub mod unit_tests {
},
"interval":null
},
"tails_file": get_temp_dir_path().to_str().unwrap().to_string(),
"tails_dir": get_temp_dir_path().to_str().unwrap().to_string(),
},
}
});
Expand All @@ -554,7 +554,7 @@ pub mod unit_tests {
rev_reg_id: None,
cred_rev_id: Some(CRED_REV_ID.to_string()),
revocation_interval: None,
tails_file: Some(get_temp_dir_path().to_str().unwrap().to_string()),
tails_dir: Some(get_temp_dir_path().to_str().unwrap().to_string()),
timestamp: None,
revealed: None,
}];
Expand Down Expand Up @@ -591,7 +591,7 @@ pub mod unit_tests {
rev_reg_id: Some(REV_REG_ID.to_string()),
cred_rev_id: Some(CRED_REV_ID.to_string()),
revocation_interval: None,
tails_file: None,
tails_dir: None,
timestamp: Some(800),
revealed: None,
};
Expand All @@ -603,7 +603,7 @@ pub mod unit_tests {
rev_reg_id: Some(ADDRESS_REV_REG_ID.to_string()),
cred_rev_id: Some(ADDRESS_CRED_REV_ID.to_string()),
revocation_interval: None,
tails_file: None,
tails_dir: None,
timestamp: Some(800),
revealed: Some(false),
};
Expand Down Expand Up @@ -658,7 +658,7 @@ pub mod unit_tests {
cred_def_id: CRED_DEF_ID.to_string(),
rev_reg_id: Some(REV_REG_ID.to_string()),
cred_rev_id: Some(CRED_REV_ID.to_string()),
tails_file: Some(get_temp_dir_path().to_str().unwrap().to_string()),
tails_dir: Some(get_temp_dir_path().to_str().unwrap().to_string()),
revocation_interval: None,
timestamp: None,
revealed: None,
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/handlers/proof_presentation/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ pub struct SelectedCredentialForReferent {
/// file for the credential's revocation registry. Note that the files within this
/// dir should be pre-downloaded and named by the tailsFileHash (base58), as
/// specified in the revocation registry definition for the credential.
#[serde(rename = "tails_file")] // our APIs expect a directory, but the legacy API calls it tails_file
pub tails_dir: Option<String>,
}

Expand Down
3 changes: 1 addition & 2 deletions aries_vcx/tests/utils/scenarios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,14 @@ pub mod test_utils {
credential_json: &str,
comment: Option<&str>,
) -> Issuer {
info!("create_and_send_cred_offer >> creating issuer credential");
let offer_info = OfferInfo {
credential_json: credential_json.to_string(),
cred_def_id: cred_def.get_cred_def_id(),
rev_reg_id: Some(rev_reg.get_rev_reg_id()),
tails_file: Some(rev_reg.get_tails_dir()),
};
info!("create_and_send_cred_offer :: sending credential offer, offer_info: {offer_info:?}");
let mut issuer = Issuer::create("1").unwrap();
info!("create_and_send_cred_offer :: sending credential offer");
issuer
.build_credential_offer_msg(&faber.profile.inject_anoncreds(), offer_info, comment.map(String::from))
.await
Expand Down

0 comments on commit def6295

Please sign in to comment.