Skip to content

Commit

Permalink
Merge pull request #180 from alan-turing-institute/179-remove-rss-for…
Browse files Browse the repository at this point in the history
…-publish-to-crates-io

Make version with all dependencies available on crates.io (#179)
  • Loading branch information
sgreenbury authored May 13, 2024
2 parents 8ffe5f5 + 4604858 commit 0ffddfb
Show file tree
Hide file tree
Showing 33 changed files with 78 additions and 423 deletions.
18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
[package]
name = "trustchain"
version = "0.2.0"
authors = ["Trustchain Devs"]
license = "MIT OR Apache-2.0"
description = "Trustchain decentralised PKI reference implementation."
homepage = "https://alan-turing-institute.github.io/trustchain/"
repository = "https://github.com/alan-turing-institute/trustchain/"
keywords = ["pki", "did", "vc", "vp"]
edition = "2021"

[workspace]
members = [
"trustchain-core",
Expand All @@ -8,3 +19,10 @@ members = [
"trustchain-ffi"
]
resolver = "2"

[dependencies]
trustchain-api = { path = "./trustchain-api", version = "0.1.0"}
trustchain-core = { path = "./trustchain-core", version = "0.2.0"}
trustchain-ffi = { path = "./trustchain-ffi", version = "0.1.0"}
trustchain-http = { path = "./trustchain-http", version = "0.1.0"}
trustchain-ion = { path = "./trustchain-ion", version = "0.2.0"}
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Trustchain reference implementation.

pub use trustchain_api as api;
pub use trustchain_core as core;
pub use trustchain_ffi as ffi;
pub use trustchain_http as http;
pub use trustchain_ion as ion;
10 changes: 2 additions & 8 deletions trustchain-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ edition = "2021"
[dependencies]
trustchain-core = { path = "../trustchain-core" }
trustchain-ion = { path = "../trustchain-ion" }
ps_sig = { git = "https://github.com/alan-turing-institute/RSS.git", rev = "ec9386e125d87c5f54898b34fbe0883b3b36ffd4" }

async-trait = "0.1"
serde_json = "1.0"
ssi = { git = "https://github.com/alan-turing-institute/ssi.git", rev = "1aa3223a384ee71df1333bbce04af445e852eab5", features = [
"http-did",
"secp256k1",
"rss",
] }
did-ion = { git = "https://github.com/alan-turing-institute/ssi.git", rev = "1aa3223a384ee71df1333bbce04af445e852eab5" }
ssi = { version = "0.7", features = ["http-did", "secp256k1"]}
did-ion = { version = "0.2"}
futures = "0.3.28"

[dev-dependencies]
Expand Down
152 changes: 5 additions & 147 deletions trustchain-api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use trustchain_ion::{
attest::attest_operation, attestor::IONAttestor, create::create_operation, trustchain_resolver,
};

/// API for Trustchain CLI DID functionality.
/// API for Trustchain DID functionality.
#[async_trait]
pub trait TrustchainDIDAPI {
/// Creates a controlled DID from a passed document state, writing the associated create
Expand Down Expand Up @@ -79,7 +79,7 @@ pub trait TrustchainDIDAPI {
// }
}

/// API for Trustchain CLI VC functionality.
/// API for Trustchain VC functionality.
#[async_trait]
pub trait TrustchainVCAPI {
/// Signs a credential.
Expand Down Expand Up @@ -135,6 +135,7 @@ pub trait TrustchainVCAPI {
}
}

/// API for Trustchain VP functionality.
#[async_trait]
pub trait TrustchainVPAPI {
/// Signs a presentation constructing a verifiable presentation.
Expand Down Expand Up @@ -248,11 +249,11 @@ pub trait TrustchainVPAPI {
mod tests {
use crate::api::{TrustchainVCAPI, TrustchainVPAPI};
use crate::TrustchainAPI;
use did_ion::sidetree::PublicKeyEntry;

use ssi::jsonld::ContextLoader;
use ssi::ldp::now_ns;
use ssi::one_or_many::OneOrMany;
use ssi::vc::{Credential, CredentialOrJWT, CredentialSubject, Presentation, VCDateTime};
use ssi::vc::{Credential, CredentialOrJWT, Presentation, VCDateTime};
use trustchain_core::utils::init;
use trustchain_core::vc::CredentialError;
use trustchain_core::vp::PresentationError;
Expand Down Expand Up @@ -284,33 +285,6 @@ mod tests {
}
"#;

const UNSIGNED_DRIVERS_LICENCE_VC: &str = r###"{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/vdl/v1"
],
"type": [
"VerifiableCredential",
"Iso18013DriversLicense"
],
"issuer": "did:ion:test:EiAtHHKFJWAk5AsM3tgCut3OiBY4ekHTf66AAjoysXL65Q",
"issuanceDate": "2023-11-23T11:43:26.806224Z",
"credentialSubject": {
"id": "did:example:12347abcd",
"Iso18013DriversLicense": {
"height": 1.8,
"weight": 70,
"nationality": "France",
"given_name": "Test",
"family_name": "A",
"issuing_country": "US",
"birth_date": "1958-07-17",
"age_in_years": 30,
"age_birth_year": 1958
}
}
}"###;

#[ignore = "requires a running Sidetree node listening on http://localhost:3000"]
#[tokio::test]
async fn test_verify_credential() {
Expand Down Expand Up @@ -350,110 +324,6 @@ mod tests {
}
}

#[ignore = "requires a running Sidetree node listening on http://localhost:3000"]
#[tokio::test]
async fn test_verify_rss_credential() {
init();

// DID with RSS verification method
let issuer_did_suffix = "EiAtHHKFJWAk5AsM3tgCut3OiBY4ekHTf66AAjoysXL65Q";
let resolver = trustchain_resolver("http://localhost:3000/");
let vc: Credential = serde_json::from_str(UNSIGNED_DRIVERS_LICENCE_VC).unwrap();
let attestor = IONAttestor::new(issuer_did_suffix);

let signed_vc = attestor
.sign(
&vc,
None,
Some("QDsGIX_7NfNEaXdEeV7PJ5e_CwoH5LlF3srsCp5dcHA"),
&resolver,
&mut ContextLoader::default(),
)
.await
.unwrap();
println!("{}", serde_json::to_string_pretty(&signed_vc).unwrap());
let mut context_loader = ContextLoader::default();
let verifier = TrustchainVerifier::new(resolver);
let res = TrustchainAPI::verify_credential(
&signed_vc,
None,
ROOT_EVENT_TIME_1,
&verifier,
&mut context_loader,
)
.await;
// println!("{:?}", &res);
assert!(res.is_ok());
}

#[ignore = "requires a running Sidetree node listening on http://localhost:3000"]
#[tokio::test]
async fn test_redact_verify_rss_credential() {
init();

// DID with RSS verification method
let issuer_did_suffix = "did:ion:test:EiAtHHKFJWAk5AsM3tgCut3OiBY4ekHTf66AAjoysXL65Q";
let resolver = trustchain_resolver("http://localhost:3000/");
let vc: Credential = serde_json::from_str(UNSIGNED_DRIVERS_LICENCE_VC).unwrap();
let attestor = IONAttestor::new(issuer_did_suffix);

let mut signed_vc = attestor
.sign(
&vc,
None,
Some("QDsGIX_7NfNEaXdEeV7PJ5e_CwoH5LlF3srsCp5dcHA"),
&resolver,
&mut ContextLoader::default(),
)
.await
.unwrap();
// println!("{}", serde_json::to_string_pretty(&signed_vc).unwrap());
// derive redacted RSignature
let masked_cred_sub: CredentialSubject = serde_json::from_str(
r###"{
"id": "did:example:12347abcd",
"Iso18013DriversLicense": {
"height": null,
"weight": null,
"nationality": null,
"given_name": null,
"family_name": null,
"issuing_country": "US",
"birth_date": null,
"age_in_years": 30,
"age_birth_year": null
}
}"###,
)
.unwrap();
let mut masked_copy = signed_vc.clone();
masked_copy.credential_subject = OneOrMany::One(masked_cred_sub);

// produce redacted vc from redacted json
let mut context_loader = ContextLoader::default();
let verifier = TrustchainVerifier::new(resolver);
signed_vc
.rss_redact(
masked_copy,
&trustchain_resolver("http://localhost:3000/"),
&mut context_loader,
)
.await
.unwrap();
// println!("{}", serde_json::to_string_pretty(&signed_vc).unwrap());

let res = TrustchainAPI::verify_credential(
&signed_vc,
None,
ROOT_EVENT_TIME_1,
&verifier,
&mut context_loader,
)
.await;

assert!(res.is_ok());
}

#[ignore = "requires a running Sidetree node listening on http://localhost:3000"]
#[tokio::test]
async fn test_verify_presentation() {
Expand Down Expand Up @@ -570,16 +440,4 @@ mod tests {
.await
.unwrap()
}

#[test]
fn get_key_entry() {
use ps_sig::keys::Params;
use ssi::jwk::rss::generate_keys_jwk;
use ssi::jwk::JWK;

let key: JWK = generate_keys_jwk(64, &Params::new("test".to_string().as_bytes())).unwrap();
println!("{}", serde_json::to_string_pretty(&key).unwrap());
let entry: PublicKeyEntry = key.try_into().unwrap();
println!("{}", serde_json::to_string_pretty(&entry).unwrap());
}
}
1 change: 1 addition & 0 deletions trustchain-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! API for DID, VC and VP functionality.
pub mod api;
use crate::api::{TrustchainDIDAPI, TrustchainVCAPI, TrustchainVPAPI};

Expand Down
8 changes: 2 additions & 6 deletions trustchain-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ trustchain-ion = { path = "../trustchain-ion" }
trustchain-api = { path = "../trustchain-api" }

clap = { version = "4.0.32", features = ["derive", "cargo"] }
did-ion = { git = "https://github.com/alan-turing-institute/ssi.git", rev = "1aa3223a384ee71df1333bbce04af445e852eab5" }
did-ion = { version = "0.2"}
lazy_static = "1.4.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
ssi = { git = "https://github.com/alan-turing-institute/ssi.git", rev = "1aa3223a384ee71df1333bbce04af445e852eab5", features = [
"http-did",
"secp256k1",
"rss",
] }
ssi = { version = "0.7", features = ["http-did", "secp256k1"]}
tokio = { version = "1.20.1", features = ["full"] }
toml = "0.7.2"
13 changes: 3 additions & 10 deletions trustchain-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
[package]
name = "trustchain-core"
version = "0.1.0"
version = "0.2.0"
authors = ["Trustchain Devs"]
edition = "2021"


[dependencies]
ps_sig = { git = "https://github.com/alan-turing-institute/RSS.git", rev = "ec9386e125d87c5f54898b34fbe0883b3b36ffd4" }

async-trait = "0.1"
base64 = "0.13"
canonical_json = "0.4.0"
chrono = "0.4"
did-method-key = { git = "https://github.com/alan-turing-institute/ssi.git", rev = "1aa3223a384ee71df1333bbce04af445e852eab5" }
did-method-key = { version = "0.2.2"}
futures = "0.3.21"
petgraph = { version = "0.6" }
serde = { version = "1.0", features = ["derive"] }
serde_jcs = "0.1.0"
serde_json = "1.0"
sha2 = "0.10.7"
ssi = { git = "https://github.com/alan-turing-institute/ssi.git", rev = "1aa3223a384ee71df1333bbce04af445e852eab5", features = [
"http-did",
"secp256k1",
"rss",
] }
ssi = { version = "0.7", features = ["http-did", "secp256k1"]}
tempfile = { version = "3.3" }
thiserror = "1.0"
tokio = { version = "1.20.1", features = ["full"] }
Expand Down
2 changes: 1 addition & 1 deletion trustchain-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Trustchain library.
//! Core traits and logic (data layer independent).
pub mod attestor;
pub mod chain;
pub mod commitment;
Expand Down
10 changes: 3 additions & 7 deletions trustchain-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Trustchain Devs"]
edition = "2021"

[lib]
crate-type = ["cdylib", "staticlib"]
crate-type = ["cdylib", "staticlib", "lib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -16,17 +16,13 @@ trustchain-api = { path = "../trustchain-api" }

anyhow = "1.0"
chrono = "0.4.26"
did-ion = { git = "https://github.com/alan-turing-institute/ssi.git", rev = "1aa3223a384ee71df1333bbce04af445e852eab5" }
did-ion = { version = "0.2"}
# Fixed to same version used to generate bridge: `[email protected]`
flutter_rust_bridge = "=1.64.0"
lazy_static = "1.4.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
ssi = { git = "https://github.com/alan-turing-institute/ssi.git", rev = "1aa3223a384ee71df1333bbce04af445e852eab5", features = [
"http-did",
"secp256k1",
"rss",
] }
ssi = { version = "0.7", features = ["http-did", "secp256k1"]}
thiserror = "1.0"
tokio = { version = "1.14.0", features = ["rt-multi-thread"] }
toml = "0.7.2"
1 change: 1 addition & 0 deletions trustchain-ffi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! FFI bindings for flutter/dart.
pub mod config;
// pub mod gui;
pub mod mobile;
Expand Down
Loading

0 comments on commit 0ffddfb

Please sign in to comment.