Skip to content

Commit

Permalink
Tidy feature gates
Browse files Browse the repository at this point in the history
  • Loading branch information
sbihel committed Jun 27, 2023
1 parent 10e145c commit 5f709b6
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ssi-dids/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ssi-jwk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,9 @@ impl JWK {
pub fn from_vm_type(type_: &str, pk_bytes: Vec<u8>) -> Result<Self, Error> {
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),
Expand Down
1 change: 1 addition & 0 deletions ssi-ldp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion ssi-ldp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions ssi-ldp/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pub struct Proof {
pub nonce: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub jws: Option<String>,
#[cfg(feature = "w3c")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cryptosuite: Option<dataintegrity::DataIntegrityCryptoSuite>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -81,7 +80,6 @@ impl Proof {
nonce: None,
jws: None,
property_set: None,
#[cfg(feature = "w3c")]
cryptosuite: None,
}
}
Expand Down Expand Up @@ -237,7 +235,6 @@ pub struct LinkedDataProofOptions {
pub eip712_domain: Option<crate::eip712::ProofInfo>,
#[cfg(not(feature = "eip"))]
pub eip712_domain: Option<()>,
#[cfg(feature = "w3c")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cryptosuite: Option<DataIntegrityCryptoSuite>,
}
Expand All @@ -253,7 +250,6 @@ impl Default for LinkedDataProofOptions {
checks: Some(vec![Check::Proof]),
eip712_domain: None,
type_: None,
#[cfg(feature = "w3c")]
cryptosuite: None,
}
}
Expand Down
8 changes: 0 additions & 8 deletions ssi-ldp/src/suites/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#[cfg(feature = "aleo")]
mod aleo;
#[cfg(feature = "w3c")]
pub mod dataintegrity;
#[cfg(feature = "eip")]
mod eip;
Expand All @@ -15,7 +14,6 @@ mod w3c;

#[cfg(feature = "aleo")]
use aleo::*;
#[cfg(feature = "w3c")]
use dataintegrity::*;
#[cfg(feature = "eip")]
use eip::*;
Expand Down Expand Up @@ -51,7 +49,6 @@ pub enum ProofSuiteType {
Ed25519Signature2018,
#[cfg(feature = "ed25519")]
Ed25519Signature2020,
#[cfg(feature = "w3c")]
DataIntegrityProof,
#[cfg(feature = "tezos")]
Ed25519BLAKE2BDigestSize20Base58CheckEncodedSignature2021,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -372,7 +367,6 @@ impl ProofSuite for ProofSuiteType {
)
.await
}
#[cfg(feature = "w3c")]
Self::DataIntegrityProof => {
DataIntegrityProof::sign(
document,
Expand Down Expand Up @@ -584,7 +578,6 @@ impl ProofSuite for ProofSuiteType {
)
.await
}
#[cfg(feature = "w3c")]
Self::DataIntegrityProof => {
DataIntegrityProof::prepare(
document,
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 5f709b6

Please sign in to comment.