Skip to content

Commit 415c6ff

Browse files
committed
move examples, remove workspace, update docs
1 parent 9272e1c commit 415c6ff

File tree

42 files changed

+318
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+318
-203
lines changed

Cargo.toml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[workspace]
2-
members = [".", "openid4vp-frontend", "examples/wallet-conformance-adapter", "examples/verifier-conformance-adapter", "examples/cli-verifier"]
3-
41
[package]
52
name = "openid4vp"
63
version = "0.1.0"
@@ -37,18 +34,40 @@ serde_json_path = "0.7.1"
3734
serde_urlencoded = "0.7.1"
3835
sha2 = "0.10"
3936
ssi = { version = "0.12", features = ["secp256r1"] }
37+
thiserror = "1.0.65"
4038
tokio = "1.32.0"
4139
tracing = "0.1.37"
4240
url = { version = "2.4.1", features = ["serde"] }
4341
x509-cert = "0.2.4"
44-
thiserror = "1.0.65"
4542

4643
[dev-dependencies]
44+
anyhow = "1.0"
45+
async-trait = "0.1"
46+
axum = { version = "0.7", features = ["macros"] }
47+
base64 = "0.21"
48+
chrono = { version = "0.4", features = ["serde"] }
49+
clap = { version = "4.4", features = ["derive", "env"] }
50+
did-method-key = "0.3"
4751
hex = "0.4"
52+
http = "1.1"
53+
p256 = { version = "0.13", features = ["jwk", "ecdsa"] }
54+
qrcode = "0.14"
55+
rand = "0.8"
56+
rcgen = "0.13"
57+
reqwest = { version = "0.12", features = ["rustls-tls", "json"] }
58+
serde = { version = "1.0", features = ["derive"] }
4859
serde_json = { version = "1.0", features = ["preserve_order"] }
4960
serde_path_to_error = "0.1.8"
50-
tokio = { version = "1.32.0", features = ["macros"] }
51-
did-method-key = "0.3"
61+
serde_urlencoded = "0.7"
62+
sha2 = "0.10"
63+
thiserror = "1.0"
64+
tokio = { version = "1.32.0", features = ["macros", "full"] }
65+
tower = "0.5"
66+
tower-http = { version = "0.6", features = ["cors", "trace", "timeout", "limit"] }
67+
tracing = "0.1"
68+
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
69+
url = { version = "2.5", features = ["serde"] }
70+
uuid = { version = "1.6", features = ["v4", "serde"] }
5271

5372
[target.'cfg(target_arch = "wasm32")'.dependencies]
5473
uuid = { version = "1.2", features = ["v4", "serde", "js"] }

