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
// Copyright (c) Subzero Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
//! Keyring management module for the Rialo blockchain.
//!
//! This module provides functionality for managing cryptographic signing keys,
//! including key derivation, storage, and transaction signing. It replaces the
//! previous `wallet` module with more accurate terminology.
//!
//! # Terminology
//!
//! - **Keyring**: A collection of derived keypairs, optionally backed by a mnemonic
//! - **DerivedKeypair**: A single Ed25519 keypair with its derivation metadata
//! - **KeyringProvider**: A trait for keyring storage and lifecycle management
//!
//! # Submodules
//!
//! - [`traits`]: Core keyring and keypair traits (`Keyring`, `DerivedKeypair`, `KeyringProvider`)
//! - [`memory`]: In-memory keyring provider for testing
//! - [`mod@file`]: File-based keyring provider for persistent storage
//! - [`provider_base`]: Base trait with utility methods for providers
//! - [`encryption`]: Encryption utilities for secure key storage
//! - [`mnemonic`]: BIP39 mnemonic and HD key derivation
//!
//! # Example
//!
//! ```rust,no_run
//! use rialo_cdk::keyring::{Keyring, InMemoryKeyringProvider, KeyringProvider};
//! use ed25519_dalek::SigningKey as Keypair;
//!
//! #[tokio::main]
//! async fn main() -> rialo_cdk::Result<()> {
//! // Create an in-memory keyring provider
//! let provider = InMemoryKeyringProvider::new();
//!
//! // Create a new keyring
//! let keyring = provider.create("my_keys", "password").await?;
//!
//! // Sign a message
//! let message = b"Hello, Rialo!";
//! let signature = keyring.sign(message);
//!
//! // Get the public key for on-chain operations
//! let pubkey = keyring.pubkey();
//! println!("Public key: {}", pubkey);
//!
//! Ok(())
//! }
//! ```
//!
//! # Note
//!
//! Keyrings manage cryptographic keys, NOT assets. On-chain accounts hold tokens;
//! keyrings hold the keys needed to sign transactions that interact with those accounts.
// Re-export main types
pub use FileKeyringProvider;
pub use FileWalletProvider;
pub use InMemoryKeyringProvider;
pub use InMemoryWalletProvider;
pub use BaseKeyringProvider;
pub use BaseWalletProvider;
// === Backward compatibility re-exports ===
pub use ;
pub use ;