Skip to content

Commit

Permalink
added private key signing
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtau committed Jun 28, 2022
1 parent 9d2d10b commit 5cce766
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- `[tendermint]` Added conversions from signing requests to consensus states
and private key signing
([#1134](https://github.com/informalsystems/tendermint-rs/issues/1134))
9 changes: 8 additions & 1 deletion tendermint/src/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{de, ser, Deserialize, Serialize};
use subtle_encoding::{Base64, Encoding};
use zeroize::Zeroizing;

use crate::{prelude::*, public_key::PublicKey};
use crate::{prelude::*, public_key::PublicKey, Signature};

pub const ED25519_KEYPAIR_SIZE: usize = 64;

Expand Down Expand Up @@ -38,6 +38,13 @@ impl PrivateKey {
PrivateKey::Ed25519(signing_key) => Some(signing_key),
}
}

/// Sign a message with this private key
pub fn sign(&self, signable_msg_bytes: &[u8]) -> Signature {
match self {
PrivateKey::Ed25519(signing_key) => signing_key.sign(signable_msg_bytes).into(),
}
}
}

/// Serialize an Ed25519 keypair as Base64
Expand Down

0 comments on commit 5cce766

Please sign in to comment.