-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8785ec3
commit 39d9056
Showing
11 changed files
with
449 additions
and
121 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,39 +19,44 @@ edition = "2021" | |
rust-version = "1.76.0" | ||
|
||
[workspace.dependencies] | ||
did_manager = { git = "https://[email protected]/impierce/did-manager.git", tag = "v1.0.0-beta.3" } | ||
siopv2 = { git = "https://[email protected]/impierce/openid4vc.git", rev = "b4b7a56" } | ||
oid4vci = { git = "https://[email protected]/impierce/openid4vc.git", rev = "b4b7a56" } | ||
oid4vc-core = { git = "https://[email protected]/impierce/openid4vc.git", rev = "b4b7a56" } | ||
oid4vc-manager = { git = "https://[email protected]/impierce/openid4vc.git", rev = "b4b7a56" } | ||
oid4vp = { git = "https://[email protected]/impierce/openid4vc.git", rev = "b4b7a56" } | ||
# did_manager = { git = "https://[email protected]/impierce/did-manager.git", tag = "v1.0.0-beta.3" } | ||
did_manager = { git = "https://[email protected]/impierce/did-manager.git", rev = "c1cfda0" } | ||
# siopv2 = { path = "../openid4vc/siopv2" } | ||
# oid4vci = { path = "../openid4vc/oid4vci"} | ||
# oid4vc-core = { path = "../openid4vc/oid4vc-core"} | ||
# oid4vci = { path = "../openid4vc/oid4vci" } | ||
# oid4vc-core = { path = "../openid4vc/oid4vc-core" } | ||
# oid4vc-manager = { path = "../openid4vc/oid4vc-manager" } | ||
# oid4vp = { path = "../openid4vc/oid4vp" } | ||
siopv2 = { git = "https://[email protected]/impierce/openid4vc.git", rev = "bc4d6d2" } | ||
oid4vci = { git = "https://[email protected]/impierce/openid4vc.git", rev = "bc4d6d2" } | ||
oid4vc-core = { git = "https://[email protected]/impierce/openid4vc.git", rev = "bc4d6d2" } | ||
oid4vc-manager = { git = "https://[email protected]/impierce/openid4vc.git", rev = "bc4d6d2" } | ||
oid4vp = { git = "https://[email protected]/impierce/openid4vc.git", rev = "bc4d6d2" } | ||
|
||
async-trait = "0.1" | ||
axum = { version = "0.7", features = ["tracing"] } | ||
base64 = "0.22" | ||
cqrs-es = "0.4.2" | ||
futures = "0.3" | ||
identity_core = "1.3" | ||
identity_credential = { version = "1.3", default-features = false, features = [ | ||
identity_core = { git = "https://github.com/impierce/identity.rs", branch = "fix/compile-fixes" } | ||
identity_credential = { git = "https://github.com/impierce/identity.rs", branch = "fix/compile-fixes", default-features = false, features = [ | ||
"validator", | ||
"credential", | ||
"presentation", | ||
"domain-linkage", | ||
"sd-jwt-vc" | ||
] } | ||
identity_did = { version = "1.3" } | ||
identity_iota = { version = "1.3" } | ||
identity_verification = { version = "1.3", default-features = false } | ||
|
||
identity_did = { git = "https://github.com/impierce/identity.rs", branch = "fix/compile-fixes" } | ||
identity_document = { git = "https://github.com/impierce/identity.rs", branch = "fix/compile-fixes" } | ||
identity_iota = { git = "https://github.com/impierce/identity.rs", branch = "fix/compile-fixes" } | ||
identity_verification = { git = "https://github.com/impierce/identity.rs", branch = "fix/compile-fixes", default-features = false } | ||
jsonwebtoken = "9.3" | ||
lazy_static = "1.4" | ||
mime = { version = "0.3" } | ||
once_cell = { version = "1.19" } | ||
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] } | ||
rstest = "0.22" | ||
sd-jwt-payload-rework = { package = "sd-jwt-payload", git = "https://github.com/iotaledger/sd-jwt-payload.git", rev = "0300fc5", default-features = false, features = ["sha"] } | ||
serde = { version = "1.0", default-features = false, features = ["derive"] } | ||
serde_json = { version = "1.0" } | ||
serde_with = "3.7" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,50 @@ | ||
use std::str::FromStr as _; | ||
|
||
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine as _}; | ||
use identity_iota::{ | ||
core::{FromJson as _, ToJson as _}, | ||
verification::{ | ||
jwk::Jwk, | ||
jws::{JwsVerifier, SignatureVerificationError, VerificationInput}, | ||
}, | ||
use identity_iota::core::{FromJson as _, ToJson as _}; | ||
use identity_iota::verification; | ||
use identity_iota::verification::jws::{ | ||
JwsVerifier, SignatureVerificationError, SignatureVerificationErrorKind, VerificationInput, | ||
}; | ||
use jsonwebtoken::{crypto::verify, Algorithm, DecodingKey, Validation}; | ||
use jsonwebtoken::crypto::verify; | ||
use jsonwebtoken::{Algorithm, DecodingKey, Validation}; | ||
|
||
/// This `Verifier` uses `jsonwebtoken` under the hood to verify verification input. | ||
pub struct Verifier; | ||
impl JwsVerifier for Verifier { | ||
fn verify(&self, input: VerificationInput, public_key: &Jwk) -> Result<(), SignatureVerificationError> { | ||
let algorithm = Algorithm::from_str(&input.alg.to_string()).unwrap(); | ||
fn verify( | ||
&self, | ||
input: VerificationInput, | ||
public_key: &verification::jwk::Jwk, | ||
) -> Result<(), SignatureVerificationError> { | ||
use SignatureVerificationErrorKind::*; | ||
|
||
println!("public_key: {:?}", public_key); | ||
let algorithm = | ||
Algorithm::from_str(&input.alg.to_string()).map_err(|_| SignatureVerificationError::new(UnsupportedAlg))?; | ||
|
||
// Convert the `Jwk` first into a `jsonwebtoken::jwk::Jwk` and then into a `DecodingKey`. | ||
// Convert the `IotaIdentityJwk` first into a `jsonwebtoken::Jwk` and then into a `DecodingKey`. | ||
let decoding_key = public_key | ||
.to_json() | ||
.ok() | ||
.and_then(|public_key| jsonwebtoken::jwk::Jwk::from_json(&public_key).ok()) | ||
.and_then(|jwk| DecodingKey::from_jwk(&jwk).ok()) | ||
.unwrap(); | ||
.ok_or(SignatureVerificationError::new(KeyDecodingFailure))?; | ||
|
||
let mut validation = Validation::new(algorithm); | ||
validation.validate_aud = false; | ||
validation.required_spec_claims.clear(); | ||
|
||
println!("validation: {:?}", validation); | ||
|
||
verify( | ||
match verify( | ||
&URL_SAFE_NO_PAD.encode(input.decoded_signature), | ||
&input.signing_input, | ||
&decoding_key, | ||
algorithm, | ||
) | ||
.unwrap(); | ||
|
||
Ok(()) | ||
) { | ||
Ok(_) => Ok(()), | ||
Err(_) => Err(SignatureVerificationError::new( | ||
// TODO: more fine-grained error handling? | ||
InvalidSignature, | ||
)), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters