Use proof suites with prefix Mitra

This commit is contained in:
silverpill 2023-01-28 01:11:47 +00:00
parent f0ae82c0db
commit 08c55cc71c
3 changed files with 58 additions and 6 deletions

View file

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
### Changed
- Use proof suites with prefix `Mitra`.
## [1.12.0] - 2023-01-26 ## [1.12.0] - 2023-01-26
### Added ### Added

View file

@ -29,12 +29,60 @@ And these additional standards:
Activities are implemented in way that is compatible with Pleroma, Mastodon and other popular ActivityPub servers. Activities are implemented in way that is compatible with Pleroma, Mastodon and other popular ActivityPub servers.
## Supported FEPs Supported FEPs:
- [FEP-f1d5: NodeInfo in Fediverse Software](https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-f1d5.md) - [FEP-f1d5: NodeInfo in Fediverse Software](https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-f1d5.md)
- [FEP-e232: Object Links](https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-e232.md) - [FEP-e232: Object Links](https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-e232.md)
- [FEP-8b32: Object Integrity Proofs](https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-8b32.md) - [FEP-8b32: Object Integrity Proofs](https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-8b32.md)
## Object integrity proofs
All outgoing activities are signed with actor's key in accordance with [FEP-8b32](https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-8b32.md) document.
Example:
```json
{
"@context": "https://www.w3.org/ns/activitystreams",
"actor": "https://example.com/users/alice",
"cc": [],
"id": "https://example.com/objects/0185f5f8-10b5-1b69-f45e-25f06792f411",
"object": "https://example.net/users/bob/posts/141892712081205472",
"proof": {
"created": "2023-01-28T01:22:40.183273595Z",
"proofPurpose": "assertionMethod",
"proofValue": "z5djAdMSrV...",
"type": "MitraJcsRsaSignature2022",
"verificationMethod": "https://example.com/users/alice#main-key"
},
"to": [
"https://example.net/users/bob",
"https://www.w3.org/ns/activitystreams#Public"
],
"type":"Like"
}
```
### Supported proof suites
#### MitraJcsRsaSignature2022
Canonicalization algorithm: JCS
Hashing algorithm: SHA-256
Signature algorithm: RSASSA-PKCS1-v1_5
#### MitraJcsEip191Signature2022
Canonicalization algorithm: JCS
Hashing algorithm: KECCAK-256 (EIP-191)
Signature algorithm: ECDSA (EIP-191)
#### MitraJcsEd25519Signature2022
Canonicalization algorithm: JCS
Hashing algorithm: BLAKE2b-512
Signature algorithm: EdDSA
## Profile extensions ## Profile extensions
### Cryptocurrency addresses ### Cryptocurrency addresses

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_LEGACY, PROOF_TYPE_JCS_EIP191,
PROOF_TYPE_JCS_RSA_LEGACY, PROOF_TYPE_JCS_RSA,
}, },
}; };
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_LEGACY.to_string(), proof_type: PROOF_TYPE_JCS_RSA.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_LEGACY.to_string(), proof_type: PROOF_TYPE_JCS_EIP191.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(),
@ -160,7 +160,7 @@ mod tests {
assert_eq!(result["object"], object["object"]); assert_eq!(result["object"], object["object"]);
let signature_date = result["proof"]["created"].as_str().unwrap(); let signature_date = result["proof"]["created"].as_str().unwrap();
// Put * in place of date to avoid escaping all curly brackets // Put * in place of date to avoid escaping all curly brackets
let expected_result = r#"{"actor":"https://example.org/users/test","id":"https://example.org/objects/1","object":{"content":"test","type":"Note"},"proof":{"created":"*","proofPurpose":"assertionMethod","proofValue":"z2Gh9LYrXjSqFrkia6gMg7xp2wftn1hqmYeEXxrsH9Eh6agB2VYraSYrDoSufbXEHnnyHMCoDSAriLpVacj6E4LFK","type":"JcsRsaSignature2022","verificationMethod":"https://example.org/users/test#main-key"},"to":["https://example.org/users/yyy","https://example.org/users/xxx"],"type":"Create"}"#; let expected_result = r#"{"actor":"https://example.org/users/test","id":"https://example.org/objects/1","object":{"content":"test","type":"Note"},"proof":{"created":"*","proofPurpose":"assertionMethod","proofValue":"z2Gh9LYrXjSqFrkia6gMg7xp2wftn1hqmYeEXxrsH9Eh6agB2VYraSYrDoSufbXEHnnyHMCoDSAriLpVacj6E4LFK","type":"MitraJcsRsaSignature2022","verificationMethod":"https://example.org/users/test#main-key"},"to":["https://example.org/users/yyy","https://example.org/users/xxx"],"type":"Create"}"#;
assert_eq!( assert_eq!(
serde_json::to_string(&result).unwrap(), serde_json::to_string(&result).unwrap(),
expected_result.replace('*', signature_date), expected_result.replace('*', signature_date),