Support MitraJcsRsaSignature2022 and MitraJcsEip191Signature2022 signature suites

This commit is contained in:
silverpill 2023-01-07 23:06:23 +00:00
parent 65496e5260
commit 94d99e81c4
3 changed files with 12 additions and 6 deletions

View file

@ -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. - Started to keep track of unreachable actors.
- Added `configuration` object to response of `/api/v1/instance` endpoint. - Added `configuration` object to response of `/api/v1/instance` endpoint.
- Save media types of uploaded avatar and banner images. - Save media types of uploaded avatar and banner images.
- Support for `MitraJcsRsaSignature2022` and `MitraJcsEip191Signature2022` signature suites.
### Changed ### 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. - Deprecated `post_character_limit` property in `/api/v1/instance` response.
- Avatar and banner uploads without media type via `/api/v1/accounts/update_credentials`. - Avatar and banner uploads without media type via `/api/v1/accounts/update_credentials`.
- `JcsRsaSignature2022` and `JcsEip191Signature2022` signature suites.
### Removed ### Removed

View file

@ -13,10 +13,12 @@ pub const PROOF_TYPE_ID_MINISIGN: &str = "MitraMinisignSignature2022A";
// - Canonicalization algorithm: JCS // - Canonicalization algorithm: JCS
// - Digest algorithm: SHA-256 // - Digest algorithm: SHA-256
// - Signature algorithm: RSASSA-PKCS1-v1_5 // - 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 // 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 // Similar to Ed25519Signature2020
// https://w3c-ccg.github.io/di-eddsa-2020/#ed25519signature2020 // https://w3c-ccg.github.io/di-eddsa-2020/#ed25519signature2020
@ -38,8 +40,10 @@ impl FromStr for SignatureType {
fn from_str(value: &str) -> Result<Self, Self::Err> { fn from_str(value: &str) -> Result<Self, Self::Err> {
let signature_type = match value { let signature_type = match value {
PROOF_TYPE_JCS_EIP191 => Self::JcsEip191Signature, PROOF_TYPE_JCS_EIP191 => Self::JcsEip191Signature,
PROOF_TYPE_JCS_EIP191_LEGACY => Self::JcsEip191Signature,
PROOF_TYPE_JCS_ED25519 => Self::JcsEd25519Signature, PROOF_TYPE_JCS_ED25519 => Self::JcsEd25519Signature,
PROOF_TYPE_JCS_RSA => Self::JcsRsaSignature, PROOF_TYPE_JCS_RSA => Self::JcsRsaSignature,
PROOF_TYPE_JCS_RSA_LEGACY => Self::JcsRsaSignature,
_ => return Err(ConversionError), _ => return Err(ConversionError),
}; };
Ok(signature_type) Ok(signature_type)

View file

@ -8,8 +8,8 @@ use crate::identity::{
did_pkh::DidPkh, did_pkh::DidPkh,
signatures::{ signatures::{
PROOF_TYPE_JCS_ED25519, PROOF_TYPE_JCS_ED25519,
PROOF_TYPE_JCS_EIP191, PROOF_TYPE_JCS_EIP191_LEGACY,
PROOF_TYPE_JCS_RSA, PROOF_TYPE_JCS_RSA_LEGACY,
}, },
}; };
use crate::utils::{ use crate::utils::{
@ -43,7 +43,7 @@ impl IntegrityProof {
signature: &[u8], signature: &[u8],
) -> Self { ) -> Self {
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(), proof_purpose: PROOF_PURPOSE.to_string(),
verification_method: signer_key_id.to_string(), verification_method: signer_key_id.to_string(),
created: Utc::now(), created: Utc::now(),
@ -56,7 +56,7 @@ impl IntegrityProof {
signature: &[u8], signature: &[u8],
) -> Self { ) -> Self {
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(), proof_purpose: PROOF_PURPOSE.to_string(),
verification_method: signer.to_string(), verification_method: signer.to_string(),
created: Utc::now(), created: Utc::now(),