Skip to content

Commit 1afd011

Browse files
committed
Fixed bugs in two of the ZCert constructors with keys as argument
1 parent 35ceb0e commit 1afd011

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ZCert.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public ZCert(byte[] publicKey, byte[] secretKey)
118118
{
119119
throw new InvalidOperationException("secret key length must be of length 32");
120120
}
121-
Array.Copy(secretKey, this.secretKey, 32);
121+
Array.Copy(publicKey, this.publicKey, 32);
122122
Array.Copy(secretKey, this.secretKey, 32);
123123

124124
publicTxt = Encoding.UTF8.GetString(Z85.Encode(publicKey)).ToCharArray();
@@ -145,8 +145,9 @@ public ZCert(string publicTxt, string secretTxt)
145145
PublicTxt = publicTxt;
146146
SecretTxt = secretTxt;
147147

148-
publicKey = Z85.EncodeBytes(PublicTxt);
149-
secretKey = Z85.EncodeBytes(SecretTxt);
148+
publicKey = Z85.ToZ85DecodedBytes(PublicTxt);
149+
secretKey = Z85.ToZ85DecodedBytes(SecretTxt);
150+
150151
}
151152

152153
/// <summary>
@@ -204,7 +205,7 @@ public void Apply(ZSocket socket)
204205
/// </summary>
205206
/// <param name="cert">Certificate to deep clone. Public and private keys must not be null.</param>
206207
/// <returns>A copy of the given certificate.</returns>
207-
public ZCert Dup(ZCert cert)
208+
public static ZCert Dup(ZCert cert)
208209
{
209210
if (cert == null)
210211
return null;

0 commit comments

Comments
 (0)