diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0bdda9af..20b19fd7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -143,7 +143,7 @@ jobs: if: ${{ runner.os == 'Linux' }} run: | if [ -n "${{ matrix.use_cross }}" ]; then - cargo install --git https://github.com/cross-rs/cross --tag v${{ env.CROSS_VERSION }} cross + cargo install --locked --git https://github.com/cross-rs/cross --tag v${{ env.CROSS_VERSION }} cross cross build --release --package anoncreds --target ${{matrix.target}} --features vendored else cargo build --release --package anoncreds --target ${{matrix.target}} --features vendored diff --git a/Cargo.toml b/Cargo.toml index 202c51b3..929ac597 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ vendored = ["anoncreds-clsignatures/openssl_vendored"] w3c = ["base64", "chrono"] [dependencies] -anoncreds-clsignatures = "0.2.4" +anoncreds-clsignatures = "0.3.0" bs58 = "0.4.0" env_logger = { version = "0.9.3", optional = true } ffi-support = { version = "0.4.0", optional = true } diff --git a/src/ffi/w3c/credential.rs b/src/ffi/w3c/credential.rs index 7c5210ee..a7f45119 100644 --- a/src/ffi/w3c/credential.rs +++ b/src/ffi/w3c/credential.rs @@ -1,5 +1,7 @@ use crate::data_types::w3c::VerifiableCredentialSpecVersion; -use ffi_support::FfiStr; +use ffi_support::{rust_string_to_c, FfiStr}; +use std::ffi::c_char; +use std::ptr; use crate::data_types::w3c::credential::W3CCredential; use crate::data_types::w3c::credential_attributes::CredentialAttributes; @@ -209,6 +211,36 @@ pub extern "C" fn anoncreds_w3c_credential_get_integrity_proof_details( }) } +#[no_mangle] +pub extern "C" fn anoncreds_w3c_credential_proof_get_attribute( + handle: ObjectHandle, + name: FfiStr, + result_p: *mut *const c_char, +) -> ErrorCode { + catch_error(|| { + check_useful_c_ptr!(result_p); + let cred = handle.load()?; + let cred = cred.cast_ref::()?; + let val = match name.as_opt_str().unwrap_or_default() { + "schema_id" => rust_string_to_c(cred.schema_id.clone()), + "cred_def_id" => rust_string_to_c(cred.cred_def_id.to_string()), + "rev_reg_id" => cred + .rev_reg_id + .as_ref() + .map_or(ptr::null_mut(), |s| rust_string_to_c(s.to_string())), + "rev_reg_index" => cred + .rev_reg_index + .map_or(ptr::null_mut(), |s| rust_string_to_c(s.to_string())), + "timestamp" => cred + .timestamp + .map_or(ptr::null_mut(), |s| rust_string_to_c(s.to_string())), + s => return Err(err_msg!("Unsupported attribute: {}", s)), + }; + unsafe { *result_p = val }; + Ok(()) + }) +} + impl_anoncreds_object!(CredentialProofDetails, "CredentialProofInfo"); pub(crate) fn _credential_attributes(