diff --git a/ssi-dids/Cargo.toml b/ssi-dids/Cargo.toml index 18f4b8a12..318c9e3bf 100644 --- a/ssi-dids/Cargo.toml +++ b/ssi-dids/Cargo.toml @@ -49,7 +49,7 @@ hyper = { version = "0.14", features = [ "http1", "stream", ] } -ssi-jwk = { path = "../ssi-jwk", version = "0.1", default-features = false, features = ["secp256k1"] } +ssi-jwk = { path = "../ssi-jwk", version = "0.1", default-features = false, features = ["secp256k1", "ed25519"] } [package.metadata.docs.rs] all-features = true diff --git a/ssi-jwk/src/lib.rs b/ssi-jwk/src/lib.rs index 402c74bf1..35520bc5c 100644 --- a/ssi-jwk/src/lib.rs +++ b/ssi-jwk/src/lib.rs @@ -476,7 +476,9 @@ impl JWK { pub fn from_vm_type(type_: &str, pk_bytes: Vec) -> Result { match type_ { // TODO: check against IRIs when in JSON-LD + #[cfg(feature = "ed25519")] "Ed25519VerificationKey2018" => ed25519_parse(&pk_bytes), + #[cfg(feature = "ed25519")] "Ed25519VerificationKey2020" => match multicodec::decode(&pk_bytes) { Ok((codec, pk)) => match codec { multicodec::Codec::Ed25519Pub => ed25519_parse(&pk), diff --git a/ssi-ldp/Cargo.toml b/ssi-ldp/Cargo.toml index 88733ce8f..f647cd2ae 100644 --- a/ssi-ldp/Cargo.toml +++ b/ssi-ldp/Cargo.toml @@ -45,6 +45,7 @@ serde_json = "1.0" serde_jcs = "0.1" hex = "0.4" multibase = "0.8" +sha2 = "0.10.7" k256 = { version = "0.11", optional = true, features = ["ecdsa"] } p256 = { version = "0.11", optional = true, features = ["ecdsa"] } keccak-hash = { version = "0.7", optional = true } diff --git a/ssi-ldp/src/lib.rs b/ssi-ldp/src/lib.rs index 83001a0d4..7478bfa97 100644 --- a/ssi-ldp/src/lib.rs +++ b/ssi-ldp/src/lib.rs @@ -6,8 +6,8 @@ use async_trait::async_trait; use chrono::prelude::*; pub mod proof; use iref::{Iri, IriBuf}; -use k256::sha2::{Digest, Sha384}; pub use proof::{Check, LinkedDataProofOptions, Proof}; +use sha2::{Digest, Sha384}; use static_iref::iri; pub mod error; pub use error::Error; diff --git a/ssi-ldp/src/proof.rs b/ssi-ldp/src/proof.rs index 1562848fa..c7f565271 100644 --- a/ssi-ldp/src/proof.rs +++ b/ssi-ldp/src/proof.rs @@ -58,7 +58,6 @@ pub struct Proof { pub nonce: Option, #[serde(skip_serializing_if = "Option::is_none")] pub jws: Option, - #[cfg(feature = "w3c")] #[serde(skip_serializing_if = "Option::is_none")] pub cryptosuite: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -81,7 +80,6 @@ impl Proof { nonce: None, jws: None, property_set: None, - #[cfg(feature = "w3c")] cryptosuite: None, } } @@ -237,7 +235,6 @@ pub struct LinkedDataProofOptions { pub eip712_domain: Option, #[cfg(not(feature = "eip"))] pub eip712_domain: Option<()>, - #[cfg(feature = "w3c")] #[serde(skip_serializing_if = "Option::is_none")] pub cryptosuite: Option, } @@ -253,7 +250,6 @@ impl Default for LinkedDataProofOptions { checks: Some(vec![Check::Proof]), eip712_domain: None, type_: None, - #[cfg(feature = "w3c")] cryptosuite: None, } } diff --git a/ssi-ldp/src/suites/mod.rs b/ssi-ldp/src/suites/mod.rs index 0fd875353..443b143f9 100644 --- a/ssi-ldp/src/suites/mod.rs +++ b/ssi-ldp/src/suites/mod.rs @@ -1,6 +1,5 @@ #[cfg(feature = "aleo")] mod aleo; -#[cfg(feature = "w3c")] pub mod dataintegrity; #[cfg(feature = "eip")] mod eip; @@ -15,7 +14,6 @@ mod w3c; #[cfg(feature = "aleo")] use aleo::*; -#[cfg(feature = "w3c")] use dataintegrity::*; #[cfg(feature = "eip")] use eip::*; @@ -51,7 +49,6 @@ pub enum ProofSuiteType { Ed25519Signature2018, #[cfg(feature = "ed25519")] Ed25519Signature2020, - #[cfg(feature = "w3c")] DataIntegrityProof, #[cfg(feature = "tezos")] Ed25519BLAKE2BDigestSize20Base58CheckEncodedSignature2021, @@ -115,7 +112,6 @@ impl ProofSuiteType { Self::Ed25519Signature2018 => SignatureType::JWS, #[cfg(feature = "ed25519")] Self::Ed25519Signature2020 => SignatureType::LD, - #[cfg(feature = "w3c")] Self::DataIntegrityProof => SignatureType::LD, #[cfg(feature = "tezos")] Self::Ed25519BLAKE2BDigestSize20Base58CheckEncodedSignature2021 => SignatureType::JWS, @@ -160,7 +156,6 @@ impl ProofSuiteType { Self::Ed25519Signature2018 => &["https://w3id.org/security#Ed25519Signature2018"], #[cfg(feature = "ed25519")] Self::Ed25519Signature2020 => &["https://w3id.org/security#Ed25519Signature2020", "https://www.w3.org/ns/credentials/examples#Ed25519Signature2020"], - #[cfg(feature = "w3c")] Self::DataIntegrityProof => &["https://w3id.org/security#DataIntegrityProof"], #[cfg(feature = "tezos")] Self::Ed25519BLAKE2BDigestSize20Base58CheckEncodedSignature2021 => { @@ -372,7 +367,6 @@ impl ProofSuite for ProofSuiteType { ) .await } - #[cfg(feature = "w3c")] Self::DataIntegrityProof => { DataIntegrityProof::sign( document, @@ -584,7 +578,6 @@ impl ProofSuite for ProofSuiteType { ) .await } - #[cfg(feature = "w3c")] Self::DataIntegrityProof => { DataIntegrityProof::prepare( document, @@ -757,7 +750,6 @@ impl ProofSuite for ProofSuiteType { Self::Ed25519Signature2020 => { verify_nojws(proof, document, resolver, context_loader, Algorithm::EdDSA).await } - #[cfg(feature = "w3c")] Self::DataIntegrityProof => { DataIntegrityProof::verify(proof, document, resolver, context_loader).await }