From 94d99e81c45b85a79f35d474c4580697fa307d95 Mon Sep 17 00:00:00 2001 From: silverpill Date: Sat, 7 Jan 2023 23:06:23 +0000 Subject: [PATCH] Support MitraJcsRsaSignature2022 and MitraJcsEip191Signature2022 signature suites --- CHANGELOG.md | 2 ++ src/identity/signatures.rs | 8 ++++++-- src/json_signatures/create.rs | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a52e8fa..4c1e1fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Started to keep track of unreachable actors. - Added `configuration` object to response of `/api/v1/instance` endpoint. - Save media types of uploaded avatar and banner images. +- Support for `MitraJcsRsaSignature2022` and `MitraJcsEip191Signature2022` signature suites. ### Changed @@ -24,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Deprecated `post_character_limit` property in `/api/v1/instance` response. - Avatar and banner uploads without media type via `/api/v1/accounts/update_credentials`. +- `JcsRsaSignature2022` and `JcsEip191Signature2022` signature suites. ### Removed diff --git a/src/identity/signatures.rs b/src/identity/signatures.rs index 29d633b..fa60f1b 100644 --- a/src/identity/signatures.rs +++ b/src/identity/signatures.rs @@ -13,10 +13,12 @@ pub const PROOF_TYPE_ID_MINISIGN: &str = "MitraMinisignSignature2022A"; // - Canonicalization algorithm: JCS // - Digest algorithm: SHA-256 // - Signature algorithm: RSASSA-PKCS1-v1_5 -pub const PROOF_TYPE_JCS_RSA: &str = "JcsRsaSignature2022"; +pub const PROOF_TYPE_JCS_RSA: &str = "MitraJcsRsaSignature2022"; +pub const PROOF_TYPE_JCS_RSA_LEGACY: &str = "JcsRsaSignature2022"; // Similar to EthereumPersonalSignature2021 but with JCS -pub const PROOF_TYPE_JCS_EIP191: &str ="JcsEip191Signature2022"; +pub const PROOF_TYPE_JCS_EIP191: &str = "MitraJcsEip191Signature2022"; +pub const PROOF_TYPE_JCS_EIP191_LEGACY: &str ="JcsEip191Signature2022"; // Similar to Ed25519Signature2020 // https://w3c-ccg.github.io/di-eddsa-2020/#ed25519signature2020 @@ -38,8 +40,10 @@ impl FromStr for SignatureType { fn from_str(value: &str) -> Result { let signature_type = match value { PROOF_TYPE_JCS_EIP191 => Self::JcsEip191Signature, + PROOF_TYPE_JCS_EIP191_LEGACY => Self::JcsEip191Signature, PROOF_TYPE_JCS_ED25519 => Self::JcsEd25519Signature, PROOF_TYPE_JCS_RSA => Self::JcsRsaSignature, + PROOF_TYPE_JCS_RSA_LEGACY => Self::JcsRsaSignature, _ => return Err(ConversionError), }; Ok(signature_type) diff --git a/src/json_signatures/create.rs b/src/json_signatures/create.rs index 248ea4b..670813a 100644 --- a/src/json_signatures/create.rs +++ b/src/json_signatures/create.rs @@ -8,8 +8,8 @@ use crate::identity::{ did_pkh::DidPkh, signatures::{ PROOF_TYPE_JCS_ED25519, - PROOF_TYPE_JCS_EIP191, - PROOF_TYPE_JCS_RSA, + PROOF_TYPE_JCS_EIP191_LEGACY, + PROOF_TYPE_JCS_RSA_LEGACY, }, }; use crate::utils::{ @@ -43,7 +43,7 @@ impl IntegrityProof { signature: &[u8], ) -> Self { Self { - proof_type: PROOF_TYPE_JCS_RSA.to_string(), + proof_type: PROOF_TYPE_JCS_RSA_LEGACY.to_string(), proof_purpose: PROOF_PURPOSE.to_string(), verification_method: signer_key_id.to_string(), created: Utc::now(), @@ -56,7 +56,7 @@ impl IntegrityProof { signature: &[u8], ) -> Self { Self { - proof_type: PROOF_TYPE_JCS_EIP191.to_string(), + proof_type: PROOF_TYPE_JCS_EIP191_LEGACY.to_string(), proof_purpose: PROOF_PURPOSE.to_string(), verification_method: signer.to_string(), created: Utc::now(),