Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: serialization of status list (#1423) #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

---

> [!NOTE]
> This version of the library is compatible with IOTA Stardust networks, for a version of the library compatible with IOTA Rebased networks check [here](https://github.com/iotaledger/identity.rs/tree/feat/identity-rebased-alpha/)

## Introduction

IOTA Identity is a [Rust](https://www.rust-lang.org/) implementation of decentralized digital identity, also known as Self-Sovereign Identity (SSI). It implements the W3C [Decentralized Identifiers (DID)](https://www.w3.org/TR/did-core/) and [Verifiable Credentials](https://www.w3.org/TR/vc-data-model/) specifications. This library can be used to create, resolve and authenticate digital identities and to create verifiable credentials and presentations in order to share information in a verifiable manner and establish trust in the digital world. It does so while supporting secure storage of cryptographic keys, which can be implemented for your preferred key management system. Many of the individual libraries (Rust crates) are agnostic over the concrete DID method, with the exception of some libraries dedicated to implement the [IOTA DID method](https://wiki.iota.org/identity.rs/specs/did/iota_did_method_spec/), which is an implementation of decentralized digital identity on the IOTA and Shimmer networks. Written in stable Rust, IOTA Identity has strong guarantees of memory safety and process integrity while maintaining exceptional performance.
Expand Down
3 changes: 2 additions & 1 deletion bindings/wasm/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[toolchain]
channel = "stable"
# @itsyaasir - Update to latest stable version when wasm-bindgen is updated
channel = "1.81"
components = ["rustfmt"]
targets = ["wasm32-unknown-unknown"]
profile = "minimal"
22 changes: 21 additions & 1 deletion identity_credential/src/revocation/status_list_2021/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ where
.map(ToOwned::to_owned)
}

/// Serialize usize as string.
fn serialize_number_as_string<S>(value: &usize, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(&value.to_string())
}

/// [StatusList2021Entry](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/#statuslist2021entry) implementation.
#[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
Expand All @@ -45,7 +53,10 @@ pub struct StatusList2021Entry {
#[serde(rename = "type", deserialize_with = "deserialize_status_entry_type")]
type_: String,
status_purpose: StatusPurpose,
#[serde(deserialize_with = "serde_aux::prelude::deserialize_number_from_string")]
#[serde(
deserialize_with = "serde_aux::prelude::deserialize_number_from_string",
serialize_with = "serialize_number_as_string"
)]
status_list_index: usize,
status_list_credential: Url,
}
Expand Down Expand Up @@ -142,4 +153,13 @@ mod tests {
});
serde_json::from_value::<StatusList2021Entry>(status).expect("wrong type");
}

#[test]
fn test_status_list_index_serialization() {
let base_url = Url::parse("https://example.com/credentials/status/3").unwrap();

let entry1 = StatusList2021Entry::new(base_url.clone(), StatusPurpose::Revocation, 94567, None);
let json1 = serde_json::to_value(&entry1).unwrap();
assert_eq!(json1["statusListIndex"], "94567");
}
}
3 changes: 3 additions & 0 deletions identity_iota/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

---

> [!NOTE]
> This version of the library is compatible with IOTA Stardust networks, for a version of the library compatible with IOTA Rebased networks check [here](https://github.com/iotaledger/identity.rs/tree/feat/identity-rebased-alpha/)

## Introduction

IOTA Identity is a [Rust](https://www.rust-lang.org/) implementation of decentralized digital identity, also known as Self-Sovereign Identity (SSI). It implements the W3C [Decentralized Identifiers (DID)](https://www.w3.org/TR/did-core/) and [Verifiable Credentials](https://www.w3.org/TR/vc-data-model/) specifications. This library can be used to create, resolve and authenticate digital identities and to create verifiable credentials and presentations in order to share information in a verifiable manner and establish trust in the digital world. It does so while supporting secure storage of cryptographic keys, which can be implemented for your preferred key management system. Many of the individual libraries (Rust crates) are agnostic over the concrete DID method, with the exception of some libraries dedicated to implement the [IOTA DID method](https://wiki.iota.org/identity.rs/specs/did/iota_did_method_spec/), which is an implementation of decentralized digital identity on the IOTA and Shimmer networks. Written in stable Rust, IOTA Identity has strong guarantees of memory safety and process integrity while maintaining exceptional performance.
Expand Down