README.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
[![Docs.rs](https://docs.rs/openid4vp/badge.svg)](https://docs.rs/openid4vp)
55
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
66

7-
### Rust implementation of the OpenID for Verifiable Presentations (OID4VP) specification.
7+
Rust implementation of the OpenID for Verifiable Presentations (OID4VP) specification.
88

9+
<!-- cargo-rdme start -->
10+
<!-- cargo-rdme end -->
911

1012
## Install
1113

@@ -24,34 +26,39 @@ cargo add openid4vp
2426

2527
## Testing
2628

27-
Ensure the `/tests/presentation-exchange` submodule is initialized, run the following in the root of the project:
29+
Ensure the `/tests/presentation-exchange` submodule is initialized by running the following in the root of the project:
2830

2931
```shell
3032
git submodule init --recursive
3133
```
3234

33-
34-
## Presentation Exchange Overview
35+
## Protocol Flow Diagram
3536

3637
```mermaid
3738
sequenceDiagram
38-
participant Holder
39+
participant Wallet
3940
participant Verifier
4041
participant Issuer
4142
42-
Verifier->>Holder: 1. Request Presentation (with Presentation Definition)
43-
Note over Holder: 2. User consents to share credentials
44-
Holder->>Holder: 3. Select appropriate credentials
45-
Holder->>Holder: 4. Create Verifiable Presentation
46-
Holder->>Holder: 5. Create Presentation Submission
47-
Holder->>Verifier: 6. Send VP Token (VP + Presentation Submission)
48-
Verifier->>Verifier: 7. Validate VP Token
43+
Verifier->>Wallet: 1. Authorization Request (Presentation Definition/DCQL)
44+
Note over Wallet: 2. User consents to share credentials
45+
Wallet->>Wallet: 3. Select appropriate credentials
46+
Wallet->>Wallet: 4. Create Verifiable Presentation
47+
Wallet->>Wallet: 5. Create Presentation Submission
48+
Wallet->>Verifier: 6. Authorization Response (VP Token + Submission)
49+
Verifier->>Verifier: 7. Validate VP Token signatures
4950
Verifier->>Issuer: 8. (Optional) Verify credential status
5051
Issuer-->>Verifier: 9. (Optional) Credential status response
51-
Verifier->>Verifier: 10. Check claims against Presentation Definition
52-
Verifier->>Holder: 11. Grant or deny access based on verification
52+
Verifier->>Verifier: 10. Verify claims against Presentation Definition
53+
Verifier->>Wallet: 11. Grant or deny access based on verification
5354
```
5455

56+
## Examples
57+
58+
Check the [`examples`](examples/) directory for complete implementations:
59+
- [`cli-verifier`](examples/cli-verifier/): Command-line verifier for testing OID4VP flows
60+
- [`verifier-conformance-adapter`](examples/verifier-conformance-adapter/): Conformance testing adapter
61+
- [`oid4vp-wallet-adapter`](examples/oid4vp-wallet-adapter/): Headless wallet adapter
5562

5663
## License
5764

examples/cli-verifier/Cargo.toml

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/cli-verifier/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A minimal command-line verifier for testing OID4VP v1.0 protocol with mobile wal
2121
ngrok http 3000
2222

2323
# Run the verifier with your ngrok URL
24-
cargo run -p cli-verifier -- --public-url https://your-url.ngrok.io
24+
cargo run --example cli-verifier -- --public-url https://your-url.ngrok.io
2525
```
2626

2727
### CLI Options
@@ -48,15 +48,15 @@ cargo run -p cli-verifier -- --public-url https://your-url.ngrok.io
4848
### Request a single mDL
4949

5050
```bash
51-
cargo run -p cli-verifier -- --public-url https://abc.ngrok.io -c mdl
51+
cargo run --example cli-verifier -- --public-url https://abc.ngrok.io -c mdl
5252
```
5353

5454
### Request multiple credentials (AND logic)
5555

5656
All credentials are required:
5757

5858
```bash
59-
cargo run -p cli-verifier -- --public-url https://abc.ngrok.io -c mdl,jwt_vc
59+
cargo run --example cli-verifier -- --public-url https://abc.ngrok.io -c mdl,jwt_vc
6060
```
6161

6262
This creates:
@@ -70,7 +70,7 @@ Wallet must present **both** credentials.
7070
Accept either LDP VC or mDL:
7171

7272
```bash
73-
cargo run -p cli-verifier -- --public-url https://abc.ngrok.io -c ldp_or_mdl
73+
cargo run --example cli-verifier -- --public-url https://abc.ngrok.io -c ldp_or_mdl
7474
```
7575

7676
This creates:
@@ -81,7 +81,7 @@ Wallet can present **either** credential.
8181
### Combine OR and AND logic
8282

8383
```bash
84-
cargo run -p cli-verifier -- --public-url https://abc.ngrok.io -c ldp_or_mdl,jwt_vc
84+
cargo run --example cli-verifier -- --public-url https://abc.ngrok.io -c ldp_or_mdl,jwt_vc
8585
```
8686

8787
This creates:
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,6 @@ fn build_client_metadata(credential_types: &[String]) -> ClientMetadata {
482482
// Per OID4VP v1.0 Section B.1.3.2.1:
483483
// "The Credential Format Identifier is `ldp_vc` to request a W3C Verifiable
484484
// Credential... or a Verifiable Presentation of such a Credential."
485-
//
486-
// So ldp_vc covers BOTH the credential AND the presentation format.
487-
// There is NO ldp_vp in the spec.
488485
vp_formats.insert(
489486
ClaimFormatDesignation::LdpVc,
490487
ClaimFormatPayload::ProofTypeValues(vec![
@@ -503,9 +500,6 @@ fn build_client_metadata(credential_types: &[String]) -> ClientMetadata {
503500
// Per OID4VP v1.0 Section B.1.3.1.1:
504501
// "The Credential Format Identifier is `jwt_vc_json` to request a W3C Verifiable
505502
// Credential... or a Verifiable Presentation of such a Credential."
506-
//
507-
// So jwt_vc_json covers BOTH the credential AND the presentation format.
508-
// There is NO jwt_vp_json in the spec.
509503
vp_formats.insert(
510504
ClaimFormatDesignation::JwtVcJson,
511505
ClaimFormatPayload::AlgValues(vec![

examples/verifier-conformance-adapter/Cargo.toml

Lines changed: 0 additions & 33 deletions
This file was deleted.

examples/verifier-conformance-adapter/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ ngrok http 3000
2121

2222
```bash
2323
# For direct_post (unencrypted)
24-
cargo run -p oid4vp-verifier-adapter -- --public-url https://YOUR_NGROK_URL.ngrok-free.app
24+
cargo run --example verifier-conformance-adapter -- --public-url https://YOUR_NGROK_URL.ngrok-free.app
2525

2626
# For direct_post.jwt (encrypted)
27-
cargo run -p oid4vp-verifier-adapter -- --public-url https://YOUR_NGROK_URL.ngrok-free.app --response-mode direct_post.jwt
27+
cargo run --example verifier-conformance-adapter -- --public-url https://YOUR_NGROK_URL.ngrok-free.app --response-mode direct_post.jwt
2828
```
2929

3030
The adapter prints the signing key configuration on startup - you'll need this for the OIDF test setup.
@@ -132,10 +132,10 @@ Go back to the OIDF conformance tool and check if the test passed.
132132

133133
```bash
134134
# Debug logging
135-
RUST_LOG=debug cargo run -p oid4vp-verifier-adapter -- --public-url https://YOUR_NGROK_URL.ngrok-free.app
135+
RUST_LOG=debug cargo run --example verifier-conformance-adapter -- --public-url https://YOUR_NGROK_URL.ngrok-free.app
136136

137137
# With encrypted responses
138-
RUST_LOG=debug cargo run -p oid4vp-verifier-adapter -- \
138+
RUST_LOG=debug cargo run --example verifier-conformance-adapter -- \
139139
--public-url https://YOUR_NGROK_URL.ngrok-free.app \
140140
--response-mode direct_post.jwt
141141
```

examples/verifier-conformance-adapter/src/crypto/jwe.rs renamed to examples/verifier-conformance-adapter/crypto/jwe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn decrypt_jwe(jwe: &str, private_key_jwk: &JWK) -> Result<Value> {
99
let jwk_str = serde_json::to_string(private_key_jwk)?;
1010
let jwk = Jwk::from_bytes(jwk_str.as_bytes()).context("Invalid private key JWK")?;
1111

12-
let decrypter = ECDH_ES
12+
let decrypter: josekit::jwe::alg::ecdh_es::EcdhEsJweDecrypter<p256::NistP256> = ECDH_ES
1313
.decrypter_from_jwk(&jwk)
1414
.context("Failed to create ECDH-ES decrypter")?;
1515

File renamed without changes.

examples/verifier-conformance-adapter/src/main.rs renamed to examples/verifier-conformance-adapter/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ mod server;
1313
use server::{create_router, AppState, OidfConfig};
1414

1515
#[derive(Parser, Debug)]
16-
#[command(name = "oid4vp-verifier-adapter")]
1716
#[command(about = "OID4VP 1.0 Verifier Adapter for Conformance Testing")]
1817
struct Args {
1918
/// Port to listen on

0 commit comments

Comments
 (0)