Skip to content

Commit

Permalink
[ORTHOGONAL] Add docs to identity_key!
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed May 5, 2021
1 parent 3dc1b26 commit 1a5a515
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion rust/protocol/src/identity_key.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
//
// Copyright 2020 Signal Messenger, LLC.
// Copyright 2020-2021 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//

// TODO
// #![warn(missing_docs)]

//! Wrappers over identity primitives from [crate::curve].

use crate::proto;
use crate::{KeyPair, PrivateKey, PublicKey, Result, SignalProtocolError};

Expand All @@ -11,6 +16,7 @@ use std::convert::TryFrom;

use prost::Message;

/// Wrapper for [PublicKey].
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy)]
pub struct IdentityKey {
public_key: PublicKey,
Expand Down Expand Up @@ -51,20 +57,23 @@ impl From<PublicKey> for IdentityKey {
}
}

/// Wrapper for [KeyPair].
#[derive(Copy, Clone)]
pub struct IdentityKeyPair {
identity_key: IdentityKey,
private_key: PrivateKey,
}

impl IdentityKeyPair {
/// Create a new key pair from a public `identity_key` and a private `private_key`.
pub fn new(identity_key: IdentityKey, private_key: PrivateKey) -> Self {
Self {
identity_key,
private_key,
}
}

/// Generate a cryptographically random new identity from randomness in `csprng`.
pub fn generate<R: CryptoRng + Rng>(csprng: &mut R) -> Self {
let keypair = KeyPair::generate(csprng);

Expand Down

0 comments on commit 1a5a515

Please sign in to comment.