Skip to content

Commit

Permalink
Merge remote-tracking branch 'dsr/anoncreds-w3c-format-changes' into …
Browse files Browse the repository at this point in the history
…anoncreds-w3c-encoding

# Conflicts:
#	src/data_types/w3c/proof.rs
#	src/services/w3c/verifier.rs
  • Loading branch information
Artemkaaas committed Dec 20, 2023
2 parents 7c9939d + a2a178e commit 668b466
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -358,7 +358,7 @@ jobs:

- name: Build
run: |
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 --target ${{ matrix.target }} --features=vendored
- name: Upload artifacts
Expand Down
34 changes: 33 additions & 1 deletion src/ffi/w3c/credential.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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::<CredentialProofDetails>()?;
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(
Expand Down

0 comments on commit 668b466

Please sign in to comment.