Skip to content

Commit

Permalink
fix(credential-eip712): compatibility improvements for EthereumEIP712…
Browse files Browse the repository at this point in the history
…Signature2021 (#1131)
  • Loading branch information
mirceanis authored Feb 22, 2023
1 parent abfba31 commit 672f92b
Show file tree
Hide file tree
Showing 10 changed files with 610 additions and 66 deletions.
42 changes: 42 additions & 0 deletions __tests__/fixtures/cred1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"id": "http://example.com/credentials/3527",
"name": "begd",
"type": [
"VerifiableCredential",
"OpenBadgeCredential"
],
"proof": {
"type": "Ed25519Signature2020",
"created": "2023-02-11T02:40:43.841Z",
"@context": [
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"proofValue": "z3JLZ5fbUY4J4XyaaVhTyHaC5djPHKVgGYKF8necUHJhZi1Z9aNFvittgA5NkQ3obbVj5DiAD4GwfyxtSovBnWVAt",
"proofPurpose": "assertionMethod",
"verificationMethod": "did:key:z6MkqqPLdAy3mL5JFHEBmpuj7NjTEPnMifr2kz83XsbbgkyY#z6MkqqPLdAy3mL5JFHEBmpuj7NjTEPnMifr2kz83XsbbgkyY"
},
"issuer": "did:key:z6MkqqPLdAy3mL5JFHEBmpuj7NjTEPnMifr2kz83XsbbgkyY",
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://purl.imsglobal.org/spec/ob/v3p0/context.json"
],
"issuanceDate": "2023-02-11T02:40:43.832Z",
"credentialSubject": {
"id": "did:key:z6MkqqPLdAy3mL5JFHEBmpuj7NjTEPnMifr2kz83XsbbgkyY",
"type": [
"AchievementSubject"
],
"achievement": {
"id": "https://example.com/achievements/21st-century-skills/teamwork",
"name": "begd",
"type": [
"Achievement"
],
"criteria": {
"narrative": "hcgij"
},
"description": "ghfh",
"achievementType": "License"
}
}
}
185 changes: 185 additions & 0 deletions __tests__/fixtures/cred2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{
"id": "ceramic://kjzl6cwe1jw14amq2gh9w54p7mqkyvudy8z1bexw1w9b9vw3ikac6ahwhyurrll",
"_type": [
"VerifiableCredential",
"CredScoreGTEGood",
"Credit",
"Borrowing",
"Finance",
"DeFi",
"WorkExperience"
],
"proof": {
"type": "EthereumEip712Signature2021",
"eip712": {
"types": {
"Issuer": [
{
"name": "id",
"type": "string"
},
{
"name": "ethereumAddress",
"type": "address"
}
],
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"CredentialSchema": [
{
"name": "id",
"type": "string"
},
{
"name": "_type",
"type": "string"
}
],
"CredentialSubject": [
{
"name": "id",
"type": "string"
},
{
"name": "ethereumAddress",
"type": "address"
},
{
"name": "_type",
"type": "string"
},
{
"name": "typeSchema",
"type": "string"
},
{
"name": "value",
"type": "string"
},
{
"name": "encrypted",
"type": "string"
},
{
"name": "trust",
"type": "uint8"
},
{
"name": "stake",
"type": "uint256"
},
{
"name": "price",
"type": "uint256"
},
{
"name": "nbf",
"type": "uint256"
},
{
"name": "exp",
"type": "uint256"
}
],
"VerifiableCredential": [
{
"name": "_context",
"type": "string"
},
{
"name": "_type",
"type": "string"
},
{
"name": "id",
"type": "string"
},
{
"name": "issuer",
"type": "Issuer"
},
{
"name": "credentialSubject",
"type": "CredentialSubject"
},
{
"name": "credentialSchema",
"type": "CredentialSchema"
},
{
"name": "issuanceDate",
"type": "string"
},
{
"name": "expirationDate",
"type": "string"
}
]
},
"domain": {
"name": "Krebit",
"chainId": 137,
"version": "1.0",
"verifyingContract": "0xdEb4810c8AB3f9De3F253064A40b1D0c8703fbbf"
},
"primaryType": "VerifiableCredential"
},
"created": "2023-02-10T19:19:14.884Z",
"proofValue": "0x50af66d10f4754db27218c99cb1026f66da1f1958c4be7fc0e671aa62cce5e360c3f2d9e08807a6dca3802fc6e2151e60293d4d712f7c79b069cce77b52af1721c",
"proofPurpose": "assertionMethod",
"ethereumAddress": "0x5AFd488fe9843E51db54B2262F247572926aea5F",
"verificationMethod": "did:pkh:eip155:1:0x5afd488fe9843e51db54b2262f247572926aea5f#ethereumAddress"
},
"issuer": {
"id": "did:pkh:eip155:1:0x5afd488fe9843e51db54b2262f247572926aea5f",
"ethereumAddress": "0x5AFd488fe9843E51db54B2262F247572926aea5F"
},
"_context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/eip712sig-2021"
],
"issuanceDate": "2023-02-10T19:14:14.881Z",
"expirationDate": "2026-02-10T19:19:14.841Z",
"credentialSchema": {
"id": "https://github.com/KrebitDAO/eip712-vc",
"type": "Eip712SchemaValidator2021"
},
"credentialSubject": {
"id": "did:pkh:eip155:1:0xee55527cf8ea371ac9d574e7e861d28a27b241a4",
"did": "did:pkh:eip155:1:0xee55527cf8ea371ac9d574e7e861d28a27b241a4",
"exp": 1770751154,
"nbf": 1676056454,
"tags": [
"Credit",
"Borrowing",
"Finance",
"DeFi",
"WorkExperience"
],
"type": "CredScoreGTEGood",
"price": 0,
"stake": 1,
"trust": 100,
"value": "{\"name\":\"Cred Protocol Score >= Good\",\"entity\":\"credprotocol.com\",\"proof\":{\"account\":\"0xEE55527CF8ea371Ac9D574E7e861D28A27b241a4\",\"creation_date_utc\":\"2023-02-10 19:19:13\",\"model_version\":\"nebula_1.0.6\",\"value\":803,\"decile\":\"4.00\",\"value_rating\":\"Good\"}}",
"encrypted": "none",
"typeSchema": "krebit://schemas/certificate",
"expirationDate": "2026-02-10T19:19:14.841Z",
"ethereumAddress": "0xee55527cf8ea371ac9d574e7e861d28a27b241a4"
}
}
136 changes: 136 additions & 0 deletions __tests__/fixtures/cred3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"id": "kjzl6cwe1jw14bn99lu4spvfdvjyxtm4cg2ys5jmd0gqjaov5fqifwlf0af3hbt-did:pkh:eip155:1:0xde695cbb6ec0cf3f4c9564070baeb032552c5111",
"type": [
"VerifiableCredential",
"EventAttendanceCredential"
],
"proof": {
"type": "EthereumEip712Signature2021",
"eip712": {
"types": {
"Issuer": [
{
"name": "id",
"type": "string"
},
{
"name": "ethereumAddress",
"type": "string"
}
],
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"CredentialSchema": [
{
"name": "id",
"type": "string"
},
{
"name": "type",
"type": "string"
}
],
"CredentialSubject": [
{
"name": "id",
"type": "string"
},
{
"name": "eventName",
"type": "string"
},
{
"name": "eventIcon",
"type": "string"
},
{
"name": "eventId",
"type": "string"
}
],
"VerifiableCredential": [
{
"name": "@context",
"type": "string[]"
},
{
"name": "type",
"type": "string[]"
},
{
"name": "id",
"type": "string"
},
{
"name": "issuer",
"type": "Issuer"
},
{
"name": "credentialSubject",
"type": "CredentialSubject"
},
{
"name": "credentialSchema",
"type": "CredentialSchema"
},
{
"name": "issuanceDate",
"type": "string"
},
{
"name": "expirationDate",
"type": "string"
}
]
},
"domain": {
"name": "Verifiable Event Attendance",
"chainId": 1,
"version": "1",
"verifyingContract": "0x00000000000000000000000000000000000000000000"
},
"primaryType": "VerifiableCredential"
},
"created": "2023-02-17T02:55:22.601Z",
"proofValue": "0xc8cd38c1ba36b2209a334de8f412a8a7f8bbc20639d981c41806444e7cc2e1396d42264957771823c5f7b3f846d141333486e0c78f88ed2d657cad3f9325a64f1c",
"proofPurpose": "assertionMethod",
"ethereumAddress": "0xf6dcc520f11ad600da7E01da44e0e70D094ea246",
"verificationMethod": "did:pkh:eip155:1:0xf6dcc520f11ad600da7e01da44e0e70d094ea246#ethereumAddress"
},
"issuer": {
"id": "did:pkh:eip155:1:0xf6dcc520f11ad600da7e01da44e0e70d094ea246",
"ethereumAddress": "0xf6dcc520f11ad600da7E01da44e0e70D094ea246"
},
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://raw.githubusercontent.com/w3c-ccg/ethereum-eip712-signature-2021-spec/main/contexts/v1/index.json"
],
"issuanceDate": "2023-02-17T02:55:22.549Z",
"expirationDate": "2123-02-17T02:55:22.549Z",
"credentialSchema": {
"id": "https://app.vess.id/schemas/EventAttendance.json",
"type": "Eip712SchemaValidator2021"
},
"credentialSubject": {
"id": "did:pkh:eip155:1:0xde695cbb6ec0cf3f4c9564070baeb032552c5111",
"eventId": "kjzl6cwe1jw14bn99lu4spvfdvjyxtm4cg2ys5jmd0gqjaov5fqifwlf0af3hbt",
"eventIcon": "https://bafybeibgqa2kti2c53vq7tajbidclxbjytsgucqjdffmc2yniepejiqs7i.ipfs.w3s.link/nec_preevent.png",
"eventName": "NEC Web3 Community Pre-Event"
}
}
29 changes: 29 additions & 0 deletions __tests__/fixtures/cred4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"type": [
"VerifiableCredential"
],
"proof": {
"jws": "eyJhbGciOiJFZERTQSIsImNyaXQiOlsiYjY0Il0sImI2NCI6ZmFsc2V9.._T9sbXJAcDPWT9WX02uT4Ky5LGGjmQoo2VeglQgxzgsfJyUfBFIahn40d0d_58UShoPOfmfDEKJvuM_2W0wJCg",
"type": "Ed25519Signature2018",
"created": "2023-02-08T20:19:52.256Z",
"proofPurpose": "assertionMethod",
"verificationMethod": "did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC#z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC"
},
"issuer": "did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC",
"@context": [
"https://www.w3.org/2018/credentials/v1"
],
"issuanceDate": "2023-02-08T20:19:52.255Z",
"expirationDate": "2023-05-09T20:19:52.255Z",
"credentialSubject": {
"id": "did:pkh:eip155:1:0xACFB657781452e50f6Bd126e01C2aEF6817a5D48",
"hash": "v0.0.0:bJHkYMu57TlOcBYT9oGiywDXSHPCidOZl0CQ2DhNJKE=",
"@context": [
{
"hash": "https://schema.org/Text",
"provider": "https://schema.org/Text"
}
],
"provider": "Github"
}
}
Loading

0 comments on commit 672f92b

Please sign in to comment.