Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vcdm 2.0 model and context #3436

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7ba9b99
add vcdm 2.0 model and context
PatStLouis Jan 10, 2025
9879a4a
add backwards compatibility checks: limit proof type and add issuance…
PatStLouis Jan 10, 2025
262ae0a
seperate test fixtures, lint
PatStLouis Jan 10, 2025
5951683
replace issuanceDate tests
PatStLouis Jan 10, 2025
3383cd5
Merge branch 'openwallet-foundation:main' into vcdm-2.0-data-model-su…
PatStLouis Jan 14, 2025
909e187
Merge branch 'openwallet-foundation:main' into vcdm-2.0-data-model-su…
PatStLouis Jan 21, 2025
db5d959
remove askar issuanceDate sorting
PatStLouis Jan 21, 2025
b9a8049
Merge branch 'vcdm-2.0-data-model-support' of github.com:OpSecId/arie…
PatStLouis Jan 21, 2025
0025828
rename credential context constant
PatStLouis Jan 21, 2025
ede1d4b
linting
PatStLouis Jan 21, 2025
19df824
updated linting
PatStLouis Jan 21, 2025
41c7b14
remove askar sorting step
PatStLouis Jan 21, 2025
a7c4243
add vcdm 2.0 tests, fix presentation route default cryptosuite
PatStLouis Jan 21, 2025
286a18c
Fix broken tests, add v2 context to test document loader
PatStLouis Jan 21, 2025
12b8298
Lint
PatStLouis Jan 21, 2025
830201c
Debugging unit tests
PatStLouis Jan 21, 2025
c46c816
Merge branch 'openwallet-foundation:main' into vcdm-2.0-data-model-su…
PatStLouis Jan 27, 2025
efdd239
Merge branch 'vcdm-2.0-data-model-support' of github.com:OpSecId/arie…
PatStLouis Jan 27, 2025
c16c4a0
rename test function to v2
PatStLouis Jan 27, 2025
2c09df6
add list of support cryptosuites for vcdm 2.0
PatStLouis Jan 27, 2025
2f17be3
add list of supported cryptosuites for vcdm 2.0
PatStLouis Jan 27, 2025
a08d72c
fix presentation fixture
PatStLouis Jan 27, 2025
286d345
fix created format check
PatStLouis Jan 27, 2025
09d3d74
fix tset fixtures
PatStLouis Jan 27, 2025
1cfe448
lint
PatStLouis Jan 27, 2025
1765caa
add authentication proof purpose
PatStLouis Jan 27, 2025
0030342
Merge branch 'main' into vcdm-2.0-data-model-support
PatStLouis Feb 25, 2025
4e0536a
add holder proof type derivation when creating a vp
PatStLouis Feb 25, 2025
7e26e37
linting
PatStLouis Feb 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions acapy_agent/messaging/valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,11 @@ def __call__(self, value):
class CredentialContext(Validator):
"""Credential Context."""

FIRST_CONTEXT = "https://www.w3.org/2018/credentials/v1"
EXAMPLE = [FIRST_CONTEXT, "https://www.w3.org/2018/credentials/examples/v1"]
FIRST_CONTEXT = [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/ns/credentials/v2",
]
EXAMPLE = [FIRST_CONTEXT[0], "https://www.w3.org/2018/credentials/examples/v1"]

def __init__(self) -> None:
"""Initialize the instance."""
Expand All @@ -886,9 +889,9 @@ def __call__(self, value):
"""Validate input value."""
length = len(value)

if length < 1 or value[0] != CredentialContext.FIRST_CONTEXT:
if length < 1 or value[0] not in CredentialContext.FIRST_CONTEXT:
raise ValidationError(
f"First context must be {CredentialContext.FIRST_CONTEXT}"
f"First context must be one of {CredentialContext.FIRST_CONTEXT}"
)

return value
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
TEST_DID_SOV = "did:sov:LjgpST2rjsoxYegQDRm7EL"
TEST_DID_KEY = "did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL"

