diff --git a/PeerTalk/src/Cryptography/EphermalKey.cs b/PeerTalk/src/Cryptography/EphermalKey.cs
index 2a0992d4..4bdad86c 100644
--- a/PeerTalk/src/Cryptography/EphermalKey.cs
+++ b/PeerTalk/src/Cryptography/EphermalKey.cs
@@ -2,6 +2,7 @@
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
+using Org.BouncyCastle.Utilities;
using ProtoBuf;
using System;
using System.Collections.Generic;
@@ -42,15 +43,21 @@ public byte[] PublicKeyBytes()
///
/// Create a shared secret between this key and another.
///
- ///
- ///
+ ///
+ /// Another ephermal key.
+ ///
+ ///
+ /// The shared secret as a byte array.
+ ///
+ ///
+ /// Uses the ECDH agreement algorithm to generate the shared secet.
+ ///
public byte[] GenerateSharedSecret(EphermalKey other)
{
var agreement = AgreementUtilities.GetBasicAgreement("ECDH");
agreement.Init(privateKey);
- return agreement
- .CalculateAgreement(other.publicKey)
- .ToByteArrayUnsigned();
+ var secret = agreement.CalculateAgreement(other.publicKey);
+ return BigIntegers.AsUnsignedByteArray(agreement.GetFieldSize(), secret);
}
///