diff --git a/include/README.md b/include/README.md index b1298a93..2c8b280c 100644 --- a/include/README.md +++ b/include/README.md @@ -11,3 +11,9 @@ Generate the header file: ```sh cbindgen --config include/cbindgen.toml --crate anoncreds --output include/libanoncreds.h ``` + +Copy to React Native: + +```sh +cp include/libanoncreds.h wrappers/javascript/anoncreds-react-native/cpp/include/ +``` diff --git a/include/libanoncreds.h b/include/libanoncreds.h index 6fb2bca2..0a9931b6 100644 --- a/include/libanoncreds.h +++ b/include/libanoncreds.h @@ -285,13 +285,13 @@ ErrorCode anoncreds_create_credential_offer(FfiStr schema_id, ErrorCode anoncreds_create_credential_request(FfiStr entropy, FfiStr prover_did, ObjectHandle cred_def, - ObjectHandle master_secret, - FfiStr master_secret_id, + ObjectHandle link_secret, + FfiStr link_secret_id, ObjectHandle cred_offer, ObjectHandle *cred_req_p, ObjectHandle *cred_req_meta_p); -ErrorCode anoncreds_create_master_secret(ObjectHandle *master_secret_p); +ErrorCode anoncreds_create_link_secret(ObjectHandle *link_secret_p); ErrorCode anoncreds_create_or_update_revocation_state(ObjectHandle rev_reg_def, ObjectHandle rev_status_list, @@ -306,7 +306,7 @@ ErrorCode anoncreds_create_presentation(ObjectHandle pres_req, struct FfiList_FfiCredentialProve credentials_prove, FfiStrList self_attest_names, FfiStrList self_attest_values, - ObjectHandle master_secret, + ObjectHandle link_secret, struct FfiList_ObjectHandle schemas, FfiStrList schema_ids, struct FfiList_ObjectHandle cred_defs, @@ -354,7 +354,7 @@ ErrorCode anoncreds_object_get_type_name(ObjectHandle handle, const char **resul ErrorCode anoncreds_process_credential(ObjectHandle cred, ObjectHandle cred_req_metadata, - ObjectHandle master_secret, + ObjectHandle link_secret, ObjectHandle cred_def, ObjectHandle rev_reg_def, ObjectHandle *cred_p); diff --git a/src/data_types/cred_request.rs b/src/data_types/cred_request.rs index 5a68d793..35bf2b10 100644 --- a/src/data_types/cred_request.rs +++ b/src/data_types/cred_request.rs @@ -11,8 +11,10 @@ pub struct CredentialRequest { #[serde(skip_serializing_if = "Option::is_none")] prover_did: Option, cred_def_id: CredentialDefinitionId, - pub blinded_ms: ursa::cl::BlindedCredentialSecrets, - pub blinded_ms_correctness_proof: ursa::cl::BlindedCredentialSecretsCorrectnessProof, + #[serde(rename = "blinded_ms")] + pub blinded_ls: ursa::cl::BlindedCredentialSecrets, + #[serde(rename = "blinded_ms_correctness_proof")] + pub blinded_ls_correctness_proof: ursa::cl::BlindedCredentialSecretsCorrectnessProof, pub nonce: Nonce, } @@ -55,16 +57,16 @@ impl CredentialRequest { entropy: Option<&str>, prover_did: Option<&str>, cred_def_id: CredentialDefinitionId, - blinded_ms: ursa::cl::BlindedCredentialSecrets, - blinded_ms_correctness_proof: ursa::cl::BlindedCredentialSecretsCorrectnessProof, + blinded_ls: ursa::cl::BlindedCredentialSecrets, + blinded_ls_correctness_proof: ursa::cl::BlindedCredentialSecretsCorrectnessProof, nonce: Nonce, ) -> Result { let s = Self { entropy: entropy.map(|e| e.to_owned()), prover_did: prover_did.map(|p| p.to_owned()), cred_def_id, - blinded_ms, - blinded_ms_correctness_proof, + blinded_ls, + blinded_ls_correctness_proof, nonce, }; s.validate()?; @@ -82,9 +84,9 @@ impl CredentialRequest { #[derive(Debug, Deserialize, Serialize)] pub struct CredentialRequestMetadata { - pub master_secret_blinding_data: ursa::cl::CredentialSecretsBlindingFactors, + pub link_secret_blinding_data: ursa::cl::CredentialSecretsBlindingFactors, pub nonce: Nonce, - pub master_secret_name: String, + pub link_secret_name: String, } impl Validatable for CredentialRequestMetadata {} @@ -95,7 +97,7 @@ mod cred_req_tests { data_types::{ cred_def::{CredentialDefinition, CredentialKeyCorrectnessProof, SignatureType}, cred_offer::CredentialOffer, - master_secret::MasterSecret, + link_secret::LinkSecret, schema::AttributeNames, }, issuer::{create_credential_definition, create_credential_offer, create_schema}, @@ -112,7 +114,7 @@ mod cred_req_tests { const ENTROPY: Option<&str> = Some("entropy"); const PROVER_DID: Option<&str> = Some(LEGACY_DID_IDENTIFIER); - const MASTER_SERCET_ID: &str = "master:secret:id"; + const LINK_SERCET_ID: &str = "link:secret:id"; fn cred_def() -> Result<(CredentialDefinition, CredentialKeyCorrectnessProof)> { let credential_definition_issuer_id = "sample:id"; @@ -133,8 +135,8 @@ mod cred_req_tests { Ok((cred_def.0, cred_def.2)) } - fn master_secret() -> MasterSecret { - MasterSecret::new().unwrap() + fn link_secret() -> LinkSecret { + LinkSecret::new().unwrap() } fn credential_offer( @@ -155,15 +157,15 @@ mod cred_req_tests { #[test] fn create_credential_request_with_valid_input() -> Result<()> { let (cred_def, correctness_proof) = cred_def()?; - let master_secret = master_secret(); + let link_secret = link_secret(); let credential_offer = credential_offer(correctness_proof, false)?; let res = create_credential_request( ENTROPY, None, &cred_def, - &master_secret, - MASTER_SERCET_ID, + &link_secret, + LINK_SERCET_ID, &credential_offer, ); @@ -175,15 +177,15 @@ mod cred_req_tests { #[test] fn create_credential_request_with_valid_input_legacy() -> Result<()> { let (cred_def, correctness_proof) = cred_def()?; - let master_secret = master_secret(); + let link_secret = link_secret(); let credential_offer = credential_offer(correctness_proof, true)?; let res = create_credential_request( None, PROVER_DID, &cred_def, - &master_secret, - MASTER_SERCET_ID, + &link_secret, + LINK_SERCET_ID, &credential_offer, ); @@ -195,15 +197,15 @@ mod cred_req_tests { #[test] fn create_credential_request_with_invalid_new_identifiers_and_prover_did() -> Result<()> { let (cred_def, correctness_proof) = cred_def()?; - let master_secret = master_secret(); + let link_secret = link_secret(); let credential_offer = credential_offer(correctness_proof, false)?; let res = create_credential_request( None, PROVER_DID, &cred_def, - &master_secret, - MASTER_SERCET_ID, + &link_secret, + LINK_SERCET_ID, &credential_offer, ); @@ -215,15 +217,15 @@ mod cred_req_tests { #[test] fn create_credential_request_with_invalid_prover_did_and_entropy() -> Result<()> { let (cred_def, correctness_proof) = cred_def()?; - let master_secret = master_secret(); + let link_secret = link_secret(); let credential_offer = credential_offer(correctness_proof, true)?; let res = create_credential_request( ENTROPY, PROVER_DID, &cred_def, - &master_secret, - MASTER_SERCET_ID, + &link_secret, + LINK_SERCET_ID, &credential_offer, ); @@ -235,15 +237,15 @@ mod cred_req_tests { #[test] fn create_credential_request_with_invalid_prover_did() -> Result<()> { let (cred_def, correctness_proof) = cred_def()?; - let master_secret = master_secret(); + let link_secret = link_secret(); let credential_offer = credential_offer(correctness_proof, true)?; let res = create_credential_request( None, ENTROPY, &cred_def, - &master_secret, - MASTER_SERCET_ID, + &link_secret, + LINK_SERCET_ID, &credential_offer, ); @@ -255,15 +257,15 @@ mod cred_req_tests { #[test] fn create_credential_request_with_no_entropy_or_prover_did() -> Result<()> { let (cred_def, correctness_proof) = cred_def()?; - let master_secret = master_secret(); + let link_secret = link_secret(); let credential_offer = credential_offer(correctness_proof, true)?; let res = create_credential_request( None, None, &cred_def, - &master_secret, - MASTER_SERCET_ID, + &link_secret, + LINK_SERCET_ID, &credential_offer, ); @@ -275,15 +277,15 @@ mod cred_req_tests { #[test] fn create_credential_request_json_contains_entropy() -> Result<()> { let (cred_def, correctness_proof) = cred_def()?; - let master_secret = master_secret(); + let link_secret = link_secret(); let credential_offer = credential_offer(correctness_proof, false)?; let res = create_credential_request( ENTROPY, None, &cred_def, - &master_secret, - MASTER_SERCET_ID, + &link_secret, + LINK_SERCET_ID, &credential_offer, ) .unwrap(); @@ -298,15 +300,15 @@ mod cred_req_tests { #[test] fn create_credential_request_json_contains_prover_did_with_legacy_identifiers() -> Result<()> { let (cred_def, correctness_proof) = cred_def()?; - let master_secret = master_secret(); + let link_secret = link_secret(); let credential_offer = credential_offer(correctness_proof, true)?; let res = create_credential_request( None, PROVER_DID, &cred_def, - &master_secret, - MASTER_SERCET_ID, + &link_secret, + LINK_SERCET_ID, &credential_offer, ) .unwrap(); @@ -321,15 +323,15 @@ mod cred_req_tests { #[test] fn create_credential_request_json_contains_entropy_with_legacy_identifiers() -> Result<()> { let (cred_def, correctness_proof) = cred_def()?; - let master_secret = master_secret(); + let link_secret = link_secret(); let credential_offer = credential_offer(correctness_proof, false)?; let res = create_credential_request( ENTROPY, None, &cred_def, - &master_secret, - MASTER_SERCET_ID, + &link_secret, + LINK_SERCET_ID, &credential_offer, ) .unwrap(); diff --git a/src/data_types/link_secret.rs b/src/data_types/link_secret.rs new file mode 100644 index 00000000..dc84f669 --- /dev/null +++ b/src/data_types/link_secret.rs @@ -0,0 +1,56 @@ +use std::fmt; + +use crate::error::ConversionError; +use serde::{Deserialize, Serialize}; +use ursa::cl::{prover::Prover as UrsaProver, MasterSecret}; + +#[derive(Serialize, Deserialize)] +pub struct LinkSecret { + pub value: MasterSecret, +} + +impl LinkSecret { + #[inline] + pub fn new() -> Result { + let value = UrsaProver::new_master_secret().map_err(|err| { + ConversionError::from_msg(format!("Error creating link secret: {err}")) + })?; + Ok(Self { value }) + } + + pub fn try_clone(&self) -> Result { + Ok(Self { + value: self.value.try_clone().map_err(|e| e.to_string())?, + }) + } +} + +impl fmt::Debug for LinkSecret { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_tuple("LinkSecret") + .field(if cfg!(test) { &self.value } else { &"" }) + .finish() + } +} + + +#[cfg(test)] +mod link_secret_tests { + use super::*; + + #[test] + fn should_create_new_link_secret() { + let link_secret = LinkSecret::new(); + assert!(link_secret.is_ok()) + } + + #[test] + fn should_clone_link_secret() { + let link_secret = LinkSecret::new().expect("Unable to create link secret"); + let link_secret_value = link_secret.value.value().expect("Unable to extract value from link secret"); + let cloned_link_secret = link_secret.try_clone().expect("Unable to clone link secret"); + let cloned_link_secret_value = cloned_link_secret.value.value().expect("Unable to extract value from cloned link secret"); + + assert_eq!(link_secret_value, cloned_link_secret_value); + } +} \ No newline at end of file diff --git a/src/data_types/master_secret.rs b/src/data_types/master_secret.rs deleted file mode 100644 index 96790f05..00000000 --- a/src/data_types/master_secret.rs +++ /dev/null @@ -1,34 +0,0 @@ -use std::fmt; - -use crate::error::ConversionError; -use serde::{Deserialize, Serialize}; -use ursa::cl::{prover::Prover as UrsaProver, MasterSecret as UrsaMasterSecret}; - -#[derive(Serialize, Deserialize)] -pub struct MasterSecret { - pub value: UrsaMasterSecret, -} - -impl MasterSecret { - #[inline] - pub fn new() -> Result { - let value = UrsaProver::new_master_secret().map_err(|err| { - ConversionError::from_msg(format!("Error creating master secret: {err}")) - })?; - Ok(Self { value }) - } - - pub fn try_clone(&self) -> Result { - Ok(Self { - value: self.value.try_clone().map_err(|e| e.to_string())?, - }) - } -} - -impl fmt::Debug for MasterSecret { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_tuple("MasterSecret") - .field(if cfg!(test) { &self.value } else { &"" }) - .finish() - } -} diff --git a/src/data_types/mod.rs b/src/data_types/mod.rs index 2a2ebe3a..4ccb3f98 100644 --- a/src/data_types/mod.rs +++ b/src/data_types/mod.rs @@ -10,8 +10,8 @@ pub mod cred_request; /// Credentials pub mod credential; -/// Identity master secret -pub mod master_secret; +/// Identity link secret +pub mod link_secret; /// Nonce used in presentation requests pub mod nonce; diff --git a/src/ffi/cred_req.rs b/src/ffi/cred_req.rs index ccccccd3..1e47733e 100644 --- a/src/ffi/cred_req.rs +++ b/src/ffi/cred_req.rs @@ -13,8 +13,8 @@ pub extern "C" fn anoncreds_create_credential_request( entropy: FfiStr, prover_did: FfiStr, cred_def: ObjectHandle, - master_secret: ObjectHandle, - master_secret_id: FfiStr, + link_secret: ObjectHandle, + link_secret_id: FfiStr, cred_offer: ObjectHandle, cred_req_p: *mut ObjectHandle, cred_req_meta_p: *mut ObjectHandle, @@ -22,9 +22,9 @@ pub extern "C" fn anoncreds_create_credential_request( catch_error(|| { check_useful_c_ptr!(cred_req_p); check_useful_c_ptr!(cred_req_meta_p); - let master_secret_id = master_secret_id + let link_secret_id = link_secret_id .as_opt_str() - .ok_or_else(|| err_msg!("Missing master secret ID"))?; + .ok_or_else(|| err_msg!("Missing link secret ID"))?; let entropy = entropy.as_opt_str(); let prover_did = prover_did.as_opt_str(); @@ -35,8 +35,8 @@ pub extern "C" fn anoncreds_create_credential_request( entropy, prover_did, cred_def, - master_secret.load()?.cast_ref()?, - master_secret_id, + link_secret.load()?.cast_ref()?, + link_secret_id, cred_offer.load()?.cast_ref()?, )?; diff --git a/src/ffi/credential.rs b/src/ffi/credential.rs index 4251de58..d6d7d29b 100644 --- a/src/ffi/credential.rs +++ b/src/ffi/credential.rs @@ -170,7 +170,7 @@ pub extern "C" fn anoncreds_encode_credential_attributes( pub extern "C" fn anoncreds_process_credential( cred: ObjectHandle, cred_req_metadata: ObjectHandle, - master_secret: ObjectHandle, + link_secret: ObjectHandle, cred_def: ObjectHandle, rev_reg_def: ObjectHandle, cred_p: *mut ObjectHandle, @@ -185,7 +185,7 @@ pub extern "C" fn anoncreds_process_credential( process_credential( &mut cred, cred_req_metadata.load()?.cast_ref()?, - master_secret.load()?.cast_ref()?, + link_secret.load()?.cast_ref()?, cred_def.load()?.cast_ref()?, rev_reg_def .opt_load()? diff --git a/src/ffi/link_secret.rs b/src/ffi/link_secret.rs new file mode 100644 index 00000000..0616f25f --- /dev/null +++ b/src/ffi/link_secret.rs @@ -0,0 +1,16 @@ +use super::error::{catch_error, ErrorCode}; +use super::object::ObjectHandle; +use crate::services::{prover::create_link_secret, types::LinkSecret}; + +#[no_mangle] +pub extern "C" fn anoncreds_create_link_secret(link_secret_p: *mut ObjectHandle) -> ErrorCode { + catch_error(|| { + check_useful_c_ptr!(link_secret_p); + let secret = ObjectHandle::create(create_link_secret()?)?; + unsafe { *link_secret_p = secret }; + Ok(()) + }) +} + +impl_anoncreds_object!(LinkSecret, "LinkSecret"); +impl_anoncreds_object_from_json!(LinkSecret, anoncreds_link_secret_from_json); diff --git a/src/ffi/master_secret.rs b/src/ffi/master_secret.rs deleted file mode 100644 index 497bbbad..00000000 --- a/src/ffi/master_secret.rs +++ /dev/null @@ -1,16 +0,0 @@ -use super::error::{catch_error, ErrorCode}; -use super::object::ObjectHandle; -use crate::services::{prover::create_master_secret, types::MasterSecret}; - -#[no_mangle] -pub extern "C" fn anoncreds_create_master_secret(master_secret_p: *mut ObjectHandle) -> ErrorCode { - catch_error(|| { - check_useful_c_ptr!(master_secret_p); - let secret = ObjectHandle::create(create_master_secret()?)?; - unsafe { *master_secret_p = secret }; - Ok(()) - }) -} - -impl_anoncreds_object!(MasterSecret, "MasterSecret"); -impl_anoncreds_object_from_json!(MasterSecret, anoncreds_master_secret_from_json); diff --git a/src/ffi/mod.rs b/src/ffi/mod.rs index 23cba669..6fa9ea38 100644 --- a/src/ffi/mod.rs +++ b/src/ffi/mod.rs @@ -29,7 +29,7 @@ mod cred_def; mod cred_offer; mod cred_req; mod credential; -mod master_secret; +mod link_secret; mod pres_req; mod presentation; mod revocation; diff --git a/src/ffi/presentation.rs b/src/ffi/presentation.rs index 0116d17f..110241bf 100644 --- a/src/ffi/presentation.rs +++ b/src/ffi/presentation.rs @@ -67,7 +67,7 @@ pub extern "C" fn anoncreds_create_presentation( credentials_prove: FfiList, self_attest_names: FfiStrList, self_attest_values: FfiStrList, - master_secret: ObjectHandle, + link_secret: ObjectHandle, schemas: FfiList, schema_ids: FfiStrList, cred_defs: FfiList, @@ -184,7 +184,7 @@ pub extern "C" fn anoncreds_create_presentation( pres_req.load()?.cast_ref()?, present_creds, self_attested, - master_secret.load()?.cast_ref()?, + link_secret.load()?.cast_ref()?, &schemas, &cred_defs, )?; diff --git a/src/services/helpers.rs b/src/services/helpers.rs index 897a7904..fd51cd0f 100644 --- a/src/services/helpers.rs +++ b/src/services/helpers.rs @@ -40,7 +40,7 @@ pub fn build_non_credential_schema() -> Result { trace!("build_non_credential_schema"); let mut non_credential_schema_builder = issuer::Issuer::new_non_credential_schema_builder()?; - non_credential_schema_builder.add_attr("master_secret")?; + non_credential_schema_builder.add_attr("link_secret")?; let res = non_credential_schema_builder.finalize()?; trace!("build_non_credential_schema <<< res: {:?}", res); @@ -49,7 +49,7 @@ pub fn build_non_credential_schema() -> Result { pub fn build_credential_values( credential_values: &HashMap, - master_secret: Option<&CryptoMasterSecret>, + link_secret: Option<&CryptoMasterSecret>, ) -> Result { trace!( "build_credential_values >>> credential_values: {:?}", @@ -60,8 +60,8 @@ pub fn build_credential_values( for (attr, values) in credential_values { credential_values_builder.add_dec_known(&attr_common_view(attr), &values.encoded)?; } - if let Some(ms) = master_secret { - credential_values_builder.add_value_hidden("master_secret", &ms.value()?)?; + if let Some(ms) = link_secret { + credential_values_builder.add_value_hidden("link_secret", &ms.value()?)?; } let res = credential_values_builder.finalize()?; diff --git a/src/services/issuer.rs b/src/services/issuer.rs index f3f95d2c..673dab8d 100644 --- a/src/services/issuer.rs +++ b/src/services/issuer.rs @@ -376,8 +376,8 @@ pub fn create_credential( let (credential_signature, signature_correctness_proof, delta) = CryptoIssuer::sign_credential_with_revoc( &cred_request.entropy()?, - &cred_request.blinded_ms, - &cred_request.blinded_ms_correctness_proof, + &cred_request.blinded_ls, + &cred_request.blinded_ls_correctness_proof, cred_offer.nonce.as_native(), cred_request.nonce.as_native(), &credential_values, @@ -420,8 +420,8 @@ pub fn create_credential( _ => { let (signature, correctness_proof) = CryptoIssuer::sign_credential( &cred_request.entropy()?, - &cred_request.blinded_ms, - &cred_request.blinded_ms_correctness_proof, + &cred_request.blinded_ls, + &cred_request.blinded_ls_correctness_proof, cred_offer.nonce.as_native(), cred_request.nonce.as_native(), &credential_values, diff --git a/src/services/prover.rs b/src/services/prover.rs index 069c1695..44340504 100644 --- a/src/services/prover.rs +++ b/src/services/prover.rs @@ -29,24 +29,24 @@ use crate::utils::validation::Validatable; use super::tails::TailsFileReader; -pub fn create_master_secret() -> Result { - MasterSecret::new().map_err(err_map!(Unexpected)) +pub fn create_link_secret() -> Result { + LinkSecret::new().map_err(err_map!(Unexpected)) } pub fn create_credential_request( entropy: Option<&str>, prover_did: Option<&str>, cred_def: &CredentialDefinition, - master_secret: &MasterSecret, - master_secret_id: &str, + link_secret: &LinkSecret, + link_secret_id: &str, credential_offer: &CredentialOffer, ) -> Result<(CredentialRequest, CredentialRequestMetadata)> { trace!( - "create_credential_request >>> entropy {:?}, prover_did {:?}, cred_def: {:?}, master_secret: {:?}, credential_offer: {:?}", + "create_credential_request >>> entropy {:?}, prover_did {:?}, cred_def: {:?}, link_secret: {:?}, credential_offer: {:?}", entropy, prover_did, cred_def, - secret!(&master_secret), + secret!(&link_secret), credential_offer ); @@ -56,13 +56,13 @@ pub fn create_credential_request( )?; let mut credential_values_builder = CryptoIssuer::new_credential_values_builder()?; - credential_values_builder.add_value_hidden("master_secret", &master_secret.value.value()?)?; + credential_values_builder.add_value_hidden("link_secret", &link_secret.value.value()?)?; let cred_values = credential_values_builder.finalize()?; let nonce = new_nonce()?; let nonce_copy = nonce.try_clone().map_err(err_map!(Unexpected))?; - let (blinded_ms, master_secret_blinding_data, blinded_ms_correctness_proof) = + let (blinded_ms, link_secret_blinding_data, blinded_ls_correctness_proof) = CryptoProver::blind_credential_secrets( &credential_pub_key, &credential_offer.key_correctness_proof, @@ -75,14 +75,14 @@ pub fn create_credential_request( prover_did, credential_offer.cred_def_id.to_owned(), blinded_ms, - blinded_ms_correctness_proof, + blinded_ls_correctness_proof, nonce, )?; let credential_request_metadata = CredentialRequestMetadata { - master_secret_blinding_data, + link_secret_blinding_data, nonce: nonce_copy, - master_secret_name: master_secret_id.to_string(), + link_secret_name: link_secret_id.to_string(), }; trace!( @@ -97,26 +97,26 @@ pub fn create_credential_request( pub fn process_credential( credential: &mut Credential, cred_request_metadata: &CredentialRequestMetadata, - master_secret: &MasterSecret, + link_secret: &LinkSecret, cred_def: &CredentialDefinition, rev_reg_def: Option<&RevocationRegistryDefinition>, ) -> Result<()> { - trace!("process_credential >>> credential: {:?}, cred_request_metadata: {:?}, master_secret: {:?}, cred_def: {:?}, rev_reg_def: {:?}", - credential, cred_request_metadata, secret!(&master_secret), cred_def, rev_reg_def); + trace!("process_credential >>> credential: {:?}, cred_request_metadata: {:?}, link_secret: {:?}, cred_def: {:?}, rev_reg_def: {:?}", + credential, cred_request_metadata, secret!(&link_secret), cred_def, rev_reg_def); let credential_pub_key = CredentialPublicKey::build_from_parts( &cred_def.value.primary, cred_def.value.revocation.as_ref(), )?; let credential_values = - build_credential_values(&credential.values.0, Some(&master_secret.value))?; + build_credential_values(&credential.values.0, Some(&link_secret.value))?; let rev_pub_key = rev_reg_def.map(|d| &d.value.public_keys.accum_key); CryptoProver::process_credential_signature( &mut credential.signature, &credential_values, &credential.signature_correctness_proof, - &cred_request_metadata.master_secret_blinding_data, + &cred_request_metadata.link_secret_blinding_data, &credential_pub_key, cred_request_metadata.nonce.as_native(), rev_pub_key, @@ -133,12 +133,12 @@ pub fn create_presentation( pres_req: &PresentationRequest, credentials: PresentCredentials, self_attested: Option>, - master_secret: &MasterSecret, + link_secret: &LinkSecret, schemas: &HashMap<&SchemaId, &Schema>, cred_defs: &HashMap<&CredentialDefinitionId, &CredentialDefinition>, ) -> Result { - trace!("create_proof >>> credentials: {:?}, pres_req: {:?}, credentials: {:?}, self_attested: {:?}, master_secret: {:?}, schemas: {:?}, cred_defs: {:?}", - credentials, pres_req, credentials, &self_attested, secret!(&master_secret), schemas, cred_defs); + trace!("create_proof >>> credentials: {:?}, pres_req: {:?}, credentials: {:?}, self_attested: {:?}, link_secret: {:?}, schemas: {:?}, cred_defs: {:?}", + credentials, pres_req, credentials, &self_attested, secret!(&link_secret), schemas, cred_defs); if credentials.is_empty() && self_attested @@ -155,7 +155,7 @@ pub fn create_presentation( let pres_req_val = pres_req.value(); let mut proof_builder = CryptoProver::new_proof_builder()?; - proof_builder.add_common_attribute("master_secret")?; + proof_builder.add_common_attribute("link_secret")?; let mut requested_proof = RequestedProof { self_attested_attrs: self_attested.unwrap_or_default(), @@ -191,7 +191,7 @@ pub fn create_presentation( let credential_schema = build_credential_schema(&schema.attr_names.0)?; let credential_values = - build_credential_values(&credential.values.0, Some(&master_secret.value))?; + build_credential_values(&credential.values.0, Some(&link_secret.value))?; let (req_attrs, req_predicates) = prepare_credential_for_proving( present.requested_attributes, present.requested_predicates, @@ -822,8 +822,8 @@ mod tests { const LEGACY_SCHEMA_IDENTIFIER: &str = "DXoTtQJNtXtiwWaZAK3rB1:2:example:1.0"; const LEGACY_CRED_DEF_IDENTIFIER: &str = "DXoTtQJNtXtiwWaZAK3rB1:3:CL:98153:default"; - fn _master_secret() -> MasterSecret { - MasterSecret::new().expect("Error creating prover master secret") + fn _link_secret() -> LinkSecret { + LinkSecret::new().expect("Error creating prover link secret") } fn _schema() -> Schema { @@ -890,13 +890,13 @@ mod tests { #[test] fn create_credential_request_with_new_identifiers_and_no_prover_did() { let (cred_def, key_correctness_proof) = _cred_def_and_key_correctness_proof(); - let master_secret = _master_secret(); + let link_secret = _link_secret(); let cred_offer = _cred_offer(key_correctness_proof); let resp = create_credential_request( Some("entropy"), None, &cred_def, - &master_secret, + &link_secret, "default", &cred_offer, ); @@ -906,13 +906,13 @@ mod tests { #[test] fn create_credential_request_with_legacy_identifiers_and_a_prover_did() { let (cred_def, key_correctness_proof) = _legacy_cred_def_and_key_correctness_proof(); - let master_secret = _master_secret(); + let link_secret = _link_secret(); let cred_offer = _legacy_cred_offer(key_correctness_proof); let resp = create_credential_request( Some("entropy"), None, &cred_def, - &master_secret, + &link_secret, "default", &cred_offer, ); @@ -922,13 +922,13 @@ mod tests { #[test] fn create_credential_request_with_legacy_identifiers_and_no_prover_did() { let (cred_def, key_correctness_proof) = _legacy_cred_def_and_key_correctness_proof(); - let master_secret = _master_secret(); + let link_secret = _link_secret(); let cred_offer = _legacy_cred_offer(key_correctness_proof); let resp = create_credential_request( Some("entropy"), None, &cred_def, - &master_secret, + &link_secret, "default", &cred_offer, ); @@ -938,13 +938,13 @@ mod tests { #[test] fn create_credential_request_with_new_identifiers_and_a_prover_did() { let (cred_def, key_correctness_proof) = _cred_def_and_key_correctness_proof(); - let master_secret = _master_secret(); + let link_secret = _link_secret(); let cred_offer = _cred_offer(key_correctness_proof); let resp = create_credential_request( Some("entropy"), None, &cred_def, - &master_secret, + &link_secret, "default", &cred_offer, ); @@ -954,13 +954,13 @@ mod tests { #[test] fn create_credential_request_with_new_and_legacy_identifiers_and_a_prover_did() { let (cred_def, key_correctness_proof) = _cred_def_and_key_correctness_proof(); - let master_secret = _master_secret(); + let link_secret = _link_secret(); let cred_offer = _legacy_cred_offer(key_correctness_proof); let resp = create_credential_request( Some("entropy"), None, &cred_def, - &master_secret, + &link_secret, "default", &cred_offer, ); diff --git a/src/services/types.rs b/src/services/types.rs index 4df89c94..72c4e9dd 100644 --- a/src/services/types.rs +++ b/src/services/types.rs @@ -6,7 +6,7 @@ pub use crate::data_types::{ cred_offer::CredentialOffer, cred_request::{CredentialRequest, CredentialRequestMetadata}, credential::{AttributeValues, Credential, CredentialValues}, - master_secret::MasterSecret, + link_secret::LinkSecret, pres_request::PresentationRequest, presentation::Presentation, rev_reg::{RevocationRegistry, RevocationRegistryDelta, RevocationStatusList}, diff --git a/tests/anoncreds_demos.rs b/tests/anoncreds_demos.rs index 0c417f99..0f4be266 100644 --- a/tests/anoncreds_demos.rs +++ b/tests/anoncreds_demos.rs @@ -18,7 +18,7 @@ mod utils; #[test] fn anoncreds_demo_works_for_single_issuer_single_prover() { - // Create Prover pseudo wallet and master secret + // Create Prover pseudo wallet and link secret let mut prover_wallet = ProverWallet::default(); // Create schema @@ -41,7 +41,7 @@ fn anoncreds_demo_works_for_single_issuer_single_prover() { Some("entropy"), None, &gvt_cred_def, - &prover_wallet.master_secret, + &prover_wallet.link_secret, "default", &cred_offer, ) @@ -66,7 +66,7 @@ fn anoncreds_demo_works_for_single_issuer_single_prover() { prover::process_credential( &mut recv_cred, &cred_request_metadata, - &prover_wallet.master_secret, + &prover_wallet.link_secret, &gvt_cred_def, None, ) @@ -128,7 +128,7 @@ fn anoncreds_demo_works_for_single_issuer_single_prover() { &pres_request, present, Some(self_attested), - &prover_wallet.master_secret, + &prover_wallet.link_secret, &schemas, &cred_defs, ) @@ -193,7 +193,7 @@ fn anoncreds_demo_works_for_single_issuer_single_prover() { #[test] fn anoncreds_demo_works_with_revocation_for_single_issuer_single_prover() { - // Create Prover pseudo wallet and master secret + // Create Prover pseudo wallet and link secret let mut prover_wallet = ProverWallet::default(); // Create schema @@ -241,7 +241,7 @@ fn anoncreds_demo_works_with_revocation_for_single_issuer_single_prover() { Some("entropy"), None, &gvt_cred_def, - &prover_wallet.master_secret, + &prover_wallet.link_secret, "default", &cred_offer, ) @@ -289,7 +289,7 @@ fn anoncreds_demo_works_with_revocation_for_single_issuer_single_prover() { prover::process_credential( &mut recv_cred, &cred_request_metadata, - &prover_wallet.master_secret, + &prover_wallet.link_secret, &gvt_cred_def, Some(&gvt_rev_reg_def), ) @@ -446,7 +446,7 @@ fn anoncreds_demo_works_for_multiple_issuer_single_prover() { Some("entropy"), None, &gvt_cred_def, - &prover_wallet.master_secret, + &prover_wallet.link_secret, "default", &gvt_cred_offer, ) @@ -471,7 +471,7 @@ fn anoncreds_demo_works_for_multiple_issuer_single_prover() { prover::process_credential( &mut gvt_recv_cred, &gvt_cred_request_metadata, - &prover_wallet.master_secret, + &prover_wallet.link_secret, &gvt_cred_def, None, ) @@ -489,7 +489,7 @@ fn anoncreds_demo_works_for_multiple_issuer_single_prover() { Some("entropy"), None, &emp_cred_def, - &prover_wallet.master_secret, + &prover_wallet.link_secret, "default", &emp_cred_offer, ) @@ -513,7 +513,7 @@ fn anoncreds_demo_works_for_multiple_issuer_single_prover() { prover::process_credential( &mut emp_recv_cred, &emp_cred_request_metadata, - &prover_wallet.master_secret, + &prover_wallet.link_secret, &emp_cred_def, None, ) @@ -575,7 +575,7 @@ fn anoncreds_demo_works_for_multiple_issuer_single_prover() { &pres_request, present, None, - &prover_wallet.master_secret, + &prover_wallet.link_secret, &schemas, &cred_defs, ) @@ -596,7 +596,7 @@ fn anoncreds_demo_works_for_multiple_issuer_single_prover() { #[test] fn anoncreds_demo_proof_does_not_verify_with_wrong_attr_and_predicates() { - // Create Prover pseudo wallet and master secret + // Create Prover pseudo wallet and link secret let mut prover_wallet = ProverWallet::default(); // Create schema @@ -619,7 +619,7 @@ fn anoncreds_demo_proof_does_not_verify_with_wrong_attr_and_predicates() { Some("entropy"), None, &gvt_cred_def, - &prover_wallet.master_secret, + &prover_wallet.link_secret, "default", &cred_offer, ) @@ -644,7 +644,7 @@ fn anoncreds_demo_proof_does_not_verify_with_wrong_attr_and_predicates() { prover::process_credential( &mut recv_cred, &cred_request_metadata, - &prover_wallet.master_secret, + &prover_wallet.link_secret, &gvt_cred_def, None, ) @@ -704,7 +704,7 @@ fn anoncreds_demo_proof_does_not_verify_with_wrong_attr_and_predicates() { &pres_request, present, Some(self_attested), - &prover_wallet.master_secret, + &prover_wallet.link_secret, &schemas, &cred_defs, ) @@ -725,7 +725,7 @@ fn anoncreds_demo_proof_does_not_verify_with_wrong_attr_and_predicates() { #[test] fn anoncreds_demo_works_for_requested_attribute_in_upper_case() { - // Create Prover pseudo wallet and master secret + // Create Prover pseudo wallet and link secret let mut prover_wallet = ProverWallet::default(); // Create schema @@ -748,7 +748,7 @@ fn anoncreds_demo_works_for_requested_attribute_in_upper_case() { Some("entropy"), None, &gvt_cred_def, - &prover_wallet.master_secret, + &prover_wallet.link_secret, "default", &cred_offer, ) @@ -773,7 +773,7 @@ fn anoncreds_demo_works_for_requested_attribute_in_upper_case() { prover::process_credential( &mut recv_cred, &cred_request_metadata, - &prover_wallet.master_secret, + &prover_wallet.link_secret, &gvt_cred_def, None, ) @@ -833,7 +833,7 @@ fn anoncreds_demo_works_for_requested_attribute_in_upper_case() { &pres_request, present, Some(self_attested), - &prover_wallet.master_secret, + &prover_wallet.link_secret, &schemas, &cred_defs, ) @@ -925,7 +925,7 @@ fn anoncreds_demo_works_for_twice_entry_of_attribute_from_different_credential() Some("entropy"), None, &gvt_cred_def, - &prover_wallet.master_secret, + &prover_wallet.link_secret, "default", &gvt_cred_offer, ) @@ -950,7 +950,7 @@ fn anoncreds_demo_works_for_twice_entry_of_attribute_from_different_credential() prover::process_credential( &mut gvt_recv_cred, &gvt_cred_request_metadata, - &prover_wallet.master_secret, + &prover_wallet.link_secret, &gvt_cred_def, None, ) @@ -968,7 +968,7 @@ fn anoncreds_demo_works_for_twice_entry_of_attribute_from_different_credential() Some("entropy"), None, &emp_cred_def, - &prover_wallet.master_secret, + &prover_wallet.link_secret, "default", &emp_cred_offer, ) @@ -992,7 +992,7 @@ fn anoncreds_demo_works_for_twice_entry_of_attribute_from_different_credential() prover::process_credential( &mut emp_recv_cred, &emp_cred_request_metadata, - &prover_wallet.master_secret, + &prover_wallet.link_secret, &emp_cred_def, None, ) @@ -1059,7 +1059,7 @@ fn anoncreds_demo_works_for_twice_entry_of_attribute_from_different_credential() &pres_request, present, None, - &prover_wallet.master_secret, + &prover_wallet.link_secret, &schemas, &cred_defs, ) @@ -1121,16 +1121,16 @@ fn anoncreds_works_for_twice_entry_of_credential_for_different_witness() { // ISSUANCE CREDENTIAL FOR PROVER1 - // Prover1 creates Master Secret - let prover1_master_secret_id = "prover1_master_secret"; - anoncreds::prover_create_master_secret(prover1_wallet_handle, prover1_master_secret_id) + // Prover1 creates Link Secret + let prover1_link_secret_id = "prover1_link_secret"; + anoncreds::prover_create_link_secret(prover1_wallet_handle, prover1_link_secret_id) .unwrap(); let timestamp1 = time::get_time().sec as u64; let (prover1_cred_rev_id, revoc_reg_delta1_json) = anoncreds::multi_steps_create_revocation_credential( - prover1_master_secret_id, + prover1_link_secret_id, prover1_wallet_handle, issuer_wallet_handle, CREDENTIAL1_ID, @@ -1144,15 +1144,15 @@ fn anoncreds_works_for_twice_entry_of_credential_for_different_witness() { let revoc_reg_delta1_json = revoc_reg_delta1_json.unwrap(); // ISSUANCE CREDENTIAL FOR PROVER2 - // Prover2 creates Master Secret - let prover2_master_secret_id = "prover2_master_secret"; - anoncreds::prover_create_master_secret(prover2_wallet_handle, prover2_master_secret_id) + // Prover2 creates Link Secret + let prover2_link_secret_id = "prover2_link_secret"; + anoncreds::prover_create_link_secret(prover2_wallet_handle, prover2_link_secret_id) .unwrap(); let timestamp2 = time::get_time().sec as u64 + 100; let (_, revoc_reg_delta2_json) = anoncreds::multi_steps_create_revocation_credential( - prover2_master_secret_id, + prover2_link_secret_id, prover2_wallet_handle, issuer_wallet_handle, CREDENTIAL2_ID, @@ -1260,7 +1260,7 @@ fn anoncreds_works_for_twice_entry_of_credential_for_different_witness() { prover1_wallet_handle, &proof_request, &requested_credentials_json, - prover1_master_secret_id, + prover1_link_secret_id, &schemas_json, &credential_defs_json, &rev_states_json, @@ -1364,8 +1364,8 @@ fn anoncreds_works_for_multiple_requested_predicates_from_one_credential() { attr_names, ); - //4. Prover creates Master Secret - anoncreds::prover_create_master_secret(prover_wallet_handle, COMMON_MASTER_SECRET).unwrap(); + //4. Prover creates Link Secret + anoncreds::prover_create_link_secret(prover_wallet_handle, COMMON_LINK_SECRET).unwrap(); //5. Issuance credential for Prover let cred_values = r#"{ @@ -1383,7 +1383,7 @@ fn anoncreds_works_for_multiple_requested_predicates_from_one_credential() { }"#; anoncreds::multi_steps_create_credential( - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, prover_wallet_handle, issuer_wallet_handle, CREDENTIAL1_ID, @@ -1463,7 +1463,7 @@ fn anoncreds_works_for_multiple_requested_predicates_from_one_credential() { prover_wallet_handle, &proof_req_json, &requested_credentials_json, - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, &schemas_json, &cred_defs_json, &rev_states_json, @@ -1514,12 +1514,12 @@ fn anoncreds_works_for_multiple_requested_predicates_from_one_credential() { // GVT_SCHEMA_ATTRIBUTES, // ); -// //4. Prover creates Master Secret -// anoncreds::prover_create_master_secret(prover_wallet_handle, COMMON_MASTER_SECRET).unwrap(); +// //4. Prover creates Link Secret +// anoncreds::prover_create_link_secret(prover_wallet_handle, COMMON_LINK_SECRET).unwrap(); // //5. Issuance credential for Prover // anoncreds::multi_steps_create_credential( -// COMMON_MASTER_SECRET, +// COMMON_LINK_SECRET, // prover_wallet_handle, // issuer_wallet_handle, // CREDENTIAL1_ID, @@ -1574,7 +1574,7 @@ fn anoncreds_works_for_multiple_requested_predicates_from_one_credential() { // prover_wallet_handle, // &proof_req_json, // &requested_credentials_json, -// COMMON_MASTER_SECRET, +// COMMON_LINK_SECRET, // &schemas_json, // &cred_defs_json, // &rev_states_json, @@ -1612,7 +1612,7 @@ fn anoncreds_works_for_multiple_requested_predicates_from_one_credential() { // prover_wallet_handle, // &proof_req_json, // &requested_credentials_json, -// COMMON_MASTER_SECRET, +// COMMON_LINK_SECRET, // &schemas_json, // &cred_defs_json, // &rev_states_json, @@ -1660,8 +1660,8 @@ fn anoncreds_works_for_different_predicate_types() { schema_attributes, ); - //4. Prover creates Master Secret - anoncreds::prover_create_master_secret(prover_wallet_handle, COMMON_MASTER_SECRET).unwrap(); + //4. Prover creates Link Secret + anoncreds::prover_create_link_secret(prover_wallet_handle, COMMON_LINK_SECRET).unwrap(); let cred_values = json!({ "age": {"raw": "28", "encoded": "28"}, @@ -1673,7 +1673,7 @@ fn anoncreds_works_for_different_predicate_types() { //5. Issuance credential for Prover anoncreds::multi_steps_create_credential( - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, prover_wallet_handle, issuer_wallet_handle, CREDENTIAL1_ID, @@ -1737,7 +1737,7 @@ fn anoncreds_works_for_different_predicate_types() { prover_wallet_handle, &proof_req_json, &requested_credentials_json, - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, &schemas_json, &cred_defs_json, &rev_states_json, @@ -1787,11 +1787,11 @@ fn anoncreds_works_for_attr_value_restriction() { ); //4. Prover creates Master Secret - anoncreds::prover_create_master_secret(prover_wallet_handle, COMMON_MASTER_SECRET).unwrap(); + anoncreds::prover_create_link_secret(prover_wallet_handle, COMMON_LINK_SECRET).unwrap(); //5. Issuance credential for Prover anoncreds::multi_steps_create_credential( - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, prover_wallet_handle, issuer_wallet_handle, CREDENTIAL1_ID, @@ -1845,7 +1845,7 @@ fn anoncreds_works_for_attr_value_restriction() { prover_wallet_handle, &proof_req_json, &requested_credentials_json, - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, &schemas_json, &cred_defs_json, &rev_states_json, @@ -1907,11 +1907,11 @@ fn anoncreds_fails_for_unmet_attr_value_restrictions() { ); //4. Prover creates Master Secret - anoncreds::prover_create_master_secret(prover_wallet_handle, COMMON_MASTER_SECRET).unwrap(); + anoncreds::prover_create_link_secret(prover_wallet_handle, COMMON_LINK_SECRET).unwrap(); //5. Issuance 2 credentials for Prover anoncreds::multi_steps_create_credential( - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, prover_wallet_handle, issuer_wallet_handle, CREDENTIAL1_ID, @@ -1921,7 +1921,7 @@ fn anoncreds_fails_for_unmet_attr_value_restrictions() { ); anoncreds::multi_steps_create_credential( - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, prover_wallet_handle, issuer_wallet_handle, CREDENTIAL3_ID, @@ -1968,7 +1968,7 @@ fn anoncreds_fails_for_unmet_attr_value_restrictions() { prover_wallet_handle, &proof_req_json, &requested_credentials_json, - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, &schemas_json, &cred_defs_json, &rev_states_json, @@ -2029,11 +2029,11 @@ fn anoncreds_works_for_single_issuer_single_prover_fully_qualified_ids() { ); //4. Prover creates Master Secret - anoncreds::prover_create_master_secret(prover_wallet_handle, COMMON_MASTER_SECRET).unwrap(); + anoncreds::prover_create_link_secret(prover_wallet_handle, COMMON_LINK_SECRET).unwrap(); //5. Issuance credential for Prover anoncreds::multi_steps_create_credential( - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, prover_wallet_handle, issuer_wallet_handle, CREDENTIAL1_ID, @@ -2108,7 +2108,7 @@ fn anoncreds_works_for_single_issuer_single_prover_fully_qualified_ids() { prover_wallet_handle, &proof_req_json, &requested_credentials_json, - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, &schemas_json, &cred_defs_json, &rev_states_json, @@ -2207,7 +2207,7 @@ fn anoncreds_works_for_single_issuer_single_prover_fully_qualified_ids() { prover_wallet_handle, &proof_req_json, &requested_credentials_json, - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, &schemas_json, &cred_defs_json, &rev_states_json, @@ -2302,7 +2302,7 @@ fn anoncreds_works_for_single_fully_qualified_issuer_single_unqualified_prover() ); //4. Prover creates Master Secret - anoncreds::prover_create_master_secret(prover_wallet_handle, COMMON_MASTER_SECRET).unwrap(); + anoncreds::prover_create_link_secret(prover_wallet_handle, COMMON_LINK_SECRET).unwrap(); //5. Issuance unqualified credential for Prover // Issuer creates Credential Offer @@ -2323,7 +2323,7 @@ fn anoncreds_works_for_single_fully_qualified_issuer_single_unqualified_prover() DID_MY1, &cred_offer_json, &cred_def_json, - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, ) .unwrap(); @@ -2414,7 +2414,7 @@ fn anoncreds_works_for_single_fully_qualified_issuer_single_unqualified_prover() prover_wallet_handle, &proof_req_json, &requested_credentials_json, - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, &schemas_json, &cred_defs_json, &rev_states_json, @@ -2502,11 +2502,11 @@ fn anoncreds_works_for_prover_hold_different_credentials_types() { ); //6. Prover creates Master Secret - anoncreds::prover_create_master_secret(prover_wallet_handle, COMMON_MASTER_SECRET).unwrap(); + anoncreds::prover_create_link_secret(prover_wallet_handle, COMMON_LINK_SECRET).unwrap(); //7. Issuer1 issue GVT Credential for Prover anoncreds::multi_steps_create_credential( - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, prover_wallet_handle, issuer_gvt_wallet_handle, CREDENTIAL1_ID, @@ -2517,7 +2517,7 @@ fn anoncreds_works_for_prover_hold_different_credentials_types() { //8. Issuer2 issue XYZ Credential for Prover anoncreds::multi_steps_create_credential( - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, prover_wallet_handle, issuer_xyz_wallet_handle, CREDENTIAL2_ID, @@ -2613,7 +2613,7 @@ fn anoncreds_works_for_prover_hold_different_credentials_types() { prover_wallet_handle, &proof_req_json, &requested_credentials_json, - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, &schemas_json, &credential_defs_json, &rev_states_json, @@ -2718,11 +2718,11 @@ fn anoncreds_works_for_restrictions_as_empty_array() { ); //4. Prover creates Master Secret - anoncreds::prover_create_master_secret(prover_wallet_handle, COMMON_MASTER_SECRET).unwrap(); + anoncreds::prover_create_link_secret(prover_wallet_handle, COMMON_LINK_SECRET).unwrap(); //5. Issuance credential for Prover anoncreds::multi_steps_create_credential( - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, prover_wallet_handle, issuer_wallet_handle, CREDENTIAL1_ID, @@ -2794,7 +2794,7 @@ fn anoncreds_works_for_restrictions_as_empty_array() { prover_wallet_handle, &proof_req_json, &requested_credentials_json, - COMMON_MASTER_SECRET, + COMMON_LINK_SECRET, &schemas_json, &cred_defs_json, &rev_states_json, diff --git a/tests/utils/fixtures.rs b/tests/utils/fixtures.rs index 2caefc79..512c0b01 100644 --- a/tests/utils/fixtures.rs +++ b/tests/utils/fixtures.rs @@ -217,7 +217,7 @@ pub fn create_presentation( pres_request, present, Some(self_attested), - &prover_wallet.master_secret, + &prover_wallet.link_secret, schemas, cred_defs, ) diff --git a/tests/utils/mock.rs b/tests/utils/mock.rs index 619c6e32..9c0a6016 100644 --- a/tests/utils/mock.rs +++ b/tests/utils/mock.rs @@ -319,7 +319,7 @@ impl<'a> Mock<'a> { Some("entropy"), None, &cred_def, - &self.prover_wallets[prover_id].master_secret, + &self.prover_wallets[prover_id].link_secret, "default", &offer, ) @@ -347,7 +347,7 @@ impl<'a> Mock<'a> { prover::process_credential( &mut recv_cred, &cred_req_data.1, - &self.prover_wallets[prover_id].master_secret, + &self.prover_wallets[prover_id].link_secret, &cred_def, rev_def, ) @@ -451,7 +451,7 @@ impl<'a> Mock<'a> { req, present, Some(self_attested.clone()), - &self.prover_wallets[prover_id].master_secret, + &self.prover_wallets[prover_id].link_secret, &schemas, &cred_defs, ) diff --git a/tests/utils/storage.rs b/tests/utils/storage.rs index cb4e91e6..adbffab5 100644 --- a/tests/utils/storage.rs +++ b/tests/utils/storage.rs @@ -1,6 +1,6 @@ use anoncreds::data_types::cred_def::{CredentialDefinition, CredentialDefinitionId}; use anoncreds::data_types::credential::Credential; -use anoncreds::data_types::master_secret::MasterSecret; +use anoncreds::data_types::link_secret::LinkSecret; use anoncreds::data_types::rev_reg::RevocationRegistryId; use anoncreds::data_types::rev_reg_def::{ RevocationRegistryDefinition, RevocationRegistryDefinitionId, @@ -57,18 +57,18 @@ impl<'a> Default for IssuerWallet<'a> { pub struct ProverWallet<'a> { pub credentials: Vec, pub rev_states: HashMap, Option)>, - pub master_secret: MasterSecret, + pub link_secret: LinkSecret, pub cred_offers: HashMap<&'a str, CredentialOffer>, pub cred_reqs: Vec<(CredentialRequest, CredentialRequestMetadata)>, } impl<'a> Default for ProverWallet<'a> { fn default() -> Self { - let master_secret = MasterSecret::new().expect("Error creating prover master secret"); + let link_secret = LinkSecret::new().expect("Error creating prover link secret"); Self { credentials: vec![], rev_states: HashMap::new(), - master_secret, + link_secret, cred_offers: HashMap::new(), cred_reqs: vec![], } diff --git a/wrappers/javascript/anoncreds-nodejs/src/NodeJSAnoncreds.ts b/wrappers/javascript/anoncreds-nodejs/src/NodeJSAnoncreds.ts index c07c41ba..1395d476 100644 --- a/wrappers/javascript/anoncreds-nodejs/src/NodeJSAnoncreds.ts +++ b/wrappers/javascript/anoncreds-nodejs/src/NodeJSAnoncreds.ts @@ -225,18 +225,18 @@ export class NodeJSAnoncreds implements Anoncreds { public processCredential(options: { credential: ObjectHandle credentialRequestMetadata: ObjectHandle - masterSecret: ObjectHandle + linkSecret: ObjectHandle credentialDefinition: ObjectHandle revocationRegistryDefinition?: ObjectHandle | undefined }): ObjectHandle { - const { credential, credentialRequestMetadata, masterSecret, credentialDefinition } = serializeArguments(options) + const { credential, credentialRequestMetadata, linkSecret, credentialDefinition } = serializeArguments(options) const ret = allocatePointer() this.nativeAnoncreds.anoncreds_process_credential( credential, credentialRequestMetadata, - masterSecret, + linkSecret, credentialDefinition, options.revocationRegistryDefinition?.handle ?? 0, ret @@ -264,11 +264,11 @@ export class NodeJSAnoncreds implements Anoncreds { entropy?: string proverDid?: string credentialDefinition: ObjectHandle - masterSecret: ObjectHandle - masterSecretId: string + linkSecret: ObjectHandle + linkSecretId: string credentialOffer: ObjectHandle }): { credentialRequest: ObjectHandle; credentialRequestMetadata: ObjectHandle } { - const { entropy, proverDid, credentialDefinition, masterSecret, masterSecretId, credentialOffer } = + const { entropy, proverDid, credentialDefinition, linkSecret, linkSecretId, credentialOffer } = serializeArguments(options) const credentialRequestPtr = allocatePointer() @@ -278,8 +278,8 @@ export class NodeJSAnoncreds implements Anoncreds { entropy, proverDid, credentialDefinition, - masterSecret, - masterSecretId, + linkSecret, + linkSecretId, credentialOffer, credentialRequestPtr, credentialRequestMetadataPtr @@ -292,10 +292,10 @@ export class NodeJSAnoncreds implements Anoncreds { } } - public createMasterSecret(): ObjectHandle { + public createLinkSecret(): ObjectHandle { const ret = allocatePointer() - this.nativeAnoncreds.anoncreds_create_master_secret(ret) + this.nativeAnoncreds.anoncreds_create_link_secret(ret) this.handleError() return new ObjectHandle(handleReturnPointer(ret)) @@ -306,11 +306,11 @@ export class NodeJSAnoncreds implements Anoncreds { credentials: NativeCredentialEntry[] credentialsProve: NativeCredentialProve[] selfAttest: Record - masterSecret: ObjectHandle + linkSecret: ObjectHandle schemas: Record credentialDefinitions: Record }): ObjectHandle { - const { presentationRequest, masterSecret } = serializeArguments(options) + const { presentationRequest, linkSecret } = serializeArguments(options) const credentialEntries = options.credentials.map((value) => CredentialEntryStruct({ @@ -390,7 +390,7 @@ export class NodeJSAnoncreds implements Anoncreds { credentialProveList as unknown as Buffer, selfAttestNames as unknown as Buffer, selfAttestValues as unknown as Buffer, - masterSecret, + linkSecret, schemas as unknown as Buffer, schemaIds as unknown as Buffer, credentialDefinitions as unknown as Buffer, @@ -636,8 +636,8 @@ export class NodeJSAnoncreds implements Anoncreds { return this.objectFromJson(this.nativeAnoncreds.anoncreds_presentation_request_from_json, options) } - public masterSecretFromJson(options: { json: string }): ObjectHandle { - return this.objectFromJson(this.nativeAnoncreds.anoncreds_master_secret_from_json, options) + public linkSecretFromJson(options: { json: string }): ObjectHandle { + return this.objectFromJson(this.nativeAnoncreds.anoncreds_link_secret_from_json, options) } public credentialRequestFromJson(options: { json: string }): ObjectHandle { diff --git a/wrappers/javascript/anoncreds-nodejs/src/library/bindings.ts b/wrappers/javascript/anoncreds-nodejs/src/library/bindings.ts index 0841e939..d4317dcb 100644 --- a/wrappers/javascript/anoncreds-nodejs/src/library/bindings.ts +++ b/wrappers/javascript/anoncreds-nodejs/src/library/bindings.ts @@ -68,7 +68,7 @@ export const nativeBindings = { FFI_OBJECT_HANDLE_PTR, ], ], - anoncreds_create_master_secret: [FFI_ERRORCODE, [FFI_OBJECT_HANDLE_PTR]], + anoncreds_create_link_secret: [FFI_ERRORCODE, [FFI_OBJECT_HANDLE_PTR]], anoncreds_create_or_update_revocation_state: [ FFI_ERRORCODE, [ @@ -168,7 +168,7 @@ export const nativeBindings = { [FFI_INT64, I32ListStruct, I32ListStruct, FFI_OBJECT_HANDLE, FFI_OBJECT_HANDLE, FFI_OBJECT_HANDLE_PTR], ], anoncreds_version: [FFI_STRING, []], - anoncreds_master_secret_from_json: [FFI_ERRORCODE, [ByteBufferStruct, FFI_STRING_PTR]], + anoncreds_link_secret_from_json: [FFI_ERRORCODE, [ByteBufferStruct, FFI_STRING_PTR]], anoncreds_credential_request_from_json: [FFI_ERRORCODE, [ByteBufferStruct, FFI_STRING_PTR]], anoncreds_credential_request_metadata_from_json: [FFI_ERRORCODE, [ByteBufferStruct, FFI_STRING_PTR]], anoncreds_presentation_from_json: [FFI_ERRORCODE, [ByteBufferStruct, FFI_STRING_PTR]], diff --git a/wrappers/javascript/anoncreds-nodejs/test/api.test.ts b/wrappers/javascript/anoncreds-nodejs/test/api.test.ts index 14f98f66..effa7326 100644 --- a/wrappers/javascript/anoncreds-nodejs/test/api.test.ts +++ b/wrappers/javascript/anoncreds-nodejs/test/api.test.ts @@ -6,7 +6,7 @@ import { CredentialRequest, CredentialRevocationConfig, CredentialRevocationState, - MasterSecret, + LinkSecret, Presentation, PresentationRequest, RevocationRegistryDefinition, @@ -89,14 +89,14 @@ describe('API', () => { keyCorrectnessProof, }) - const masterSecret = MasterSecret.create() - const masterSecretId = 'master secret id' + const linkSecret = LinkSecret.create() + const linkSecretId = 'link secret id' const { credentialRequestMetadata, credentialRequest } = CredentialRequest.create({ entropy: 'entropy', credentialDefinition, - masterSecret, - masterSecretId, + linkSecret, + linkSecretId, credentialOffer, }) @@ -119,7 +119,7 @@ describe('API', () => { const credentialReceived = credential.process({ credentialDefinition, credentialRequestMetadata, - masterSecret, + linkSecret, revocationRegistryDefinition, }) @@ -168,7 +168,7 @@ describe('API', () => { reveal: true, }, ], - masterSecret, + linkSecret, schemas: { 'mock:uri': schema }, selfAttest: { attr3_referent: '8-800-300' }, }) @@ -209,14 +209,14 @@ describe('API', () => { keyCorrectnessProof, }) - const masterSecret = MasterSecret.create() - const masterSecretId = 'master secret id' + const linkSecret = LinkSecret.create() + const linkSecretId = 'link secret id' const { credentialRequestMetadata, credentialRequest } = CredentialRequest.create({ entropy: 'entropy', credentialDefinition, - masterSecret, - masterSecretId, + linkSecret, + linkSecretId, credentialOffer, }) @@ -231,7 +231,7 @@ describe('API', () => { const credReceived = credential.process({ credentialDefinition, credentialRequestMetadata, - masterSecret, + linkSecret, }) const credJson = credential.toJson() @@ -312,7 +312,7 @@ describe('API', () => { reveal: true, }, ], - masterSecret, + linkSecret, schemas: { 'mock:uri': schema }, selfAttest: { attr3_referent: '8-800-300' }, }) @@ -329,7 +329,11 @@ describe('API', () => { }) }) -test('create and verify presentation passing only JSON objects as parameters)', () => { +test('create and verify presentation passing only JSON objects as parameters', () => { + setup() + + const nonce = anoncreds.generateNonce() + // a schema can be created from JSON const schema = Schema.fromJson({ name: 'schema-1', @@ -358,20 +362,21 @@ test('create and verify presentation passing only JSON objects as parameters)', tag: 'TAG', }) - const credentialOffer = CredentialOffer.create({ - schemaId: 'mock:uri', - credentialDefinitionId: 'mock:uri', - keyCorrectnessProof: keyCorrectnessProof.toJson(), + const credentialOffer = CredentialOffer.fromJson({ + schema_id: 'mock:uri', + cred_def_id: 'mock:uri', + key_correctness_proof: keyCorrectnessProof.toJson(), + nonce, }) - const masterSecret = MasterSecret.create() - const masterSecretId = 'master secret id' + const linkSecret = LinkSecret.fromJson({ value: { ms: '123' } }) + const linkSecretId = 'link secret id' const { credentialRequestMetadata, credentialRequest } = CredentialRequest.create({ entropy: 'entropy', credentialDefinition: credentialDefinition.toJson(), - masterSecret: masterSecret.toJson(), - masterSecretId, + linkSecret: linkSecret.toJson(), + linkSecretId, credentialOffer: credentialOffer.toJson(), }) @@ -386,7 +391,7 @@ test('create and verify presentation passing only JSON objects as parameters)', const credReceived = credential.process({ credentialDefinition: credentialDefinition.toJson(), credentialRequestMetadata: credentialRequestMetadata.toJson(), - masterSecret: masterSecret.toJson(), + linkSecret: linkSecret.toJson(), }) const credJson = credential.toJson() @@ -407,8 +412,6 @@ test('create and verify presentation passing only JSON objects as parameters)', expect(credReceivedJson).toHaveProperty('signature') expect(credReceivedJson).toHaveProperty('witness') - const nonce = anoncreds.generateNonce() - const presentationRequest = { nonce, name: 'pres_req_1', @@ -467,7 +470,7 @@ test('create and verify presentation passing only JSON objects as parameters)', reveal: true, }, ], - masterSecret: masterSecret.toJson(), + linkSecret, schemas: { 'mock:uri': schema.toJson() }, selfAttest: { attr3_referent: '8-800-300' }, }) diff --git a/wrappers/javascript/anoncreds-nodejs/test/bindings.test.ts b/wrappers/javascript/anoncreds-nodejs/test/bindings.test.ts index ca7e13c8..e336b386 100644 --- a/wrappers/javascript/anoncreds-nodejs/test/bindings.test.ts +++ b/wrappers/javascript/anoncreds-nodejs/test/bindings.test.ts @@ -132,9 +132,9 @@ describe('bindings', () => { ) }) - test('create master secret', () => { - const masterSecret = anoncreds.createMasterSecret() - const json = anoncreds.getJson({ objectHandle: masterSecret }) + test('create link secret', () => { + const linkSecret = anoncreds.createLinkSecret() + const json = anoncreds.getJson({ objectHandle: linkSecret }) expect(JSON.parse(json)).toHaveProperty('value') expect(JSON.parse(json).value).toHaveProperty('ms') }) @@ -196,14 +196,14 @@ describe('bindings', () => { keyCorrectnessProof, }) - const masterSecret = anoncreds.createMasterSecret() - const masterSecretId = 'master secret id' + const linkSecret = anoncreds.createLinkSecret() + const linkSecretId = 'link secret id' const { credentialRequest, credentialRequestMetadata } = anoncreds.createCredentialRequest({ entropy: ENTROPY, credentialDefinition: credentialDefinition, - masterSecret, - masterSecretId, + linkSecret, + linkSecretId, credentialOffer: credOfferObj, }) @@ -219,10 +219,10 @@ describe('bindings', () => { const credReqMetadataJson = anoncreds.getJson({ objectHandle: credentialRequestMetadata }) expect(JSON.parse(credReqMetadataJson)).toEqual( expect.objectContaining({ - master_secret_name: masterSecretId, + link_secret_name: linkSecretId, }) ) - expect(JSON.parse(credReqMetadataJson)).toHaveProperty('master_secret_blinding_data') + expect(JSON.parse(credReqMetadataJson)).toHaveProperty('link_secret_blinding_data') expect(JSON.parse(credReqMetadataJson)).toHaveProperty('nonce') }) @@ -274,14 +274,14 @@ describe('bindings', () => { keyCorrectnessProof, }) - const masterSecret = anoncreds.createMasterSecret() - const masterSecretId = 'master secret id' + const linkSecret = anoncreds.createLinkSecret() + const linkSecretId = 'link secret id' const { credentialRequestMetadata, credentialRequest } = anoncreds.createCredentialRequest({ entropy: ENTROPY, credentialDefinition, - masterSecret, - masterSecretId, + linkSecret, + linkSecretId, credentialOffer, }) @@ -305,7 +305,7 @@ describe('bindings', () => { credential, credentialDefinition, credentialRequestMetadata, - masterSecret, + linkSecret, revocationRegistryDefinition, }) @@ -409,14 +409,14 @@ describe('bindings', () => { keyCorrectnessProof, }) - const masterSecret = anoncreds.createMasterSecret() - const masterSecretId = 'master secret id' + const linkSecret = anoncreds.createLinkSecret() + const linkSecretId = 'link secret id' const { credentialRequestMetadata, credentialRequest } = anoncreds.createCredentialRequest({ entropy: ENTROPY, credentialDefinition, - masterSecret, - masterSecretId, + linkSecret, + linkSecretId, credentialOffer, }) @@ -440,7 +440,7 @@ describe('bindings', () => { credential, credentialDefinition, credentialRequestMetadata, - masterSecret, + linkSecret, revocationRegistryDefinition, }) @@ -494,7 +494,7 @@ describe('bindings', () => { reveal: true, }, ], - masterSecret, + linkSecret, schemas: { 'mock:uri': schemaObj }, selfAttest: { attr3_referent: '8-800-300' }, }) @@ -540,14 +540,14 @@ describe('bindings', () => { keyCorrectnessProof, }) - const masterSecret = anoncreds.createMasterSecret() - const masterSecretId = 'master secret id' + const linkSecret = anoncreds.createLinkSecret() + const linkSecretId = 'link secret id' const { credentialRequestMetadata, credentialRequest } = anoncreds.createCredentialRequest({ entropy: ENTROPY, credentialDefinition, - masterSecret, - masterSecretId, + linkSecret, + linkSecretId, credentialOffer, }) @@ -563,7 +563,7 @@ describe('bindings', () => { credential, credentialDefinition, credentialRequestMetadata, - masterSecret, + linkSecret, }) const credJson = anoncreds.getJson({ objectHandle: credential }) @@ -646,7 +646,7 @@ describe('bindings', () => { reveal: true, }, ], - masterSecret, + linkSecret, schemas: { 'mock:uri': schemaObj }, selfAttest: { attr3_referent: '8-800-300' }, }) diff --git a/wrappers/javascript/anoncreds-react-native/cpp/HostObject.cpp b/wrappers/javascript/anoncreds-react-native/cpp/HostObject.cpp index efff353c..ef754c02 100644 --- a/wrappers/javascript/anoncreds-react-native/cpp/HostObject.cpp +++ b/wrappers/javascript/anoncreds-react-native/cpp/HostObject.cpp @@ -21,7 +21,7 @@ FunctionMap AnoncredsTurboModuleHostObject::functionMapping(jsi::Runtime &rt) { fMap.insert(std::make_tuple("createCredentialRequest", &anoncreds::createCredentialRequest)); fMap.insert( - std::make_tuple("createMasterSecret", &anoncreds::createMasterSecret)); + std::make_tuple("createLinkSecret", &anoncreds::createLinkSecret)); fMap.insert(std::make_tuple("createOrUpdateRevocationState", &anoncreds::createOrUpdateRevocationState)); fMap.insert( @@ -61,8 +61,8 @@ FunctionMap AnoncredsTurboModuleHostObject::functionMapping(jsi::Runtime &rt) { fMap.insert(std::make_tuple("credentialOfferFromJson", &anoncreds::credentialOfferFromJson)); fMap.insert(std::make_tuple("schemaFromJson", &anoncreds::schemaFromJson)); - fMap.insert(std::make_tuple("masterSecretFromJson", - &anoncreds::masterSecretFromJson)); + fMap.insert(std::make_tuple("linkSecretFromJson", + &anoncreds::linkSecretFromJson)); fMap.insert(std::make_tuple("credentialRequestFromJson", &anoncreds::credentialRequestFromJson)); fMap.insert(std::make_tuple("credentialRequestMetadataFromJson", diff --git a/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.cpp b/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.cpp index 6b27a57a..aa02289f 100644 --- a/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.cpp +++ b/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.cpp @@ -55,10 +55,10 @@ jsi::Value objectFree(jsi::Runtime &rt, jsi::Object options) { // ===== META ===== -jsi::Value createMasterSecret(jsi::Runtime &rt, jsi::Object options) { +jsi::Value createLinkSecret(jsi::Runtime &rt, jsi::Object options) { ObjectHandle out; - ErrorCode code = anoncreds_create_master_secret(&out); + ErrorCode code = anoncreds_create_link_secret(&out); return createReturnValue(rt, code, &out); }; @@ -213,13 +213,13 @@ jsi::Value schemaFromJson(jsi::Runtime &rt, jsi::Object options) { return returnValue; }; -jsi::Value masterSecretFromJson(jsi::Runtime &rt, jsi::Object options) { +jsi::Value linkSecretFromJson(jsi::Runtime &rt, jsi::Object options) { auto json = jsiToValue(rt, options, "json"); ObjectHandle out; ByteBuffer b = stringToByteBuffer(json); - ErrorCode code = anoncreds_master_secret_from_json(b, &out); + ErrorCode code = anoncreds_link_secret_from_json(b, &out); auto returnValue = createReturnValue(rt, code, &out); // Free memory @@ -381,7 +381,7 @@ jsi::Value createPresentation(jsi::Runtime &rt, jsi::Object options) { jsiToValue(rt, options, "selfAttestNames"); auto selfAttestedValues = jsiToValue(rt, options, "selfAttestValues"); - auto masterSecret = jsiToValue(rt, options, "masterSecret"); + auto linkSecret = jsiToValue(rt, options, "linkSecret"); auto schemas = jsiToValue(rt, options, "schemas"); auto schemaIds = jsiToValue(rt, options, "schemaIds"); auto credentialDefinitions = @@ -393,7 +393,7 @@ jsi::Value createPresentation(jsi::Runtime &rt, jsi::Object options) { ErrorCode code = anoncreds_create_presentation( presentationRequest, credentials, credentialsProve, selfAttestedNames, - selfAttestedValues, masterSecret, schemas, schemaIds, + selfAttestedValues, linkSecret, schemas, schemaIds, credentialDefinitions, credentialDefinitionIds, &out); auto returnValue = createReturnValue(rt, code, &out); @@ -521,8 +521,8 @@ jsi::Value createCredentialRequest(jsi::Runtime &rt, jsi::Object options) { auto proverDid = jsiToValue(rt, options, "proverDid", true); auto credentialDefinition = jsiToValue(rt, options, "credentialDefinition"); - auto masterSecret = jsiToValue(rt, options, "masterSecret"); - auto masterSecretId = jsiToValue(rt, options, "masterSecretId"); + auto linkSecret = jsiToValue(rt, options, "linkSecret"); + auto linkSecretId = jsiToValue(rt, options, "linkSecretId"); auto credentialOffer = jsiToValue(rt, options, "credentialOffer"); @@ -531,7 +531,7 @@ jsi::Value createCredentialRequest(jsi::Runtime &rt, jsi::Object options) { ErrorCode code = anoncreds_create_credential_request( entropy.length() ? entropy.c_str() : nullptr, proverDid.length() ? proverDid.c_str() : nullptr, credentialDefinition, - masterSecret, masterSecretId.c_str(), credentialOffer, + linkSecret, linkSecretId.c_str(), credentialOffer, &out.credentialRequest, &out.credentialRequestMetadata); return createReturnValue(rt, code, &out); @@ -565,7 +565,7 @@ jsi::Value processCredential(jsi::Runtime &rt, jsi::Object options) { auto credential = jsiToValue(rt, options, "credential"); auto credentialRequestMetadata = jsiToValue(rt, options, "credentialRequestMetadata"); - auto masterSecret = jsiToValue(rt, options, "masterSecret"); + auto linkSecret = jsiToValue(rt, options, "linkSecret"); auto credentialDefinition = jsiToValue(rt, options, "credentialDefinition"); auto revocationRegistryDefinition = jsiToValue( @@ -574,7 +574,7 @@ jsi::Value processCredential(jsi::Runtime &rt, jsi::Object options) { ObjectHandle out; ErrorCode code = anoncreds_process_credential( - credential, credentialRequestMetadata, masterSecret, credentialDefinition, + credential, credentialRequestMetadata, linkSecret, credentialDefinition, revocationRegistryDefinition, &out); return createReturnValue(rt, code, &out); diff --git a/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.h b/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.h index 6eb13045..e87f02c4 100644 --- a/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.h +++ b/wrappers/javascript/anoncreds-react-native/cpp/anoncreds.h @@ -33,7 +33,7 @@ jsi::Value setDefaultLogger(jsi::Runtime &rt, jsi::Object options); jsi::Value objectFree(jsi::Runtime &rt, jsi::Object options); // Meta -jsi::Value createMasterSecret(jsi::Runtime &rt, jsi::Object options); +jsi::Value createLinkSecret(jsi::Runtime &rt, jsi::Object options); jsi::Value generateNonce(jsi::Runtime &rt, jsi::Object options); // Anoncreds Objects @@ -48,7 +48,7 @@ jsi::Value presentationFromJson(jsi::Runtime &rt, jsi::Object options); jsi::Value presentationRequestFromJson(jsi::Runtime &rt, jsi::Object options); jsi::Value credentialOfferFromJson(jsi::Runtime &rt, jsi::Object options); jsi::Value schemaFromJson(jsi::Runtime &rt, jsi::Object options); -jsi::Value masterSecretFromJson(jsi::Runtime &rt, jsi::Object options); +jsi::Value linkSecretFromJson(jsi::Runtime &rt, jsi::Object options); jsi::Value credentialRequestFromJson(jsi::Runtime &rt, jsi::Object options); jsi::Value credentialRequestMetadataFromJson(jsi::Runtime &rt, jsi::Object options); diff --git a/wrappers/javascript/anoncreds-react-native/cpp/include/libanoncreds.h b/wrappers/javascript/anoncreds-react-native/cpp/include/libanoncreds.h index c9bc0bf2..0a9931b6 100644 --- a/wrappers/javascript/anoncreds-react-native/cpp/include/libanoncreds.h +++ b/wrappers/javascript/anoncreds-react-native/cpp/include/libanoncreds.h @@ -285,13 +285,13 @@ ErrorCode anoncreds_create_credential_offer(FfiStr schema_id, ErrorCode anoncreds_create_credential_request(FfiStr entropy, FfiStr prover_did, ObjectHandle cred_def, - ObjectHandle master_secret, - FfiStr master_secret_id, + ObjectHandle link_secret, + FfiStr link_secret_id, ObjectHandle cred_offer, ObjectHandle *cred_req_p, ObjectHandle *cred_req_meta_p); -ErrorCode anoncreds_create_master_secret(ObjectHandle *master_secret_p); +ErrorCode anoncreds_create_link_secret(ObjectHandle *link_secret_p); ErrorCode anoncreds_create_or_update_revocation_state(ObjectHandle rev_reg_def, ObjectHandle rev_status_list, @@ -306,7 +306,7 @@ ErrorCode anoncreds_create_presentation(ObjectHandle pres_req, struct FfiList_FfiCredentialProve credentials_prove, FfiStrList self_attest_names, FfiStrList self_attest_values, - ObjectHandle master_secret, + ObjectHandle link_secret, struct FfiList_ObjectHandle schemas, FfiStrList schema_ids, struct FfiList_ObjectHandle cred_defs, @@ -354,7 +354,7 @@ ErrorCode anoncreds_object_get_type_name(ObjectHandle handle, const char **resul ErrorCode anoncreds_process_credential(ObjectHandle cred, ObjectHandle cred_req_metadata, - ObjectHandle master_secret, + ObjectHandle link_secret, ObjectHandle cred_def, ObjectHandle rev_reg_def, ObjectHandle *cred_p); @@ -388,39 +388,6 @@ ErrorCode anoncreds_verify_presentation(ObjectHandle presentation, struct FfiList_FfiNonrevokedIntervalOverride nonrevoked_interval_override, int8_t *result_p); -ErrorCode anoncreds_master_secret_from_json(ByteBuffer buffer, ObjectHandle *master_secret_p); - -ErrorCode anoncreds_credential_from_json(ByteBuffer buffer, ObjectHandle *credential_p); - -ErrorCode anoncreds_credential_request_from_json(ByteBuffer buffer, ObjectHandle *credential_request_p); - -ErrorCode anoncreds_credential_request_metadata_from_json(ByteBuffer buffer, ObjectHandle *credential_request_metadata_p); - -ErrorCode anoncreds_presentation_from_json(ByteBuffer buffer, ObjectHandle *presentation_p); - -ErrorCode anoncreds_presentation_request_from_json(ByteBuffer buffer, ObjectHandle *presentation_request_p); - -ErrorCode anoncreds_credential_offer_from_json(ByteBuffer buffer, ObjectHandle *credential_offer_p); - -ErrorCode anoncreds_credential_definition_private_from_json(ByteBuffer buffer, ObjectHandle *credential_definition_private_p); - -ErrorCode anoncreds_revocation_registry_definition_from_json(ByteBuffer buffer, ObjectHandle *revocation_registry_definition_p); - -ErrorCode anoncreds_revocation_registry_from_json(ByteBuffer buffer, ObjectHandle *revocation_registry_p); - -ErrorCode anoncreds_revocation_state_from_json(ByteBuffer buffer, ObjectHandle *revocation_state_p); - -ErrorCode anoncreds_credential_definition_from_json(ByteBuffer buffer, ObjectHandle *credential_definition_p); - -ErrorCode anoncreds_revocation_registry_definition_private_from_json(ByteBuffer buffer, ObjectHandle *revocation_registry_private_p); - -ErrorCode anoncreds_revocation_registry_delta_from_json(ByteBuffer buffer, ObjectHandle *revocation_registry_delta_p); - -ErrorCode anoncreds_key_correctness_proof_from_json(ByteBuffer buffer, ObjectHandle *key_correctness_proof_p); - -ErrorCode anoncreds_schema_from_json(ByteBuffer buffer, ObjectHandle *schema_p); - - char *anoncreds_version(void); #ifdef __cplusplus diff --git a/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts b/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts index 9b0daf75..276cfa50 100644 --- a/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts +++ b/wrappers/javascript/anoncreds-react-native/src/ReactNativeAnoncreds.ts @@ -140,7 +140,7 @@ export class ReactNativeAnoncreds implements Anoncreds { public processCredential(options: { credential: ObjectHandle credentialRequestMetadata: ObjectHandle - masterSecret: ObjectHandle + linkSecret: ObjectHandle credentialDefinition: ObjectHandle revocationRegistryDefinition?: ObjectHandle }): ObjectHandle { @@ -161,8 +161,8 @@ export class ReactNativeAnoncreds implements Anoncreds { entropy?: string proverDid?: string credentialDefinition: ObjectHandle - masterSecret: ObjectHandle - masterSecretId: string + linkSecret: ObjectHandle + linkSecretId: string credentialOffer: ObjectHandle }): { credentialRequest: ObjectHandle; credentialRequestMetadata: ObjectHandle } { const { credentialRequest, credentialRequestMetadata } = handleError( @@ -175,8 +175,8 @@ export class ReactNativeAnoncreds implements Anoncreds { } } - public createMasterSecret(): ObjectHandle { - const handle = handleError(anoncredsReactNative.createMasterSecret({})) + public createLinkSecret(): ObjectHandle { + const handle = handleError(anoncredsReactNative.createLinkSecret({})) return new ObjectHandle(handle) } @@ -185,7 +185,7 @@ export class ReactNativeAnoncreds implements Anoncreds { credentials: NativeCredentialEntry[] credentialsProve: NativeCredentialProve[] selfAttest: Record - masterSecret: ObjectHandle + linkSecret: ObjectHandle schemas: Record credentialDefinitions: Record }): ObjectHandle { @@ -205,7 +205,7 @@ export class ReactNativeAnoncreds implements Anoncreds { const handle = handleError( anoncredsReactNative.createPresentation({ presentationRequest: options.presentationRequest.handle, - masterSecret: options.masterSecret.handle, + linkSecret: options.linkSecret.handle, credentialsProve: options.credentialsProve, selfAttestNames, selfAttestValues, @@ -325,8 +325,8 @@ export class ReactNativeAnoncreds implements Anoncreds { return new ObjectHandle(handle) } - public masterSecretFromJson(options: { json: string }): ObjectHandle { - const handle = handleError(anoncredsReactNative.masterSecretFromJson(serializeArguments(options))) + public linkSecretFromJson(options: { json: string }): ObjectHandle { + const handle = handleError(anoncredsReactNative.linkSecretFromJson(serializeArguments(options))) return new ObjectHandle(handle) } diff --git a/wrappers/javascript/anoncreds-react-native/src/library/NativeBindings.ts b/wrappers/javascript/anoncreds-react-native/src/library/NativeBindings.ts index b43d8849..1cb6590f 100644 --- a/wrappers/javascript/anoncreds-react-native/src/library/NativeBindings.ts +++ b/wrappers/javascript/anoncreds-react-native/src/library/NativeBindings.ts @@ -68,7 +68,7 @@ export interface NativeBindings { processCredential(options: { credential: number credentialRequestMetadata: number - masterSecret: number + linkSecret: number credentialDefinition: number revocationRegistryDefinition?: number }): ReturnObject @@ -83,12 +83,12 @@ export interface NativeBindings { entropy?: string proverDid?: string credentialDefinition: number - masterSecret: number - masterSecretId: string + linkSecret: number + linkSecretId: string credentialOffer: number }): ReturnObject<{ credentialRequest: Handle; credentialRequestMetadata: Handle }> - createMasterSecret(options: Record): ReturnObject + createLinkSecret(options: Record): ReturnObject createPresentation(options: { presentationRequest: number @@ -96,7 +96,7 @@ export interface NativeBindings { credentialsProve: NativeCredentialProve[] selfAttestNames: string[] selfAttestValues: string[] - masterSecret: number + linkSecret: number schemaIds: string[] schemas: number[] credentialDefinitionIds: string[] @@ -165,7 +165,7 @@ export interface NativeBindings { schemaFromJson(options: { json: string }): ReturnObject - masterSecretFromJson(options: { json: string }): ReturnObject + linkSecretFromJson(options: { json: string }): ReturnObject credentialRequestFromJson(options: { json: string }): ReturnObject diff --git a/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts b/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts index 79451af0..8cc90d8c 100644 --- a/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts +++ b/wrappers/javascript/anoncreds-shared/src/Anoncreds.ts @@ -75,7 +75,7 @@ export interface Anoncreds { processCredential(options: { credential: ObjectHandle credentialRequestMetadata: ObjectHandle - masterSecret: ObjectHandle + linkSecret: ObjectHandle credentialDefinition: ObjectHandle revocationRegistryDefinition?: ObjectHandle }): ObjectHandle @@ -90,19 +90,19 @@ export interface Anoncreds { entropy?: string proverDid?: string credentialDefinition: ObjectHandle - masterSecret: ObjectHandle - masterSecretId: string + linkSecret: ObjectHandle + linkSecretId: string credentialOffer: ObjectHandle }): { credentialRequest: ObjectHandle; credentialRequestMetadata: ObjectHandle } - createMasterSecret(): ObjectHandle + createLinkSecret(): ObjectHandle createPresentation(options: { presentationRequest: ObjectHandle credentials: NativeCredentialEntry[] credentialsProve: NativeCredentialProve[] selfAttest: Record - masterSecret: ObjectHandle + linkSecret: ObjectHandle schemas: Record credentialDefinitions: Record }): ObjectHandle @@ -179,7 +179,7 @@ export interface Anoncreds { schemaFromJson(options: { json: string }): ObjectHandle - masterSecretFromJson(options: { json: string }): ObjectHandle + linkSecretFromJson(options: { json: string }): ObjectHandle credentialRequestFromJson(options: { json: string }): ObjectHandle diff --git a/wrappers/javascript/anoncreds-shared/src/api/Credential.ts b/wrappers/javascript/anoncreds-shared/src/api/Credential.ts index 86717a2c..71296a12 100644 --- a/wrappers/javascript/anoncreds-shared/src/api/Credential.ts +++ b/wrappers/javascript/anoncreds-shared/src/api/Credential.ts @@ -10,7 +10,7 @@ import { CredentialDefinitionPrivate } from './CredentialDefinitionPrivate' import { CredentialOffer } from './CredentialOffer' import { CredentialRequest } from './CredentialRequest' import { CredentialRequestMetadata } from './CredentialRequestMetadata' -import { MasterSecret } from './MasterSecret' +import { LinkSecret } from './LinkSecret' import { RevocationRegistryDefinition } from './RevocationRegistryDefinition' import { RevocationStatusList } from './RevocationStatusList' import { pushToArray } from './utils' @@ -29,7 +29,7 @@ export type CreateCredentialOptions = { export type ProcessCredentialOptions = { credentialRequestMetadata: CredentialRequestMetadata | JsonObject - masterSecret: MasterSecret | JsonObject + linkSecret: LinkSecret | JsonObject credentialDefinition: CredentialDefinition | JsonObject revocationRegistryDefinition?: RevocationRegistryDefinition | JsonObject } @@ -103,10 +103,10 @@ export class Credential extends AnoncredsObject { ? options.credentialRequestMetadata.handle : pushToArray(CredentialRequestMetadata.fromJson(options.credentialRequestMetadata).handle, objectHandles) - const masterSecret = - options.masterSecret instanceof MasterSecret - ? options.masterSecret.handle - : pushToArray(MasterSecret.fromJson(options.masterSecret).handle, objectHandles) + const linkSecret = + options.linkSecret instanceof LinkSecret + ? options.linkSecret.handle + : pushToArray(LinkSecret.fromJson(options.linkSecret).handle, objectHandles) const revocationRegistryDefinition = options.revocationRegistryDefinition instanceof RevocationRegistryDefinition @@ -122,7 +122,7 @@ export class Credential extends AnoncredsObject { credential: this.handle, credentialDefinition, credentialRequestMetadata, - masterSecret, + linkSecret, revocationRegistryDefinition, }) diff --git a/wrappers/javascript/anoncreds-shared/src/api/CredentialRequest.ts b/wrappers/javascript/anoncreds-shared/src/api/CredentialRequest.ts index 36621f5b..bb3be61b 100644 --- a/wrappers/javascript/anoncreds-shared/src/api/CredentialRequest.ts +++ b/wrappers/javascript/anoncreds-shared/src/api/CredentialRequest.ts @@ -7,15 +7,15 @@ import { anoncreds } from '../register' import { CredentialDefinition } from './CredentialDefinition' import { CredentialOffer } from './CredentialOffer' import { CredentialRequestMetadata } from './CredentialRequestMetadata' -import { MasterSecret } from './MasterSecret' +import { LinkSecret } from './LinkSecret' import { pushToArray } from './utils' export type CreateCredentialRequestOptions = { entropy?: string proverDid?: string credentialDefinition: CredentialDefinition | JsonObject - masterSecret: MasterSecret | JsonObject - masterSecretId: string + linkSecret: LinkSecret | JsonObject + linkSecretId: string credentialOffer: CredentialOffer | JsonObject } @@ -33,10 +33,10 @@ export class CredentialRequest extends AnoncredsObject { ? options.credentialDefinition.handle : pushToArray(CredentialDefinition.fromJson(options.credentialDefinition).handle, objectHandles) - const masterSecret = - options.masterSecret instanceof MasterSecret - ? options.masterSecret.handle - : pushToArray(MasterSecret.fromJson(options.masterSecret).handle, objectHandles) + const linkSecret = + options.linkSecret instanceof LinkSecret + ? options.linkSecret.handle + : pushToArray(LinkSecret.fromJson(options.linkSecret).handle, objectHandles) const credentialOffer = options.credentialOffer instanceof CredentialOffer @@ -47,8 +47,8 @@ export class CredentialRequest extends AnoncredsObject { entropy: options.entropy, proverDid: options.proverDid, credentialDefinition, - masterSecret, - masterSecretId: options.masterSecretId, + linkSecret, + linkSecretId: options.linkSecretId, credentialOffer, }) } finally { diff --git a/wrappers/javascript/anoncreds-shared/src/api/MasterSecret.ts b/wrappers/javascript/anoncreds-shared/src/api/LinkSecret.ts similarity index 50% rename from wrappers/javascript/anoncreds-shared/src/api/MasterSecret.ts rename to wrappers/javascript/anoncreds-shared/src/api/LinkSecret.ts index 268d78e6..34242447 100644 --- a/wrappers/javascript/anoncreds-shared/src/api/MasterSecret.ts +++ b/wrappers/javascript/anoncreds-shared/src/api/LinkSecret.ts @@ -3,12 +3,12 @@ import type { JsonObject } from '../types' import { AnoncredsObject } from '../AnoncredsObject' import { anoncreds } from '../register' -export class MasterSecret extends AnoncredsObject { +export class LinkSecret extends AnoncredsObject { public static create() { - return new MasterSecret(anoncreds.createMasterSecret().handle) + return new LinkSecret(anoncreds.createLinkSecret().handle) } public static fromJson(json: JsonObject) { - return new MasterSecret(anoncreds.masterSecretFromJson({ json: JSON.stringify(json) }).handle) + return new LinkSecret(anoncreds.linkSecretFromJson({ json: JSON.stringify(json) }).handle) } } diff --git a/wrappers/javascript/anoncreds-shared/src/api/Presentation.ts b/wrappers/javascript/anoncreds-shared/src/api/Presentation.ts index 9875cd7c..207f7025 100644 --- a/wrappers/javascript/anoncreds-shared/src/api/Presentation.ts +++ b/wrappers/javascript/anoncreds-shared/src/api/Presentation.ts @@ -9,7 +9,7 @@ import { anoncreds } from '../register' import { Credential } from './Credential' import { CredentialDefinition } from './CredentialDefinition' import { CredentialRevocationState } from './CredentialRevocationState' -import { MasterSecret } from './MasterSecret' +import { LinkSecret } from './LinkSecret' import { PresentationRequest } from './PresentationRequest' import { RevocationRegistryDefinition } from './RevocationRegistryDefinition' import { Schema } from './Schema' @@ -48,7 +48,7 @@ export type CreatePresentationOptions = { credentials: CredentialEntry[] credentialsProve: CredentialProve[] selfAttest: Record - masterSecret: MasterSecret | JsonObject + linkSecret: LinkSecret | JsonObject schemas: Record credentialDefinitions: Record } @@ -73,10 +73,10 @@ export class Presentation extends AnoncredsObject { ? options.presentationRequest.handle : pushToArray(PresentationRequest.fromJson(options.presentationRequest).handle, objectHandles) - const masterSecret = - options.masterSecret instanceof MasterSecret - ? options.masterSecret.handle - : pushToArray(MasterSecret.fromJson(options.masterSecret).handle, objectHandles) + const linkSecret = + options.linkSecret instanceof LinkSecret + ? options.linkSecret.handle + : pushToArray(LinkSecret.fromJson(options.linkSecret).handle, objectHandles) presentationHandle = anoncreds.createPresentation({ presentationRequest, @@ -96,7 +96,7 @@ export class Presentation extends AnoncredsObject { })), credentialsProve: options.credentialsProve, selfAttest: options.selfAttest, - masterSecret, + linkSecret, schemas: Object.entries(options.schemas).reduce>((prev, [id, object]) => { const objectHandle = object instanceof Schema ? object.handle : pushToArray(Schema.fromJson(object).handle, objectHandles) diff --git a/wrappers/javascript/anoncreds-shared/src/api/index.ts b/wrappers/javascript/anoncreds-shared/src/api/index.ts index 2fbe021c..23c7650c 100644 --- a/wrappers/javascript/anoncreds-shared/src/api/index.ts +++ b/wrappers/javascript/anoncreds-shared/src/api/index.ts @@ -7,7 +7,7 @@ export * from './KeyCorrectnessProof' export * from './CredentialOffer' export * from './CredentialRequest' export * from './CredentialRequestMetadata' -export * from './MasterSecret' +export * from './LinkSecret' export * from './PresentationRequest' export * from './Presentation' export * from './Schema' diff --git a/wrappers/python/anoncreds/__init__.py b/wrappers/python/anoncreds/__init__.py index f29b81d9..61e5ab5b 100644 --- a/wrappers/python/anoncreds/__init__.py +++ b/wrappers/python/anoncreds/__init__.py @@ -12,7 +12,7 @@ CredentialOffer, CredentialRequest, CredentialRequestMetadata, - MasterSecret, + LinkSecret, PresentationRequest, Presentation, PresentCredentials, @@ -38,7 +38,7 @@ "CredentialOffer", "CredentialRequest", "CredentialRequestMetadata", - "MasterSecret", + "LinkSecret", "PresentationRequest", "Presentation", "PresentCredentials", diff --git a/wrappers/python/anoncreds/bindings.py b/wrappers/python/anoncreds/bindings.py index d520c743..50fd0078 100644 --- a/wrappers/python/anoncreds/bindings.py +++ b/wrappers/python/anoncreds/bindings.py @@ -578,7 +578,7 @@ def encode_credential_attributes( def process_credential( cred: ObjectHandle, cred_req_metadata: ObjectHandle, - master_secret: ObjectHandle, + link_secret: ObjectHandle, cred_def: ObjectHandle, rev_reg_def: Optional[ObjectHandle], ) -> ObjectHandle: @@ -587,7 +587,7 @@ def process_credential( "anoncreds_process_credential", cred, cred_req_metadata, - master_secret, + link_secret, cred_def, rev_reg_def or ObjectHandle(), byref(result), @@ -632,8 +632,8 @@ def create_credential_offer( def create_credential_request( prover_did: Optional[str], cred_def: ObjectHandle, - master_secret: ObjectHandle, - master_secret_id: str, + link_secret: ObjectHandle, + link_secret_id: str, cred_offer: ObjectHandle, ) -> Tuple[ObjectHandle, ObjectHandle]: cred_req, cred_req_metadata = ObjectHandle(), ObjectHandle() @@ -641,8 +641,8 @@ def create_credential_request( "anoncreds_create_credential_request", encode_str(prover_did), cred_def, - master_secret, - encode_str(master_secret_id), + link_secret, + encode_str(link_secret_id), cred_offer, byref(cred_req), byref(cred_req_metadata), @@ -650,10 +650,10 @@ def create_credential_request( return (cred_req, cred_req_metadata) -def create_master_secret() -> ObjectHandle: +def create_link_secret() -> ObjectHandle: secret = ObjectHandle() do_call( - "anoncreds_create_master_secret", + "anoncreds_create_link_secret", byref(secret), ) return secret @@ -664,7 +664,7 @@ def create_presentation( credentials: Sequence[CredentialEntry], credentials_prove: Sequence[CredentialProve], self_attest: Mapping[str, str], - master_secret: ObjectHandle, + link_secret: ObjectHandle, schemas: Sequence[ObjectHandle], schema_ids: Sequence[str], cred_defs: Sequence[ObjectHandle], @@ -684,7 +684,7 @@ def create_presentation( prove_list, FfiStrList.create(self_attest.keys()), FfiStrList.create(self_attest.values()), - master_secret, + link_secret, FfiObjectHandleList.create(schemas), FfiStrList.create(schema_ids), FfiObjectHandleList.create(cred_defs), diff --git a/wrappers/python/anoncreds/types.py b/wrappers/python/anoncreds/types.py index a9f6e45c..4c528b66 100644 --- a/wrappers/python/anoncreds/types.py +++ b/wrappers/python/anoncreds/types.py @@ -108,21 +108,21 @@ def create( cls, prover_did: Optional[str], cred_def: Union[str, CredentialDefinition], - master_secret: Union[str, "MasterSecret"], - master_secret_id: str, + link_secret: Union[str, "LinkSecret"], + link_secret_id: str, cred_offer: Union[str, CredentialOffer], ) -> Tuple["CredentialRequest", "CredentialRequestMetadata"]: if not isinstance(cred_def, bindings.AnoncredsObject): cred_def = CredentialDefinition.load(cred_def) - if not isinstance(master_secret, bindings.AnoncredsObject): - master_secret = MasterSecret.load(master_secret) + if not isinstance(link_secret, bindings.AnoncredsObject): + link_secret = LinkSecret.load(link_secret) if not isinstance(cred_offer, bindings.AnoncredsObject): cred_offer = CredentialOffer.load(cred_offer) cred_def, cred_def_metadata = bindings.create_credential_request( prover_did, cred_def.handle, - master_secret.handle, - master_secret_id, + link_secret.handle, + link_secret_id, cred_offer.handle, ) return CredentialRequest(cred_def), CredentialRequestMetadata(cred_def_metadata) @@ -146,15 +146,15 @@ def load( ) -class MasterSecret(bindings.AnoncredsObject): +class LinkSecret(bindings.AnoncredsObject): @classmethod - def create(cls) -> "MasterSecret": - return MasterSecret(bindings.create_master_secret()) + def create(cls) -> "LinkSecret": + return LinkSecret(bindings.create_link_secret()) @classmethod - def load(cls, value: Union[dict, str, bytes, memoryview]) -> "MasterSecret": - return MasterSecret( - bindings._object_from_json("anoncreds_master_secret_from_json", value) + def load(cls, value: Union[dict, str, bytes, memoryview]) -> "LinkSecret": + return LinkSecret( + bindings._object_from_json("anoncreds_link_secret_from_json", value) ) @@ -220,14 +220,14 @@ def create( def process( self, cred_req_metadata: Union[str, CredentialRequestMetadata], - master_secret: Union[str, MasterSecret], + link_secret: Union[str, LinkSecret], cred_def: Union[str, CredentialDefinition], rev_reg_def: Optional[Union[str, "RevocationRegistryDefinition"]] = None, ) -> "Credential": if not isinstance(cred_req_metadata, bindings.AnoncredsObject): cred_req_metadata = CredentialRequestMetadata.load(cred_req_metadata) - if not isinstance(master_secret, bindings.AnoncredsObject): - master_secret = MasterSecret.load(master_secret) + if not isinstance(link_secret, bindings.AnoncredsObject): + link_secret = LinkSecret.load(link_secret) if not isinstance(cred_def, bindings.AnoncredsObject): cred_def = CredentialDefinition.load(cred_def) if rev_reg_def and not isinstance(rev_reg_def, bindings.AnoncredsObject): @@ -236,7 +236,7 @@ def process( bindings.process_credential( self.handle, cred_req_metadata.handle, - master_secret.handle, + link_secret.handle, cred_def.handle, rev_reg_def.handle if rev_reg_def else None, ) @@ -358,14 +358,14 @@ def create( pres_req: Union[str, PresentationRequest], present_creds: PresentCredentials, self_attest: Optional[Mapping[str, str]], - master_secret: Union[str, MasterSecret], + link_secret: Union[str, LinkSecret], schemas: Mapping[str, Union[str, Schema]], cred_defs: Mapping[str, Union[str, CredentialDefinition]], ) -> "Presentation": if not isinstance(pres_req, bindings.AnoncredsObject): pres_req = PresentationRequest.load(pres_req) - if not isinstance(master_secret, bindings.AnoncredsObject): - master_secret = MasterSecret.load(master_secret) + if not isinstance(link_secret, bindings.AnoncredsObject): + link_secret = LinkSecret.load(link_secret) schema_ids = list(schemas.keys()) cred_def_ids = list(cred_defs.keys()) schemas = [ @@ -406,7 +406,7 @@ def create( creds, creds_prove, self_attest, - master_secret.handle, + link_secret.handle, schemas, schema_ids, cred_defs, diff --git a/wrappers/python/demo/test.py b/wrappers/python/demo/test.py index 8ac04652..072cf493 100644 --- a/wrappers/python/demo/test.py +++ b/wrappers/python/demo/test.py @@ -11,7 +11,7 @@ PresentationRequest, Presentation, PresentCredentials, - MasterSecret, + LinkSecret, RevocationRegistryDefinition, Schema, ) @@ -41,13 +41,13 @@ rev_reg_init_list, ) = RevocationRegistryDefinition.create(cred_def_id, cred_def, "default", "CL_ACCUM", 100) -master_secret = MasterSecret.create() -master_secret_id = "my id" +link_secret = LinkSecret.create() +link_secret_id = "my id" cred_offer = CredentialOffer.create(schema_id, cred_def_id, key_proof) cred_req, cred_req_metadata = CredentialRequest.create( - None, cred_def, master_secret, master_secret_id, cred_offer + None, cred_def, link_secret, link_secret_id, cred_offer ) issuer_rev_index = 1 @@ -70,7 +70,7 @@ ), ) -cred_received = cred.process(cred_req_metadata, master_secret, cred_def, rev_reg_def) +cred_received = cred.process(cred_req_metadata, link_secret, cred_def, rev_reg_def) timestamp = int(time()) @@ -106,7 +106,7 @@ ) presentation = Presentation.create( - pres_req, present_creds, {}, master_secret, {schema_id: schema}, {cred_def_id: cred_def} + pres_req, present_creds, {}, link_secret, {schema_id: schema}, {cred_def_id: cred_def} ) # verified = presentation.verify( @@ -135,7 +135,7 @@ # cred_received, "reft", reveal=True, timestamp=timestamp, rev_state=rev_state # ) # presentation_2 = Presentation.create( -# pres_req, present_creds, {}, master_secret, [schema], [cred_def] +# pres_req, present_creds, {}, link_secret, [schema], [cred_def] # ) # # verified = presentation.verify(