From f898dcf1a6ead00d44ef6098e92852ae6a2d5520 Mon Sep 17 00:00:00 2001 From: Lyuben Penkovski <lyuben.penkovski@vereign.com> Date: Wed, 2 Nov 2022 13:42:12 +0200 Subject: [PATCH] Update example policies because of changes for VC/VP proof functions --- .../1.0/policy.rego | 2 +- example/createProof/1.0/policy.rego | 3 --- example/createProofVC/1.0/policy.rego | 3 +++ example/createProofVP/1.0/policy.rego | 3 +++ example/hackaton/1.0/policy.rego | 20 +++++++++---------- example/publicKeysForDIDs/1.0/data.json | 2 +- example/publicKeysForDIDs/1.0/policy.rego | 2 +- example/returnDID/1.0/policy.rego | 8 ++++---- example/selfDescription/1.0/policy.rego | 2 +- example/validateVacVC/1.0/data.json | 1 - example/validateVacVC/1.0/policy.rego | 20 +++++++++---------- 11 files changed, 34 insertions(+), 32 deletions(-) delete mode 100644 example/createProof/1.0/policy.rego create mode 100644 example/createProofVC/1.0/policy.rego create mode 100644 example/createProofVP/1.0/policy.rego diff --git a/example/TrustedConnectionCredentials/1.0/policy.rego b/example/TrustedConnectionCredentials/1.0/policy.rego index ce41342..bf3b736 100644 --- a/example/TrustedConnectionCredentials/1.0/policy.rego +++ b/example/TrustedConnectionCredentials/1.0/policy.rego @@ -1,3 +1,3 @@ package example.TrustedConnectionCredentials -default allow = true \ No newline at end of file +default allow = true diff --git a/example/createProof/1.0/policy.rego b/example/createProof/1.0/policy.rego deleted file mode 100644 index 31ba7d1..0000000 --- a/example/createProof/1.0/policy.rego +++ /dev/null @@ -1,3 +0,0 @@ -package example.createProof - -_ := proof.create(input) diff --git a/example/createProofVC/1.0/policy.rego b/example/createProofVC/1.0/policy.rego new file mode 100644 index 0000000..18e71a6 --- /dev/null +++ b/example/createProofVC/1.0/policy.rego @@ -0,0 +1,3 @@ +package example.createProofVC + +_ := add_vc_proof("transit", "key1", input) diff --git a/example/createProofVP/1.0/policy.rego b/example/createProofVP/1.0/policy.rego new file mode 100644 index 0000000..860aa57 --- /dev/null +++ b/example/createProofVP/1.0/policy.rego @@ -0,0 +1,3 @@ +package example.createProofVP + +_ := add_vp_proof("did:web:example.com", "transit", "key1", input) diff --git a/example/hackaton/1.0/policy.rego b/example/hackaton/1.0/policy.rego index f781457..4ec799d 100644 --- a/example/hackaton/1.0/policy.rego +++ b/example/hackaton/1.0/policy.rego @@ -7,22 +7,22 @@ default expired = false default valid = false trusted { - m := input.issuer - m in data.trustlist + m := input.issuer + m in data.trustlist } expired { - exp:= time.parse_ns("2006-01-02T15:04:05Z07:00",input.expirationDate) - now:=time.now_ns() - now>exp + exp:= time.parse_ns("2006-01-02T15:04:05Z07:00",input.expirationDate) + now:=time.now_ns() + now>exp } valid = semanticallyValid(input) semanticallyValid(i) = res { - now:=time.now_ns() - vac:= data.vaccines[i.credentialSubject.vaccine.vacCode].active == true - vacDate:=time.parse_ns("2006-01-02T15:04:05Z07:00",i.credentialSubject.dateOfVaccination) - vacStillValid:=now < (vacDate+15552000000000000) - res := vac == vacStillValid + now:=time.now_ns() + vac:= data.vaccines[i.credentialSubject.vaccine.vacCode].active == true + vacDate:=time.parse_ns("2006-01-02T15:04:05Z07:00",i.credentialSubject.dateOfVaccination) + vacStillValid:=now < (vacDate+15552000000000000) + res := vac == vacStillValid } diff --git a/example/publicKeysForDIDs/1.0/data.json b/example/publicKeysForDIDs/1.0/data.json index c8cca05..f57a60e 100644 --- a/example/publicKeysForDIDs/1.0/data.json +++ b/example/publicKeysForDIDs/1.0/data.json @@ -3,4 +3,4 @@ "did:key:z6MkpxjNepTaD1xo49dEbbW36FguWgsiToxNdhR8YJMnFQoJ", "did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6" ] -} \ No newline at end of file +} diff --git a/example/publicKeysForDIDs/1.0/policy.rego b/example/publicKeysForDIDs/1.0/policy.rego index 30ba5de..310f529 100644 --- a/example/publicKeysForDIDs/1.0/policy.rego +++ b/example/publicKeysForDIDs/1.0/policy.rego @@ -6,4 +6,4 @@ getKeys(i) = res { doc1 = did.resolve(data.dids[0]) doc2 = did.resolve(data.dids[1]) res := array.concat([doc1.didDocument.verificationMethod[0].publicKeyMultibase], [doc2.didDocument.verificationMethod[0].publicKeyMultibase]) -} \ No newline at end of file +} diff --git a/example/returnDID/1.0/policy.rego b/example/returnDID/1.0/policy.rego index 3fc575d..2bb67fa 100644 --- a/example/returnDID/1.0/policy.rego +++ b/example/returnDID/1.0/policy.rego @@ -1,7 +1,7 @@ package example.returnDID -_ := { - "@context": ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/suites/ed25519-2020/v1"], - "id": issuer().did, - "verificationMethod": keys.getAll() +_ = { + "@context": ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/suites/jws-2020/v1"], + "id": "did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation", + "verificationMethod": verification_methods("did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation", "transit") } \ No newline at end of file diff --git a/example/selfDescription/1.0/policy.rego b/example/selfDescription/1.0/policy.rego index 760e80e..031208d 100644 --- a/example/selfDescription/1.0/policy.rego +++ b/example/selfDescription/1.0/policy.rego @@ -1,3 +1,3 @@ package example.selfDescription -_ := cache.get(input.key, input.scope, input.namespace) \ No newline at end of file +_ := cache.get(input.key, input.scope, input.namespace) diff --git a/example/validateVacVC/1.0/data.json b/example/validateVacVC/1.0/data.json index 41aa007..93e24b1 100644 --- a/example/validateVacVC/1.0/data.json +++ b/example/validateVacVC/1.0/data.json @@ -15,6 +15,5 @@ "medicinalProductName": "Pfizer–BioNTech COVID-19 vaccine", "marketingAuthorizationHolder": "Pfizer–BioNTech" } - } } diff --git a/example/validateVacVC/1.0/policy.rego b/example/validateVacVC/1.0/policy.rego index 161cb45..06fcbef 100644 --- a/example/validateVacVC/1.0/policy.rego +++ b/example/validateVacVC/1.0/policy.rego @@ -7,22 +7,22 @@ default expired = false default valid = false trusted { - m := input.issuer - m in data.trustlist + m := input.issuer + m in data.trustlist } expired { - exp:= time.parse_ns("2006-01-02T15:04:05Z07:00",input.expirationDate) - now:=time.now_ns() - now>exp + exp:= time.parse_ns("2006-01-02T15:04:05Z07:00",input.expirationDate) + now:=time.now_ns() + now>exp } valid = semanticallyValid(input) semanticallyValid(i) = res { - now:=time.now_ns() - vac:= data.vaccines[i.credentialSubject.vaccine.vacCode].active == true - vacDate:=time.parse_ns("2006-01-02T15:04:05Z07:00",i.credentialSubject.dateOfVaccination) - vacStillValid:=now < (vacDate+15552000000000000) - res := vac == vacStillValid + now:=time.now_ns() + vac:= data.vaccines[i.credentialSubject.vaccine.vacCode].active == true + vacDate:=time.parse_ns("2006-01-02T15:04:05Z07:00",i.credentialSubject.dateOfVaccination) + vacStillValid:=now < (vacDate+15552000000000000) + res := vac == vacStillValid } -- GitLab