Skip to content

Commit

Permalink
chore(ci): Fix CI actions; add random feature to iota crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
itsyaasir committed Aug 30, 2024
1 parent 989e6ca commit 6cee4a5
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 31 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,17 @@ jobs:

# Build the library, tests, and examples without running them to avoid recompilation in the run tests step
- name: Build with all features
run: cargo build --workspace --tests --examples --all-features --release
run: cargo build --workspace --tests --examples --release

- name: Start iota sandbox
if: matrix.os == 'ubuntu-latest'
uses: './.github/actions/iota-sandbox/setup'

- name: Run tests
run: cargo test --workspace --all-features --release
- name: Run tests excluding `custom_time` feature
run: cargo test --workspace --release

- name: Run tests with `custom_time` feature
run: cargo test --test custom_time --features="custom_time"

- name: Run Rust examples
# run examples only on ubuntu for now
Expand All @@ -157,7 +160,7 @@ jobs:
- name: Tear down iota sandbox
if: matrix.os == 'ubuntu-latest' && always()
uses: './.github/actions/iota-sandbox/tear-down'

- name: Stop sccache
uses: './.github/actions/rust/sccache/stop-sccache'
with:
Expand Down
3 changes: 1 addition & 2 deletions identity_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ url = { version = "2.4", default-features = false, features = ["serde"] }
zeroize = { version = "1.6", default-features = false }

