Skip to content

Commit

Permalink
feat: expand json-ld behave tests with ed25519
Browse files Browse the repository at this point in the history
Signed-off-by: Akiff Manji <[email protected]>
  • Loading branch information
amanji committed Jul 26, 2024
1 parent 4c54e74 commit 5063a25
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 104 deletions.
190 changes: 135 additions & 55 deletions demo/features/0453-issue-credential.feature

Large diffs are not rendered by default.

34 changes: 26 additions & 8 deletions demo/features/0454-present-proof.feature
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Feature: RFC 0454 Aries agent present proof
| Acme | --public-did --mediation --multitenant --wallet-type askar-anoncreds | --mediation --multitenant --wallet-type askar-anoncreds | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 |


@T001.2-RFC0454 @BBS
@T001.2-RFC0454
Scenario Outline: Present Proof json-ld where the prover does not propose a presentation of the proof and is acknowledged
Given we have "3" agents
| name | role | capabilities |
Expand All @@ -100,23 +100,41 @@ Feature: RFC 0454 Aries agent present proof
And "<issuer>" and "Bob" have an existing connection
And "Bob" has an issued json-ld <Schema_name> credential <Credential_data> from "<issuer>"
And "Faber" and "Bob" have an existing connection
When "Faber" sends a request for json-ld proof presentation <Proof_request> to "Bob"
When "Faber" sends a request for json-ld proof presentation <Proof_request> to "Bob" with <Sig_type>
Then "Faber" has the proof verified

@PR @Release @WalletType_Askar
Examples:
| issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request |
| Acme | --public-did --cred-type json-ld | | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 |
| issuer | Acme1_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request | Key_type | Sig_type |
| Acme | --public-did --cred-type json-ld | | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 | ed25519 | Ed25519Signature2018 |
| Acme | --public-did --cred-type json-ld | | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 | ed25519 | Ed25519Signature2020 |

@PR @Release @WalletType_Askar @BBS
Examples:
| issuer | Acme1_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request | Key_type | Sig_type |
| Acme | --public-did --cred-type json-ld | | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 | bls12381g2 | BbsBlsSignature2020 |

@Release @WalletType_Askar
Examples:
| issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request |
| Faber | --public-did --cred-type json-ld --did-exchange | --did-exchange | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 |
| issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request | Key_type | Sig_type |
| Faber | --public-did --cred-type json-ld --did-exchange | --did-exchange | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 | ed25519 | Ed25519Signature2018 |
| Faber | --public-did --cred-type json-ld --did-exchange | --did-exchange | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 | ed25519 | Ed25519Signature2020 |

@Release @WalletType_Askar @BBS
Examples:
| issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request | Key_type | Sig_type |
| Faber | --public-did --cred-type json-ld --did-exchange | --did-exchange | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 | bls12381g2 | BbsBlsSignature2020 |

@PR @Release @WalletType_Askar_AnonCreds
Examples:
| issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request |
| Faber | --public-did --cred-type json-ld --wallet-type askar-anoncreds | --wallet-type askar-anoncreds | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 |
| issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request | Key_type | Sig_type |
| Faber | --public-did --cred-type json-ld --wallet-type askar-anoncreds | --wallet-type askar-anoncreds | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 | ed25519 | Ed25519Signature2018 |
| Faber | --public-did --cred-type json-ld --wallet-type askar-anoncreds | --wallet-type askar-anoncreds | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 | ed25519 | Ed25519Signature2020 |

@PR @Release @WalletType_Askar_AnonCreds @BBS
Examples:
| issuer | Acme_capabilities | Bob_capabilities | Schema_name | Credential_data | Proof_request | Key_type | Sig_type |
| Faber | --public-did --cred-type json-ld --wallet-type askar-anoncreds | --wallet-type askar-anoncreds | driverslicense_v2 | Data_DL_MaxValues | DL_age_over_19_v2 | bls12381g2 | BbsBlsSignature2020 |


