Added a lot of Doc
This commit is contained in:
parent
b094b12539
commit
d65bf5d97a
3 changed files with 118 additions and 2 deletions
|
|
@ -6,7 +6,7 @@ use serde::{Serialize, Deserialize};
|
|||
#[cfg(test)]
|
||||
use crate::dh::gen_key_pair;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct Header {
|
||||
pub public_key: PublicKey,
|
||||
pub pn: usize, // Previous Chain Length
|
||||
|
|
@ -20,7 +20,9 @@ struct ExHeader {
|
|||
n: usize
|
||||
}
|
||||
|
||||
// Message Header
|
||||
impl Header {
|
||||
#[doc(hidden)]
|
||||
pub fn new(dh_pair: &DhKeyPair, pn: usize, n: usize) -> Self {
|
||||
Header {
|
||||
public_key: dh_pair.public_key,
|
||||
|
|
@ -28,7 +30,7 @@ impl Header {
|
|||
n,
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub fn concat(&self) -> Vec<u8> {
|
||||
let ex_header = ExHeader{
|
||||
public_key: self.public_key.to_bytes(),
|
||||
|
|
@ -61,6 +63,12 @@ impl From<&[u8]> for Header {
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<Vec<u8>> for Header {
|
||||
fn into(self) -> Vec<u8> {
|
||||
self.concat()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Header {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
if self.public_key == other.public_key
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue