显示 crate…
1 个不稳定版本
| 0.29.0 | 2021 年 3 月 15 日 |
|---|
#237 在 #tetcoin
用于 tet-libp2p
535KB
9K SLoC
Noise 协议框架 支持 libp2p。
注意:此 crate 仍然处于试验阶段,API 和底层协议可能会发生重大更改。
此 crate 为各种 noise 握手模式(目前为 IK、IX 和 XX)提供 tet_libp2p_core::InboundUpgrade 和 tet_libp2p_core::OutboundUpgrade 实现,针对特定的 Diffie–Hellman 密钥协议选择(目前仅为 X25519)。
注意:目前仅保证
XX握手模式与其他 libp2p 实现的互操作性。
所有升级都输出一个由远程的静态公钥和一个 NoiseOutput 组成的对,该 NoiseOutput 表示与远程建立的加密会话,实现 futures::io::AsyncRead 和 futures::io::AsyncWrite。
使用方法
示例
use tet_libp2p_core::{identity, Transport, upgrade};
use tet_libp2p_tcp::TcpConfig;
use tet_libp2p_noise::{Keypair, X25519Spec, NoiseConfig};
let id_keys = identity::Keypair::generate_ed25519();
let dh_keys = Keypair::<X25519Spec>::new().into_authentic(&id_keys).unwrap();
let noise = NoiseConfig::xx(dh_keys).into_authenticated();
let builder = TcpConfig::new().upgrade(upgrade::Version::V1).authenticate(noise);
// let transport = builder.multiplex(...);
依赖项
~10–15MB
~308K SLoC