Skip to content

Commit

Permalink
feat: add NonRevProofWarnings for verifier
Browse files Browse the repository at this point in the history
Signed-off-by: bwty <[email protected]>
  • Loading branch information
whalelephant committed Jan 19, 2023
1 parent 4637419 commit 393bbd2
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 34 deletions.
22 changes: 22 additions & 0 deletions anoncreds/src/data_types/anoncreds/rev_reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,28 @@ pub mod serde_revocation_list {
}
}

// NonRevocationProof warnings:
// - timestamps_out_of_range: all timestamps used for rev_state that are o.o.r
// this can be for request / attribute / predicate level time intervals
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct NonRevProofWarnings {
pub timestamps_out_of_range: Option<Vec<String>>,
}

impl NonRevProofWarnings {
pub fn new(referents: Vec<String>) -> Self {
if referents.is_empty() {
Self {
timestamps_out_of_range: None,
}
} else {
Self {
timestamps_out_of_range: Some(referents),
}
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
13 changes: 11 additions & 2 deletions anoncreds/src/ffi/presentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::error::{catch_error, ErrorCode};
use super::object::{AnonCredsObject, AnonCredsObjectList, ObjectHandle};
use super::util::{FfiList, FfiStrList};
use crate::data_types::anoncreds::cred_def::{CredentialDefinition, CredentialDefinitionId};
use crate::data_types::anoncreds::rev_reg::RevocationRegistryId;
use crate::data_types::anoncreds::rev_reg::{NonRevProofWarnings, RevocationRegistryId};
use crate::data_types::anoncreds::rev_reg_def::{
RevocationRegistryDefinition, RevocationRegistryDefinitionId,
};
Expand All @@ -21,6 +21,12 @@ use crate::services::{
impl_anoncreds_object!(Presentation, "Presentation");
impl_anoncreds_object_from_json!(Presentation, anoncreds_presentation_from_json);

impl_anoncreds_object!(NonRevProofWarnings, "NonRevProofWarnings");
impl_anoncreds_object_from_json!(
NonRevProofWarnings,
anoncreds_non_rev_proof_warnings_from_json
);

#[derive(Debug)]
#[repr(C)]
pub struct FfiCredentialEntry {
Expand Down Expand Up @@ -230,6 +236,7 @@ pub extern "C" fn anoncreds_verify_presentation(
rev_reg_def_ids: FfiStrList,
rev_reg_entries: FfiList<FfiRevocationEntry>,
result_p: *mut i8,
non_rev_proof_warning_p: *mut ObjectHandle,
) -> ErrorCode {
catch_error(|| {
if schemas.len() != schema_ids.len() {
Expand Down Expand Up @@ -301,7 +308,7 @@ pub extern "C" fn anoncreds_verify_presentation(
&rev_reg_def_identifiers,
)?;

let verify = verify_presentation(
let (verify, nrp) = verify_presentation(
presentation.load()?.cast_ref()?,
pres_req.load()?.cast_ref()?,
&schemas,
Expand All @@ -310,6 +317,8 @@ pub extern "C" fn anoncreds_verify_presentation(
Some(&rev_regs),
)?;
unsafe { *result_p = verify as i8 };
let nrp = ObjectHandle::create(nrp)?;
unsafe { *non_rev_proof_warning_p = nrp };
Ok(())
})
}
Loading

0 comments on commit 393bbd2

Please sign in to comment.