-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #291 from DSRCorporation/anoncreds-w3c-format-changes
Reworked w3c credentials and presentations to use DataIntegrityProof instead of custom AnonCreds context
- Loading branch information
Showing
33 changed files
with
2,246 additions
and
1,909 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,43 @@ | ||
use crate::data_types::w3c::context::{Context, Contexts}; | ||
use once_cell::sync::Lazy; | ||
use serde_json::{json, Value}; | ||
use std::collections::HashSet; | ||
|
||
use crate::data_types::w3c::credential::{Contexts, Types}; | ||
use crate::data_types::w3c::credential::Types; | ||
use crate::data_types::w3c::uri::URI; | ||
|
||
// Contexts | ||
pub const W3C_CONTEXT: &str = "https://www.w3.org/2018/credentials/v1"; | ||
pub const W3C_ANONCREDS_CONTEXT: &str = "https://raw.githubusercontent.com/hyperledger/anoncreds-spec/main/data/anoncreds-w3c-context.json"; | ||
pub const W3C_VC_1_1_BASE_CONTEXT: &str = "https://www.w3.org/2018/credentials/v1"; | ||
pub const W3C_VC_2_0_BASE_CONTEXT: &str = "https://www.w3.org/ns/credentials/v2"; | ||
pub const W3C_DATA_INTEGRITY_CONTEXT: &str = "https://w3id.org/security/data-integrity/v2"; | ||
|
||
// Types | ||
pub const W3C_CREDENTIAL_TYPE: &str = "VerifiableCredential"; | ||
pub const W3C_PRESENTATION_TYPE: &str = "VerifiablePresentation"; | ||
pub const W3C_ANONCREDS_CREDENTIAL_TYPE: &str = "AnonCredsCredential"; | ||
pub const W3C_ANONCREDS_PRESENTATION_TYPE: &str = "AnonCredsPresentation"; | ||
|
||
pub(crate) static ANONCREDS_CONTEXTS: Lazy<Contexts> = Lazy::new(|| { | ||
Contexts(HashSet::from([ | ||
URI::from(W3C_CONTEXT), | ||
URI::from(W3C_ANONCREDS_CONTEXT), | ||
])) | ||
pub static ISSUER_DEPENDENT_VOCABULARY: Lazy<Value> = Lazy::new(|| { | ||
json!({ | ||
"@vocab": "https://www.w3.org/ns/credentials/issuer-dependent#" | ||
}) | ||
}); | ||
|
||
pub(crate) static ANONCREDS_CREDENTIAL_TYPES: Lazy<Types> = Lazy::new(|| { | ||
Types(HashSet::from([ | ||
String::from(W3C_CREDENTIAL_TYPE), | ||
String::from(W3C_ANONCREDS_CREDENTIAL_TYPE), | ||
])) | ||
pub(crate) static ANONCREDS_VC_1_1_CONTEXTS: Lazy<Contexts> = Lazy::new(|| { | ||
Contexts(vec![ | ||
Context::URI(URI::from(W3C_VC_1_1_BASE_CONTEXT)), | ||
Context::URI(URI::from(W3C_DATA_INTEGRITY_CONTEXT)), | ||
Context::Object(ISSUER_DEPENDENT_VOCABULARY.clone()), | ||
]) | ||
}); | ||
|
||
pub(crate) static ANONCREDS_PRESENTATION_TYPES: Lazy<Types> = Lazy::new(|| { | ||
Types(HashSet::from([ | ||
String::from(W3C_PRESENTATION_TYPE), | ||
String::from(W3C_ANONCREDS_PRESENTATION_TYPE), | ||
])) | ||
pub(crate) static ANONCREDS_VC_2_0_CONTEXTS: Lazy<Contexts> = Lazy::new(|| { | ||
Contexts(vec![ | ||
Context::URI(URI::from(W3C_VC_2_0_BASE_CONTEXT)), | ||
Context::Object(ISSUER_DEPENDENT_VOCABULARY.clone()), | ||
]) | ||
}); | ||
|
||
// Types | ||
pub const W3C_CREDENTIAL_TYPE: &str = "VerifiableCredential"; | ||
pub const W3C_PRESENTATION_TYPE: &str = "VerifiablePresentation"; | ||
|
||
pub(crate) static ANONCREDS_CREDENTIAL_TYPES: Lazy<Types> = | ||
Lazy::new(|| Types(HashSet::from([String::from(W3C_CREDENTIAL_TYPE)]))); | ||
|
||
pub(crate) static ANONCREDS_PRESENTATION_TYPES: Lazy<Types> = | ||
Lazy::new(|| Types(HashSet::from([String::from(W3C_PRESENTATION_TYPE)]))); |
Oops, something went wrong.