Skip to content

Commit

Permalink
feat(dotnet): add conversion from Algorand.Crypto.KeyPair to `Algor…
Browse files Browse the repository at this point in the history
…and.Unity.PrivateKey`
  • Loading branch information
jasonboukheir committed Nov 25, 2022
1 parent 25beba1 commit cfa72ff
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Runtime/Algorand.Unity/Accounts/PrivateKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ public static PrivateKey FromString(string keyString)
return new Algorand.Utils.Crypto.FixedSecureRandom(pk.ToArray());
}

public static explicit operator PrivateKey(Algorand.Crypto.KeyPair kp)
{
var pkBytes = kp.ClearTextPrivateKey;
var result = new PrivateKey();
result.CopyFrom(pkBytes, 0, 32);
return result;
}

public static explicit operator Algorand.Crypto.KeyPair(PrivateKey pk)
{
return new Algorand.Crypto.KeyPair((Algorand.Utils.Crypto.FixedSecureRandom)pk);
Expand Down

0 comments on commit cfa72ff

Please sign in to comment.