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 4, 2021
1 parent 63b9b23 commit 8acc32c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rust/protocol/src/identity_key.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//
// Copyright 2020 Signal Messenger, LLC.
// Copyright 2020-2021 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//

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

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

Expand All @@ -11,6 +13,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 +54,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 8acc32c

Please sign in to comment.