Skip to content

Commit cfa72ff

Browse files
committed
feat(dotnet): add conversion from Algorand.Crypto.KeyPair to Algorand.Unity.PrivateKey
1 parent 25beba1 commit cfa72ff

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Runtime/Algorand.Unity/Accounts/PrivateKey.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ public static explicit operator Algorand.Utils.Crypto.FixedSecureRandom(PrivateK
9797
return new Algorand.Utils.Crypto.FixedSecureRandom(pk.ToArray());
9898
}
9999

100+
public static explicit operator PrivateKey(Algorand.Crypto.KeyPair kp)
101+
{
102+
var pkBytes = kp.ClearTextPrivateKey;
103+
var result = new PrivateKey();
104+
result.CopyFrom(pkBytes, 0, 32);
105+
return result;
106+
}
107+
100108
public static explicit operator Algorand.Crypto.KeyPair(PrivateKey pk)
101109
{
102110
return new Algorand.Crypto.KeyPair((Algorand.Utils.Crypto.FixedSecureRandom)pk);

0 commit comments

Comments
 (0)