[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi"), not(feature = "custom_time")))'.dependencies]
js-sys = { version = "0.3.55", default-features = false, optional = true }
js-sys = { version = "0.3.55", default-features = false }

[dev-dependencies]
proptest = { version = "1.0.0" }
Expand All @@ -42,7 +42,6 @@ workspace = true
# Enables a macro to provide a custom time (Timestamp::now_utc) implementation, see src/custom_time.rs
custom_time = []


[[test]]
name = "custom_time"
required-features = ["custom_time"]
2 changes: 1 addition & 1 deletion identity_core/src/common/ordered_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ mod tests {
/// Produces a strategy for generating an ordered set together with two values according to the following algorithm:
/// 1. Call `f` to get a pair of sets (x,y).
/// 2. Toss a coin to decide whether to pick an element from x at random, or from y (if the chosen set is empty
/// Default is called). 3. Repeat step 2 and let the two outcomes be denoted a and b.
/// Default is called). 3. Repeat step 2 and let the two outcomes be denoted a and b.
/// 4. Toss a coin to decide whether to swap the keys of a and b.
/// 5. return (x,a,b)
fn set_with_values<F, T, U>(f: F) -> impl Strategy<Value = (OrderedSet<T>, T, T)>
Expand Down
3 changes: 3 additions & 0 deletions identity_core/src/custom_time.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

//! An implementation of `now_utc` which calls out to an externally defined function.
use crate::common::Timestamp;

Expand Down
3 changes: 3 additions & 0 deletions identity_core/tests/custom_time.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2020-2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use identity_core::common::Timestamp;
use identity_core::register_custom_now_utc;

Expand Down
2 changes: 1 addition & 1 deletion identity_credential/src/credential/jwt_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::Result;
/// This type is opinionated in the following ways:
/// 1. Serialization tries to duplicate as little as possible between the required registered claims and the `vc` entry.
/// 2. Only allows serializing/deserializing claims "exp, iss, nbf &/or iat, jti, sub and vc". Other custom properties
/// must be set in the `vc` entry.
/// must be set in the `vc` entry.
#[derive(Serialize, Deserialize)]
pub(crate) struct CredentialJwtClaims<'credential, T = Object>
where
Expand Down
24 changes: 11 additions & 13 deletions identity_jose/src/tests/rfc8037.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,18 @@ fn test_rfc8037_ed25519() {
.and_then(|decoded| decoded.verify(&jws_verifier, &public))
.unwrap();

#[cfg(feature = "eddsa")]
{
let jws_signature_verifier = JwsVerifierFn::from(|input: VerificationInput, key: &Jwk| match input.alg {
JwsAlgorithm::EdDSA => ed25519::verify(input, key),
other => unimplemented!("{other}"),
});
let jws_signature_verifier = JwsVerifierFn::from(|input: VerificationInput, key: &Jwk| match input.alg {
JwsAlgorithm::EdDSA => ed25519::verify(input, key),
other => unimplemented!("{other}"),
});

let decoder = Decoder::new();
let token_with_default = decoder
.decode_compact_serialization(jws.as_bytes(), None)
.and_then(|decoded| decoded.verify(&jws_signature_verifier, &public))
.unwrap();

let decoder = Decoder::new();
let token_with_default = decoder
.decode_compact_serialization(jws.as_bytes(), None)
.and_then(|decoded| decoded.verify(&jws_signature_verifier, &public))
.unwrap();
assert_eq!(token, token_with_default);
}
assert_eq!(token, token_with_default);
assert_eq!(token.protected, header);
assert_eq!(token.claims, tv.payload.as_bytes());
}
Expand Down
13 changes: 9 additions & 4 deletions identity_storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ identity_credential = { version = "=1.3.1", path = "../identity_credential", def
identity_did = { version = "=1.3.1", path = "../identity_did", default-features = false }
identity_document = { version = "=1.3.1", path = "../identity_document", default-features = false }
identity_iota_core = { version = "=1.3.1", path = "../identity_iota_core", default-features = false, optional = true }
identity_verification = { version = "=1.3.1", path = "../identity_verification", default_features = false }
iota-crypto = { version = "0.23", default-features = false, features = ["ed25519"], optional = true }
identity_verification = { version = "=1.3.1", path = "../identity_verification", default-features = false }
iota-crypto = { version = "0.23", default-features = false, features = ["ed25519", "random"], optional = true }
json-proof-token = { workspace = true, optional = true }
rand = { version = "0.8.5", default-features = false, features = ["std", "std_rng"], optional = true }
seahash = { version = "4.1.0", default_features = false }
seahash = { version = "4.1.0", default-features = false }
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
Expand All @@ -47,7 +47,12 @@ send-sync-storage = []
# Implements the JwkStorageDocumentExt trait for IotaDocument
iota-document = ["dep:identity_iota_core"]
# Enables JSON Proof Token & BBS+ related features
jpt-bbs-plus = ["identity_credential/jpt-bbs-plus", "dep:zkryptium", "dep:bls12_381_plus", "dep:json-proof-token"]
jpt-bbs-plus = [
"identity_credential/jpt-bbs-plus",
"dep:zkryptium",
"dep:bls12_381_plus",
"dep:json-proof-token",
]

[lints]
workspace = true
17 changes: 11 additions & 6 deletions identity_stronghold/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ description = "Secure JWK storage with Stronghold for IOTA Identity"
[dependencies]
async-trait = { version = "0.1.64", default-features = false }
bls12_381_plus = { workspace = true, optional = true }
identity_storage = { version = "=1.3.1", path = "../identity_storage", default_features = false }
identity_verification = { version = "=1.3.1", path = "../identity_verification", default_features = false }
identity_storage = { version = "=1.3.1", path = "../identity_storage", default-features = false }
identity_verification = { version = "=1.3.1", path = "../identity_verification", default-features = false }
iota-crypto = { version = "0.23", default-features = false, features = ["ed25519"] }
iota-sdk = { version = "1.1.5", default-features = false, features = ["client", "stronghold"] }
iota_stronghold = { version = "2.1.0", default-features = false }
json-proof-token = { workspace = true, optional = true }
rand = { version = "0.8.5", default-features = false, features = ["std", "std_rng"] }
tokio = { version = "1.29.0", default-features = false, features = ["macros", "sync"] }
zeroize = { version = "1.6.0", default_features = false }
zeroize = { version = "1.6.0", default-features = false }
zkryptium = { workspace = true, optional = true }

[dev-dependencies]
anyhow = "1.0.82"
bls12_381_plus = { workspace = true }
identity_did = { version = "=1.3.1", path = "../identity_did", default_features = false }
identity_storage = { version = "=1.3.1", path = "../identity_storage", default_features = false, features = ["jpt-bbs-plus"] }
identity_did = { version = "=1.3.1", path = "../identity_did", default-features = false }
identity_storage = { version = "=1.3.1", path = "../identity_storage", default-features = false, features = ["jpt-bbs-plus"] }
json-proof-token = { workspace = true }
tokio = { version = "1.29.0", default-features = false, features = ["macros", "sync", "rt"] }
zkryptium = { workspace = true }
Expand All @@ -38,7 +38,12 @@ zkryptium = { workspace = true }
default = []
# Enables `Send` + `Sync` bounds for the trait implementations on `StrongholdStorage`.
send-sync-storage = ["identity_storage/send-sync-storage"]
bbs-plus = ["identity_storage/jpt-bbs-plus", "dep:zkryptium", "dep:bls12_381_plus", "dep:json-proof-token"]
bbs-plus = [
"identity_storage/jpt-bbs-plus",
"dep:zkryptium",
"dep:bls12_381_plus",
"dep:json-proof-token",
]

[lints]
workspace = true

0 comments on commit 6cee4a5

Please sign in to comment.