Crates.io | hive_memo |
lib.rs | hive_memo |
version | 0.1.2 |
source | src |
created_at | 2024-09-23 23:59:43.947121 |
updated_at | 2024-09-24 00:33:59.217984 |
description | A crate for encrypting and decrypting Hive Blockchain memos using elliptic curve cryptography and AES. |
homepage | https://github.com/LeoFinance/hive-memo-rs#readme |
repository | https://github.com/LeoFinance/hive-memo-rs |
max_upload_size | |
id | 1384572 |
size | 24,630 |
Hive Memo is a Rust crate designed for encrypting and decrypting memos using elliptic curve cryptography (ECC) and AES-256-CBC encryption, taking @hiveo/dhive's memo encryption and decryption methods into account.
Key Management
Parse and validate WIF (Wallet Import Format) private keys.
Handle public keys in Hive format (STM
prefixed).
Derive public keys from private keys.
Encryption & Decryption
Add hive_memo
to your Cargo.toml
:
[dependencies]
hive_memo = "0.1.0"
cargo add hive_memo
use hive_memo::keys::{wif_to_secret_key, public_key_from_string};
use hive_memo::encryption::encrypt_memo;
use std::error::Error;
fn main() {
// Sender's WIF private key
let sender_private_wif = "5KV4qZ1obXQPwUQqitD5Tx86Writ4tbeDAo68WLXhcU3ZaHR1M7";
// Receiver's public key in Hive format
let receiver_public_key_str = "STM5PQVrcekY3psFdYxRDXtYRNNWsPjeHtTvfhUtKaiADPvRqSVYM";
// Convert WIF to SecretKey
let sender_private_key = wif_to_secret_key(sender_private_wif)?;
// Convert Hive public key string to PublicKey
let receiver_public_key = public_key_from_string(receiver_public_key_str)?;
let memo = "#This is a secure memo";
// Encrypt the memo
let encrypted_memo = encrypt_memo(&sender_private_key, &receiver_public_key, memo)?;
println!("Encrypted Memo: {}", encrypted_memo);
}
use hive_memo::keys::wif_to_secret_key;
use hive_memo::encryption::decrypt_memo;
use std::error::Error;
fn main() {
// Receiver's WIF private key
let receiver_private_wif = "5KV4qZ1obXQPwUQqitD5Tx86Writ4tbeDAo68WLXhcU3ZaHR1M7";
// Encrypted memo string
let encrypted_memo = "#<Base58EncodedEncryptedMemo>";
// Convert WIF to SecretKey
let receiver_private_key = wif_to_secret_key(receiver_private_wif)?;
// Decrypt the memo
let decrypted_memo = decrypt_memo(&receiver_private_key, encrypted_memo)?;
println!("Decrypted Memo: {}", decrypted_memo);
}