Skip to content

Commit

Permalink
fix processing for the combinabtion of PPID and blind sign request
Browse files Browse the repository at this point in the history
  • Loading branch information
yamdan committed Sep 28, 2023
1 parent afdd16f commit 5260e0b
Showing 1 changed file with 37 additions and 22 deletions.
59 changes: 37 additions & 22 deletions src/derive_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,28 +555,43 @@ fn build_vp(
));
}

// use PPID as holder's ID if it is given, otherwise blank node is used
let vp_holder_id: NamedOrBlankNode = if let Some(ppid) = ppid {
let nym_multibase = ark_to_base64url(&ppid.ppid)?;
NamedNode::new(format!("{}{}", PPID_PREFIX, nym_multibase))?.into()
} else {
BlankNode::default().into()
};
vp.insert(QuadRef::new(
&vp_id,
HOLDER,
&vp_holder_id,
GraphNameRef::DefaultGraph,
));

// add secret commitment if exists
if let Some(req) = blind_sign_request {
vp.insert(QuadRef::new(
&vp_holder_id,
SECRET_COMMITMENT,
LiteralRef::new_typed_literal(&ark_to_base64url(&req.commitment)?, MULTIBASE),
GraphNameRef::DefaultGraph,
));
// use PPID as holder's ID if it is given, otherwise blank node is used,
// and add secret commitment if exists
match (ppid, blind_sign_request) {
(None, None) => (),
(None, Some(req)) => {
let vp_holder_id = BlankNode::default();
vp.insert(QuadRef::new(
&vp_id,
HOLDER,
&vp_holder_id,
GraphNameRef::DefaultGraph,
));
vp.insert(QuadRef::new(
&vp_holder_id,
SECRET_COMMITMENT,
LiteralRef::new_typed_literal(&ark_to_base64url(&req.commitment)?, MULTIBASE),
GraphNameRef::DefaultGraph,
));
}
(Some(ppid), _) => {
let nym_multibase = ark_to_base64url(&ppid.ppid)?;
let vp_holder_id = NamedNode::new(format!("{}{}", PPID_PREFIX, nym_multibase))?;
vp.insert(QuadRef::new(
&vp_id,
HOLDER,
&vp_holder_id,
GraphNameRef::DefaultGraph,
));
if let Some(req) = blind_sign_request {
vp.insert(QuadRef::new(
&vp_holder_id,
SECRET_COMMITMENT,
LiteralRef::new_typed_literal(&ark_to_base64url(&req.commitment)?, MULTIBASE),
GraphNameRef::DefaultGraph,
));
}
}
}

// convert disclosed VC graphs (triples) into disclosed VC dataset (quads)
Expand Down

0 comments on commit 5260e0b

Please sign in to comment.