From a83654ca4c5cd010c1df49f9709e63ed9dc73b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Klaehn?= Date: Wed, 13 May 2020 17:08:12 +0200 Subject: [PATCH] Add a method to create a pre shared key when you already have the raw bytes (#1570) --- protocols/pnet/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/protocols/pnet/src/lib.rs b/protocols/pnet/src/lib.rs index ab9b0bc3..496cd7d6 100644 --- a/protocols/pnet/src/lib.rs +++ b/protocols/pnet/src/lib.rs @@ -55,6 +55,11 @@ const FINGERPRINT_SIZE: usize = 16; pub struct PreSharedKey([u8; KEY_SIZE]); impl PreSharedKey { + /// Create a new pre shared key from raw bytes + pub fn new(data: [u8; KEY_SIZE]) -> Self { + Self(data) + } + /// Compute PreSharedKey fingerprint identical to the go-libp2p fingerprint. /// The computation of the fingerprint is not specified in the spec. ///