#x25519 #quantum #pqc-kyber

pqx

启用使用量子抗性Kyber和X25519进行密钥传输

2个不稳定版本

0.2.0 2024年6月23日
0.1.0 2024年6月22日

#502 in 密码学

MIT/Apache

22KB
371 代码行

PQX

使用X25519和PQC-Kyber交换密钥以实现量子抗性。

用法

# Cargo.toml

[dependencies]
pqx = "0.1"
// main.rs
use std::sync::mpsc::channel;
use std::time::Duration;
use std::thread;
use pqx::*;
let (sender1, receiver1) = channel();
let (sender2, receiver2) = channel();
let thread = thread::spawn(move || {
    let bob_s = Combinedkey::default();
    let bob_p = Combinedpub::new(&bob_s);
    sender1.send(bob_p).unwrap();
    let cipher = receiver2.recv_timeout(Duration::new(60,0)).unwrap();
    let cipher = Combinedcipher::from(cipher);
    Combinedshared::new(bob_s, cipher).unwrap()
});
let alice_s = Combinedkey::default();
let pubkey = receiver1.recv_timeout(Duration::new(60,0)).unwrap();
let kyberelem = Combinedcipher::new(&alice_s,&pubkey).unwrap();
sender2.send(kyberelem.getcipher()).unwrap();
let shared = Combinedshared::getfromshared(kyberelem, pubkey, alice_s).unwrap().getshared(SHAREDSIZE::Med);
let result = thread.join().unwrap().getshared(SHAREDSIZE::Med);
assert!(shared==result,"Invalid shared, got {:#?} and {:#?}",shared,result);
//println!("Valid shared, got {}",hex::encode(shared.get()))

信息

此crate尚未经过任何安全审计,应谨慎使用。

依赖关系

~2–12MB
~141K SLoC