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

fix: implement ES256 verification #101

Merged
merged 57 commits into from
Aug 7, 2024
Merged

fix: implement ES256 verification #101

merged 57 commits into from
Aug 7, 2024

Conversation

nanderstabel
Copy link
Collaborator

@nanderstabel nanderstabel commented Jul 31, 2024

Description of change

Please write a summary of your changes and why you made them.

Blocked by

Links to any relevant issues

Closes #102

How the change has been tested

To test against UniMe:

UniCore

  1. Copy the file agent_application/example.config.yaml into a file named agent_application/config.yaml
  2. Replace:
signing_algorithms_supported:
  eddsa:
    preferred: true
    enabled: true

with:

signing_algorithms_supported:
  es256:
    preferred: true
    enabled: true
  1. Run the Docker container ( you might need to set the UNICORE__URL environment variable first, e.g.: http://192.168.1.127:3033):
  • cd agent_application/docker
  • docker compose up --build
  1. In a separate terminal run these commands to create a Credential Offer (again, make sure the UNICORE__URL variable is set):
  • Create a Credential
curl --location "${UNICORE__URL}/v0/credentials" --header "Content-Type: application/json" --data '{
    "offerId":"001",
    "credentialConfigurationId": "w3c_vc_credential",
    "credential": {
        "credentialSubject": {
            "first_name": "Ferris",
            "last_name": "Crabman",
            "dob": "1982-01-01"
        }
    }
}'
  • Create the Offer
curl --location "${UNICORE__URL}/v0/offers" --header 'Content-Type: application/json' --data '{
    "offerId": "001"
}'
  1. Copy the string that the endpoint returns

UniMe

  1. build UniMe from this branch: feat: add support for ES256 signature algorithm identity-wallet#236
  • cargo tauri dev
  1. Select Shenrons profile (in dev mode)
  2. Hit scan and paste the string obtained in step 5, then hit 'Process QR Code'
  3. Accept Credential

The transfer should be successful.

Extra validation

by searching through the log messages from UniCore for this:

issuer::credential: Request Body: {"format":"jwt_vc_json","credential_definition":{"type":["VerifiableCredential"]},"proof":{"proof_type":"jwt","jwt":

You can verify that the Proof of Possession JWT that UniMe sent to UniCore that its header should look something like this:

{
  "typ": "openid4vci-proof+jwt",
  "alg": "ES256", <--- ES256
  "kid": "did:jwk:eyJhbGciOiJFUzI1NiIsImNydiI6IlAtMjU2Iiwia2lkIjoiTnNxRWpJMFlyeHd0dURPTnp3OEhFMmNOZEVERnV4WUY4M3FKVE85bkI1RSIsImt0eSI6IkVDIiwieCI6Ik1YY0I1NG9xZEVnXzFQTm1Fajk0djRLVGNoS3hpN3hXckkxTVlMVTNKMjQiLCJ5IjoiSnN4WnVZTXBMSEVjeUVNalUwXzRiVGhlcDc0M1B3cWlhaFloaWxoQ2RZbyJ9#0"
}

Also when searching for

INFO HTTP Request {method=POST path="/openid4vci/credential"}: agent_api_rest: Response Body: {"credential":

you can find the actual returned credential and that its header also contains "alg": "ES256"

Definition of Done checklist

Add an x to the boxes that are relevant to your changes.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have successfully tested this change in a docker environment

@nanderstabel nanderstabel changed the title feat: implement ES256 verification fix: implement ES256 verification Jul 31, 2024
@nanderstabel nanderstabel linked an issue Jul 31, 2024 that may be closed by this pull request
1 task
@nanderstabel nanderstabel self-assigned this Jul 31, 2024
@nanderstabel nanderstabel added the Bug Something isn't working label Jul 31, 2024
@nanderstabel nanderstabel marked this pull request as ready for review July 31, 2024 13:24
Base automatically changed from feat/issuance-service to dev August 2, 2024 12:36
@nanderstabel nanderstabel merged commit 6c934b8 into dev Aug 7, 2024
2 checks passed
@nanderstabel nanderstabel deleted the feat/es256 branch August 7, 2024 21:54
berkes pushed a commit to educredentials/ssi-agent that referenced this pull request Aug 14, 2024
* refactor: undo unnecessary changes

* docs: list all config values

* refactor: rename config file

* refactor: remove example files from docker image

* refactor: merge config files

* refactor: update .dockerignore to include all Dockerfiles and .env files

* WIP: migrate from config macro to config function

* refactor: configs for `log_format` and `event_store`

* refactor: remove unused macros calls

* refactor: migrate `url` config

* refactor: `secret_manager` config

* refactor: `credential_configurations` config

* refactor: rename `DidMethodOptions`, add config for `signing_algorithms_supported`

* refactor: determine default DID method

* refactor: remove comments, load env variables

* WIP: refactor `event_publishers` config

* refactor: remove `metadata`

* refactor: remove `config!` macro

* refactor: rename `config_2` to `config`

* chore: change example logo, disable `event_publisher`, respect `default_did_method`

* chore: resolve clippy issues

* refactor: remove `set_metadata_configuration`

* refactor: remove `TEST_METADATA`

* WIP

* test: fix tests

* ci: update docker-compose

* fix: replace `localhost` with container name

* refactor: clean up code

* chore: fix unused import

* chore: remove unused deployment scripts

* refactor: read `connection_string` inside postgres module

* refactor: rename env prefix to `UNICORE`

* feat: init `IsuanceService`

* refacotr: remove unused code

* feat: add `from_jsonwebtoken_algorithm_to_jwsalgorithm` helper function

* chore: remove unused code

* feat: add `generate_stronghold` option

* feat: implement `ES256` verification

* chore: update logo URI's in example config file

* chore: remove temp stronghold file

* chore: remove `example-config.yaml` file

* chore: remove unused `identity_iota` dependencies

* refactor: remove unused 'services'

* refactor: use `from_jsonwebtoken_algorithm_to_jwsalgorithm`

* fix: reset config source to `agent_application/config.yaml`

* feat: update config files

* chore: update docker-compose file

* chore: update docker-compose file

* chore: remove commented code

* fix: don't use `example.config.yaml` by default

* fix: use `get_preferred_signing_algorithm`

* fix: add tests

---------

Co-authored-by: Daniel Mader <daniel.mader@impierce.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] UniCore does not correctly validate ES256 signed messages
2 participants