@T002-RFC0454
Expand Down
38 changes: 18 additions & 20 deletions demo/features/steps/0453-issue-credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
from behave import given, then, when
from runners.support.agent import (
DID_METHOD_KEY,
KEY_TYPE_BLS,
SIG_TYPE_BLS,
)


Expand Down Expand Up @@ -352,12 +350,12 @@ def step_impl(context, holder):
assert False


@given('"{issuer}" is ready to issue a json-ld credential for {schema_name}')
def step_impl(context, issuer, schema_name):
@given('"{issuer}" is ready to issue a json-ld credential for {schema_name} with {key_type}')
def step_impl(context, issuer, schema_name, key_type):
# create a "did:key" to use as issuer
agent = context.active_agents[issuer]

data = {"method": DID_METHOD_KEY, "options": {"key_type": KEY_TYPE_BLS}}
data = {"method": DID_METHOD_KEY, "options": {"key_type": key_type}}
new_did = agent_container_POST(
agent["agent"],
"/wallet/did/create",
Expand All @@ -368,12 +366,12 @@ def step_impl(context, issuer, schema_name):
pass


@given('"{holder}" is ready to receive a json-ld credential')
def step_impl(context, holder):
@given('"{holder}" is ready to receive a json-ld credential with {key_type}')
def step_impl(context, holder, key_type):
# create a "did:key" to use as holder identity
agent = context.active_agents[holder]

data = {"method": DID_METHOD_KEY, "options": {"key_type": KEY_TYPE_BLS}}
data = {"method": DID_METHOD_KEY, "options": {"key_type": key_type}}
new_did = agent_container_POST(
agent["agent"],
"/wallet/did/create",
Expand All @@ -385,8 +383,8 @@ def step_impl(context, holder):
pass


@when('"{issuer}" offers "{holder}" a json-ld credential with data {credential_data}')
def step_impl(context, issuer, holder, credential_data):
@when('"{issuer}" offers "{holder}" a json-ld credential with data {credential_data} with {sig_type}')
def step_impl(context, issuer, holder, credential_data, sig_type):
# initiate a cred exchange with a json-ld credential
agent = context.active_agents[issuer]
holder_agent = context.active_agents[holder]
Expand Down Expand Up @@ -418,7 +416,7 @@ def step_impl(context, issuer, holder, credential_data):
"birthDate": "1958-07-17",
},
},
"options": {"proofType": SIG_TYPE_BLS},
"options": {"proofType": sig_type},
}
},
}
Expand All @@ -434,9 +432,9 @@ def step_impl(context, issuer, holder, credential_data):


@when(
'"{issuer}" offers and deletes "{holder}" a json-ld credential with data {credential_data}'
'"{issuer}" offers and deletes "{holder}" a json-ld credential with data {credential_data} and {sig_type}'
)
def step_impl(context, issuer, holder, credential_data):
def step_impl(context, issuer, holder, credential_data, sig_type):
# initiate a cred exchange with a json-ld credential
agent = context.active_agents[issuer]
holder_agent = context.active_agents[holder]
Expand Down Expand Up @@ -481,7 +479,7 @@ def step_impl(context, issuer, holder, credential_data):
"birthDate": "1958-07-17",
},
},
"options": {"proofType": SIG_TYPE_BLS},
"options": {"proofType": sig_type},
}
},
}
Expand Down Expand Up @@ -531,9 +529,9 @@ def step_impl(context, issuer):


@when(
'"{holder}" requests a json-ld credential with data {credential_data} from "{issuer}"'
'"{holder}" requests a json-ld credential with data {credential_data} from "{issuer}" with {sig_type}'
)
def step_impl(context, issuer, holder, credential_data):
def step_impl(context, issuer, holder, credential_data, sig_type):
issuer_agent = context.active_agents[issuer]
holder_agent = context.active_agents[holder]
data = {
Expand Down Expand Up @@ -564,7 +562,7 @@ def step_impl(context, issuer, holder, credential_data):
"birthDate": "1958-07-17",
},
},
"options": {"proofType": SIG_TYPE_BLS},
"options": {"proofType": sig_type},
}
},
}
Expand All @@ -578,9 +576,9 @@ def step_impl(context, issuer, holder, credential_data):


