1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! # ma-did
//!
//! DID and message primitives for the `did:ma:` method.
//!
//! This crate provides everything needed to create, sign, and verify DID
//! documents and encrypted actor-to-actor messages.
//!
//! ## Quick Start — Identity
//!
//! ```rust
//! use ma_did::{generate_identity_from_secret, Did};
//!
//! // Generate a complete identity from an application-managed secret
//! let secret = [7u8; 32];
//! let identity = generate_identity_from_secret(secret).unwrap();
//!
//! // The document is already signed and valid
//! identity.document.verify().unwrap();
//! identity.document.validate().unwrap();
//!
//! // Serialize to JSON or CBOR
//! let json = identity.document.marshal().unwrap();
//! let cbor = identity.document.to_cbor().unwrap();
//! ```
//!
//! If your application already has a resolved IPNS identifier, use
//! `generate_identity(ipns)` as the explicit low-level path.
//!
//! ## Quick Start — Messages
//!
//! ```rust
//! use ma_did::{generate_identity_from_secret, Message, SigningKey, Did};
//!
//! let alice = generate_identity_from_secret([1u8; 32]).unwrap();
//! let bob = generate_identity_from_secret([2u8; 32]).unwrap();
//!
//! // Reconstruct signing key from stored private key bytes
//! let alice_sign_url = Did::new_url(&alice.subject_url.ipns, None::<String>).unwrap();
//! let alice_signing_key = SigningKey::from_private_key_bytes(
//! alice_sign_url,
//! hex::decode(&alice.signing_private_key_hex).unwrap().try_into().unwrap(),
//! ).unwrap();
//!
//! // Create a signed message
//! let msg = Message::new(
//! alice.document.id.clone(),
//! bob.document.id.clone(),
//! "text/plain",
//! b"hello".to_vec(),
//! &alice_signing_key,
//! ).unwrap();
//!
//! // Verify message signature against sender's document
//! msg.verify_with_document(&alice.document).unwrap();
//!
//! // Encrypt for recipient as an Envelope
//! let envelope = msg.enclose_for(&bob.document).unwrap();
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use Ipld;
pub use ;
pub use ;