treasurechest/treasurechest/chestcrypto/keys/doublekey/private.cs

41 lines
1.4 KiB
C#
Raw Normal View History

namespace chestcrypto{
public class DoublePrivateKey{
2020-05-12 08:06:13 +00:00
private byte[] signingPrivateKey = new byte[64];
private byte[] encryptPrivateKey = new byte[32];
2020-05-12 08:06:13 +00:00
private string signingPrivateKeyString;
private string encryptPrivateKeyString;
public byte[] getRawDouble(){
return ByteCombiner.Combine(signingPrivateKey, encryptPrivateKey);
}
public DoublePrivateKey(byte[] sign, byte[] encrypt){
2020-05-12 08:06:13 +00:00
if (sign.Length != 64){
2020-05-17 07:49:36 +00:00
throw new exceptions.InvalidDoubleKeyException("Signing private key must be 64 bytes in length.");
2020-05-12 08:06:13 +00:00
}
if (encrypt.Length != 32){
2020-05-17 07:49:36 +00:00
throw new exceptions.InvalidDoubleKeyException("Signing private key must be 32 bytes in length.");
2020-05-12 08:06:13 +00:00
}
signingPrivateKey = sign;
encryptPrivateKey = encrypt;
}
public DoublePrivateKey(byte[] combinedKey){
if (combinedKey.Length != 96){
2020-05-17 07:49:36 +00:00
throw new exceptions.InvalidDoubleKeyException("Invalid key length, must be 96 bytes in length");
2020-05-12 08:06:13 +00:00
}
for (int i = 0; i < combinedKey.Length; i++){
if (i < 64){
signingPrivateKey[i] = combinedKey[i];
continue;
}
encryptPrivateKey[i - 64] = combinedKey[i];
}
}
}
}