@when(
'"{issuer}" offers "{holder}" an anoncreds credential with data {credential_data}'
'"{issuer}" offers "{holder}" an anoncreds credential with data {credential_data} with {sig_type}'
)
def step_impl(context, issuer, holder, credential_data):
def step_impl(context, issuer, holder, credential_data, sig_type):
# initiate a cred exchange with an anoncreds credential
agent = context.active_agents[issuer]
holder_agent = context.active_agents[holder]
Expand Down Expand Up @@ -612,7 +610,7 @@ def step_impl(context, issuer, holder, credential_data):
"birthDate": "1958-07-17",
},
},
"options": {"proofType": SIG_TYPE_BLS},
"options": {"proofType": sig_type},
}
},
}
Expand Down
23 changes: 4 additions & 19 deletions demo/features/steps/0454-present-proof.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
from behave import given, when, then
import json
from time import sleep
import time
from behave import when, then

from bdd_support.agent_backchannel_client import (
read_proof_req_data,
read_presentation_data,
aries_container_request_proof,
aries_container_verify_proof,
agent_container_POST,
async_sleep,
)
from runners.agent_container import AgentContainer
from runners.support.agent import (
CRED_FORMAT_INDY,
CRED_FORMAT_JSON_LD,
DID_METHOD_SOV,
DID_METHOD_KEY,
KEY_TYPE_ED255,
KEY_TYPE_BLS,
SIG_TYPE_BLS,
)


# This step is defined in another feature file
# Given "Acme" and "Bob" have an existing connection
Expand Down Expand Up @@ -105,9 +90,9 @@ def step_impl(context, verifier):


@when(
'"{verifier}" sends a request for json-ld proof presentation {request_for_proof} to "{prover}"'
'"{verifier}" sends a request for json-ld proof presentation {request_for_proof} to "{prover}" with {sig_type}'
)
def step_impl(context, verifier, request_for_proof, prover):
def step_impl(context, verifier, request_for_proof, prover, sig_type):
agent = context.active_agents[verifier]
prover_agent = context.active_agents[prover]

Expand All @@ -122,7 +107,7 @@ def step_impl(context, verifier, request_for_proof, prover):
},
"presentation_definition": {
"id": "32f54163-7166-48f1-93d8-ff217bdb0654",
"format": {"ldp_vp": {"proof_type": [SIG_TYPE_BLS]}},
"format": {"ldp_vp": {"proof_type": [sig_type]}},
"input_descriptors": [
{
"id": "citizenship_input_1",
Expand Down
1 change: 1 addition & 0 deletions demo/runners/support/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
KEY_TYPE_ED255 = "ed25519"
KEY_TYPE_BLS = "bls12381g2"
SIG_TYPE_BLS = "BbsBlsSignature2020"
SIG_TYPE_ED255 = "Ed25519Signature2020"


class repr_json:
Expand Down
6 changes: 4 additions & 2 deletions docs/demo/AliceWantsAJsonCredential.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ Now open up two browser windows to the [Faber](http://localhost:8021/api/doc) an
Using the Faber admin api, you have to create a DID with the appropriate:

- DID method ("key" or "sov")
- key type "ed25519" or "bls12381g2" (corresponding to signature types "Ed25519Signature2018" or "BbsBlsSignature2020")
- if you use DID method "sov" you must use key type "ed25519"
- if you use DID method "sov" you must use key type "ed25519"
- Either one of the following key types:
- "ed25519" (corresponding to signature types "Ed25519Signature2018" or "Ed25519Signature2020")
- "bls12381g2" (corresponding to signature type "BbsBlsSignature2020")

Note that "did:sov" must be a public DID (i.e. registered on the ledger) but "did:key" is not.

Expand Down

0 comments on commit 5063a25

Please sign in to comment.