3个版本
0.1.3 | 2024年8月12日 |
---|---|
0.1.2 | 2024年8月9日 |
0.1.0 | 2024年8月6日 |
#1655 in 密码学
每月 512 次下载
在ghostkey中使用
32KB
636 行
Ghostkey库(ghostkey_lib)
一个用于在Freenet生态系统中创建和管理ghost密钥和证书的Rust库。
功能
- 创建和验证代理证书
- 创建和验证ghost密钥证书
- RSA和Ed25519加密操作
- 证书的序列化和反序列化
主要组件
DelegateCertificateV1
: 表示由主密钥签名的代理证书GhostkeyCertificateV1
: 表示由代理密钥签名的ghost密钥证书Armorable
: 用于将对象序列化和反序列化到/从字节和武装字符串的特质
用法
将以下内容添加到您的Cargo.toml
[dependencies]
ghostkey_lib = "0.1.2" # Replace with the latest version
示例用法
use ghostkey_lib::{DelegateCertificateV1, GhostkeyCertificateV1, util::create_keypair};
use rand_core::OsRng;
// Create a master key pair
let (master_signing_key, master_verifying_key) = create_keypair(&mut OsRng).unwrap();
// Create a delegate certificate
let info = "Test Delegate".to_string();
let (delegate_certificate, delegate_signing_key) =
DelegateCertificateV1::new(&master_signing_key, &info).unwrap();
// Create a ghost key certificate
let (ghost_key_certificate, ghost_key_signing_key) =
GhostkeyCertificateV1::new(&delegate_certificate, &delegate_signing_key);
// Verify the ghost key certificate
let verified_info = ghost_key_certificate
.verify(&Some(master_verifying_key))
.unwrap();
assert_eq!(verified_info, info);
许可证
ghostkey_lib
遵循GNU Lesser General Public License v3.0。
依赖项
~8MB
~161K SLoC