neo3/neo_protocol/
mod.rs

1//! # Neo Protocol
2//!
3//! Core protocol types and interfaces for the Neo N3 blockchain.
4//!
5//! ## Overview
6//!
7//! The neo_protocol module provides the core types and interfaces for interacting with
8//! the Neo N3 blockchain protocol. It includes:
9//!
10//! - Account management and address handling
11//! - NEP-2 password-protected key format support
12//! - Protocol error definitions and handling
13//! - Response types for Neo N3 RPC calls
14//! - Role-based access control definitions
15//!
16//! This module forms the foundation for blockchain interactions, defining the data structures
17//! and interfaces that represent the Neo N3 protocol.
18//!
19//! ## Examples
20//!
21//! ### Working with Neo N3 accounts
22//!
23//! ```ignore
24//! use neo3::neo_protocol::{Account, AccountTrait};
25//!
26//! // Create a new account
27//! let account = Account::create().unwrap();
28//! println!("Address: {}", account.address());
29//! println!("Script Hash: {}", account.script_hash());
30//!
31//! // Create an account from a WIF (Wallet Import Format) string
32//! let wif = "KwYgW8gcxj1JWJXhPSu4Fqwzfhp5Yfi42mdYmMa4XqK7NJxXUSK7";
33//! let account = Account::from_wif(wif).unwrap();
34//!
35//! // Sign a message
36//! let message = b"Hello, Neo!";
37//! let signature = account.sign(message).unwrap();
38//!
39//! // Verify the signature
40//! let is_valid = account.verify(message, &signature).unwrap();
41//! assert!(is_valid);
42//! ```
43//!
44//! ### Using NEP-2 password-protected keys
45//!
46//! ```ignore
47//! use neo3::neo_crypto::PrivateKey;
48//! use neo3::neo_protocol::nep2::{encrypt_to_nep2, decrypt_from_nep2};
49//!
50//! // Encrypt a private key with a password (NEP-2 format)
51//! let private_key = PrivateKey::from_slice(&[/* 32 bytes */]).unwrap();
52//! let password = "your_secure_password_here";
53//! let nep2_string = encrypt_to_nep2(&private_key, password).unwrap();
54//!
55//! // Decrypt a NEP-2 string back to a private key
56//! let nep2_string = "6PYVPVe1fQznphjbUxXP9KZJqPMVnVwCx5s5pr5axRJ8uHkMtZg97eT5kL";
57//! let password = "your_secure_password_here";
58//! let private_key = decrypt_from_nep2(nep2_string, password).unwrap();
59//! ```
60
61pub use account::*;
62pub use nep2::*;
63pub use protocol_error::*;
64pub use responses::*;
65
66mod account;
67mod nep2;
68mod protocol_error;
69mod responses;
70mod role;