mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
rename EphemeralPublic to PublicKey
This commit is contained in:
parent
9c5650113e
commit
9fe535dcc7
1 changed files with 13 additions and 13 deletions
|
|
@ -23,18 +23,18 @@ use curve25519_dalek::scalar::Scalar;
|
|||
use rand_core::RngCore;
|
||||
use rand_core::CryptoRng;
|
||||
|
||||
/// A DH ephemeral public key.
|
||||
pub struct EphemeralPublic(pub (crate) MontgomeryPoint);
|
||||
/// A DH public key.
|
||||
pub struct PublicKey(pub (crate) MontgomeryPoint);
|
||||
|
||||
impl From<[u8; 32]> for EphemeralPublic {
|
||||
/// Given a byte array, construct an x25519 `EphemeralPublic` key
|
||||
fn from(bytes: [u8; 32]) -> EphemeralPublic {
|
||||
EphemeralPublic(MontgomeryPoint(bytes))
|
||||
impl From<[u8; 32]> for PublicKey {
|
||||
/// Given a byte array, construct a x25519 `PublicKey`.
|
||||
fn from(bytes: [u8; 32]) -> PublicKey {
|
||||
PublicKey(MontgomeryPoint(bytes))
|
||||
}
|
||||
}
|
||||
|
||||
impl EphemeralPublic {
|
||||
/// View this ephemeral public key as a byte array.
|
||||
impl PublicKey {
|
||||
/// View this public key as a byte array.
|
||||
#[inline]
|
||||
pub fn as_bytes(&self) -> &[u8; 32] {
|
||||
self.0.as_bytes()
|
||||
|
|
@ -55,7 +55,7 @@ impl EphemeralSecret {
|
|||
/// Utility function to make it easier to call `x25519()` with
|
||||
/// an ephemeral secret key and montegomery point as input and
|
||||
/// a shared secret as the output.
|
||||
pub fn diffie_hellman(self, their_public: &EphemeralPublic) -> SharedSecret {
|
||||
pub fn diffie_hellman(self, their_public: &PublicKey) -> SharedSecret {
|
||||
SharedSecret(self.0 * their_public.0)
|
||||
}
|
||||
|
||||
|
|
@ -72,11 +72,11 @@ impl EphemeralSecret {
|
|||
|
||||
}
|
||||
|
||||
impl<'a> From<&'a EphemeralSecret> for EphemeralPublic {
|
||||
impl<'a> From<&'a EphemeralSecret> for PublicKey {
|
||||
/// Given an x25519 `EphemeralSecret` key, compute its corresponding
|
||||
/// `EphemeralPublic` key.
|
||||
fn from(secret: &'a EphemeralSecret) -> EphemeralPublic {
|
||||
EphemeralPublic((&ED25519_BASEPOINT_TABLE * &secret.0).to_montgomery())
|
||||
/// `PublicKey` key.
|
||||
fn from(secret: &'a EphemeralSecret) -> PublicKey {
|
||||
PublicKey((&ED25519_BASEPOINT_TABLE * &secret.0).to_montgomery())
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue