Skip to main content

platform_encryption/
lib.rs

1//! Cryptographic utilities for Dash Platform (DIP-15)
2//!
3//! This crate implements the Diffie-Hellman key exchange and encryption/decryption
4//! operations as specified in DIP-15 for secure communication between Dash identities.
5//!
6//! The DIP-15 surface is split by concern:
7//! - [`ecdh`] — ECDH shared-secret derivation.
8//! - [`aes`] — AES-256-CBC primitives shared by the encrypted fields.
9//! - [`compact_xpub`] — the 69-byte compact xpub (`encryptedPublicKey`) + its encryption.
10//! - [`account_label`] — `encryptedAccountLabel`.
11//! - [`contact_info`] — `contactInfo` (`encToUserId` + `privateData`).
12//! - [`account_reference`] — the masked `accountReference`.
13//! - [`private_document_envelope`] — the standard private document envelope (version 1).
14//! - [`shielded_address`]: `encryptedShieldedAddress` and the per-contact index rule.
15//! - [`error`] — the shared [`CryptoError`].
16//!
17//! Every public item is re-exported at the crate root, so the API is flat
18//! (`platform_encryption::derive_shared_key_ecdh`, etc.) regardless of module.
19
20mod account_label;
21mod account_reference;
22mod aes;
23mod compact_xpub;
24mod contact_info;
25mod ecdh;
26mod error;
27mod private_document_envelope;
28mod shielded_address;
29
30pub use account_label::{decrypt_account_label, encrypt_account_label};
31pub use account_reference::{
32    account_reference_version, calculate_account_reference, unmask_account_reference,
33    ACCOUNT_REFERENCE_VERSION_SHIFT,
34};
35pub use aes::{decrypt_aes_256_cbc, encrypt_aes_256_cbc};
36pub use compact_xpub::{
37    compact_xpub_bytes, decrypt_extended_public_key, encrypt_extended_public_key,
38    parse_compact_xpub, CompactXpub, COMPACT_XPUB_LEN,
39};
40pub use contact_info::{
41    decrypt_enc_to_user_id, decrypt_private_data, encrypt_enc_to_user_id, encrypt_private_data,
42};
43pub use ecdh::derive_shared_key_ecdh;
44pub use error::CryptoError;
45pub use private_document_envelope::{
46    open_private_document_entry, private_document_outgoing_viewing_key,
47    private_document_signing_data, recover_private_document_signer,
48    recover_sent_private_document_entry, seal_private_document_entry,
49    sign_private_document_signing_data, OpenedPrivateDocumentEntry, PrivateDocumentAuthMode,
50    PrivateDocumentEnvelopeError, PrivateDocumentRecipient, PrivateDocumentRecipientKeys,
51    PrivateDocumentSender, PrivateDocumentTarget, PRIVATE_DOCUMENT_ENVELOPE_BODY_HEADER_LEN,
52    PRIVATE_DOCUMENT_ENVELOPE_OVERHEAD_LEN, PRIVATE_DOCUMENT_ENVELOPE_VERSION,
53    PRIVATE_DOCUMENT_ENVELOPE_WRAPPER_LEN,
54};
55pub use shielded_address::{
56    decrypt_shielded_address, encrypt_shielded_address, is_shielded_contact_index,
57    shielded_contact_index, shielded_contact_index_key, ENCRYPTED_SHIELDED_ADDRESS_LEN,
58    SHIELDED_ADDRESS_LEN, SHIELDED_DIVERSIFIER_INDEX_LEN, SHIELDED_FULL_VIEWING_KEY_LEN,
59};