LD_PROOF_VC_DETAIL = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "Ed25519Signature2018",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC_DETAIL_BBS = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "BbsBlsSignature2020",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC_DETAIL_ED25519_2020 = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "Ed25519Signature2020",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
"proof": {
"proofPurpose": "assertionMethod",
"created": "2019-12-11T03:50:55",
"type": "Ed25519Signature2018",
"verificationMethod": "did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL#z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL",
"jws": "eyJhbGciOiAiRWREU0EiLCAiYjY0IjogZmFsc2UsICJjcml0IjogWyJiNjQiXX0..Q6amIrxGiSbM7Ce6DxlfwLCjVcYyclas8fMxaecspXFUcFW9DAAxKzgHx93FWktnlZjM_biitkMgZdStgvivAQ",
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,75 +43,12 @@
from ..handler import LOGGER as LD_PROOF_LOGGER
from ..handler import LDProofCredFormatHandler
from ..models.cred_detail import LDProofVCDetail

TEST_DID_SOV = "did:sov:LjgpST2rjsoxYegQDRm7EL"
TEST_DID_KEY = "did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL"

LD_PROOF_VC_DETAIL = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "Ed25519Signature2018",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC_DETAIL_BBS = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "BbsBlsSignature2020",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC_DETAIL_ED25519_2020 = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "Ed25519Signature2020",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
"proof": {
"proofPurpose": "assertionMethod",
"created": "2019-12-11T03:50:55",
"type": "Ed25519Signature2018",
"verificationMethod": "did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL#z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL",
"jws": "eyJhbGciOiAiRWREU0EiLCAiYjY0IjogZmFsc2UsICJjcml0IjogWyJiNjQiXX0..Q6amIrxGiSbM7Ce6DxlfwLCjVcYyclas8fMxaecspXFUcFW9DAAxKzgHx93FWktnlZjM_biitkMgZdStgvivAQ",
},
}
from .fixtures import (
LD_PROOF_VC_DETAIL,
LD_PROOF_VC_DETAIL_BBS,
LD_PROOF_VC_DETAIL_ED25519_2020,
LD_PROOF_VC,
)


class TestV20LDProofCredFormatHandler(IsolatedAsyncioTestCase):
Expand Down Expand Up @@ -166,7 +103,7 @@ async def test_validate_fields(self):

incorrect_detail = {
**LD_PROOF_VC_DETAIL,
"credential": {**LD_PROOF_VC_DETAIL["credential"], "issuanceDate": None},
"credential": {**LD_PROOF_VC_DETAIL["credential"], "credentialSubject": None},
}

# test incorrect proposal
Expand All @@ -184,8 +121,7 @@ async def test_validate_fields(self):
# test incorrect cred
with self.assertRaises(ValidationError):
incorrect_cred = LD_PROOF_VC.copy()
incorrect_cred.pop("issuanceDate")

incorrect_cred.pop("credentialSubject")
self.handler.validate_fields(CRED_20_ISSUE, incorrect_cred)

async def test_get_ld_proof_detail_record(self):
Expand Down
1 change: 1 addition & 0 deletions acapy_agent/vc/ld_proofs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
SECURITY_CONTEXT_URL = SECURITY_CONTEXT_V2_URL
DID_V1_CONTEXT_URL = "https://www.w3.org/ns/did/v1"
CREDENTIALS_CONTEXT_V1_URL = "https://www.w3.org/2018/credentials/v1"
CREDENTIALS_CONTEXT_V2_URL = "https://www.w3.org/ns/credentials/v2"
SECURITY_CONTEXT_BBS_URL = "https://w3id.org/security/bbs/v1"
SECURITY_CONTEXT_ED25519_2020_URL = "https://w3id.org/security/suites/ed25519-2020/v1"

Expand Down
1 change: 1 addition & 0 deletions acapy_agent/vc/ld_proofs/document_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class StaticCacheJsonLdDownloader:

CONTEXT_FILE_MAPPING = {
"https://www.w3.org/2018/credentials/v1": "credentials_context.jsonld",
"https://www.w3.org/ns/credentials/v2": "credentials_v2_context.jsonld",
"https://w3id.org/vc/status-list/2021/v1": "status_list_context.jsonld",
"https://www.w3.org/ns/did/v1": "did_documents_context.jsonld",
"https://w3id.org/security/v1": "security-v1-context.jsonld",
Expand Down
Loading
Loading