generated from CareBoo/UPMTemplate-2020
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dotnet): use
Algorand2_Unity
instead of Algorand2
this fixes the issues associated with linking between assemblies
- Loading branch information
1 parent
6fec83a
commit 3df8515
Showing
34 changed files
with
155 additions
and
876 deletions.
There are no files selected for viewing
99 changes: 0 additions & 99 deletions
99
Algorand.Unity.Package/Assets/Resources/PerformanceTestRunInfo.json
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
Algorand.Unity.Package/Assets/Resources/PerformanceTestRunInfo.json.meta
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
Runtime/Algorand.Unity.Net/Extensions/PrivateKeyExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Algorand.Unity.LowLevel; | ||
using Algorand.Utils.Crypto; | ||
using Algorand.Crypto; | ||
|
||
namespace Algorand.Unity.Net | ||
{ | ||
public static class PrivateKeyExtensions | ||
{ | ||
public static KeyPair ToDotnet(this PrivateKey from) | ||
{ | ||
var fsr = new FixedSecureRandom(from.ToArray()); | ||
return new KeyPair(fsr); | ||
} | ||
|
||
public static PrivateKey ToUnity(this KeyPair from) | ||
{ | ||
var pkBytes = from.ClearTextPrivateKey; | ||
var result = new PrivateKey(); | ||
result.CopyFrom(pkBytes, 0, 32); | ||
return result; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Runtime/Algorand.Unity.Net/Extensions/PrivateKeyExtensions.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
Runtime/Algorand.Unity.Net/Extensions/SignatureExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System.Linq; | ||
using Algorand.Unity.Crypto; | ||
using Algorand.Unity.LowLevel; | ||
using Unity.Collections; | ||
|
||
namespace Algorand.Unity.Net | ||
{ | ||
public static class SignatureExtensions | ||
{ | ||
public static Signature ToDotnet(this Sig from) | ||
{ | ||
return from == default ? null : new Signature(from.ToArray()); | ||
} | ||
|
||
public static Sig ToUnity(this Signature from) | ||
{ | ||
if (from == null) | ||
{ | ||
return default; | ||
} | ||
var bytes = from.Bytes; | ||
var sig = default(Sig); | ||
sig.CopyFrom(bytes, 0); | ||
return sig; | ||
} | ||
|
||
public static MultisigSignature ToDotnet(this MultisigSig from) | ||
{ | ||
return new MultisigSignature | ||
{ | ||
Version = from.Version, | ||
Threshold = from.Threshold, | ||
Subsigs = from.Subsigs.Select(ToDotnet).ToList() | ||
}; | ||
} | ||
|
||
public static MultisigSig ToUnity(this MultisigSignature from) | ||
{ | ||
return new MultisigSig | ||
{ | ||
Subsigs = from.Subsigs.Select(ToUnity).ToArray(), | ||
Threshold = (byte)from.Threshold, | ||
Version = (byte)from.Version | ||
}; | ||
} | ||
|
||
public static MultisigSubsig ToDotnet(this MultisigSig.Subsig from) | ||
{ | ||
return new MultisigSubsig(from.PublicKey.ToArray(), from.Sig.ToArray()); | ||
} | ||
|
||
public static MultisigSig.Subsig ToUnity(this MultisigSubsig from) | ||
{ | ||
var pk = new Ed25519.PublicKey(); | ||
var subsigKeyBytes = from.key.GetEncoded(); | ||
pk.CopyFrom(subsigKeyBytes, 0); | ||
return new MultisigSig.Subsig | ||
{ | ||
PublicKey = pk, | ||
Sig = from.sig.ToUnity() | ||
}; | ||
} | ||
|
||
public static LogicsigSignature ToDotnet(this LogicSig from) | ||
{ | ||
return new Algorand.LogicsigSignature( | ||
from.Program, | ||
from.Args.Select(a => a.ToArray()).ToList(), | ||
from.Sig == default ? null : from.Sig.ToArray(), | ||
from.Multisig.ToDotnet() | ||
); | ||
} | ||
|
||
public static LogicSig ToUnity(this LogicsigSignature from) | ||
{ | ||
var args = new FixedList128Bytes<byte>[from.Args.Count]; | ||
for (var i = 0; i < args.Length; i++) | ||
{ | ||
args[i] = new FixedList128Bytes<byte>(); | ||
for (var j = 0; j < from.Args[i].Length; j++) | ||
{ | ||
args[i][j] = from.Args[i][j]; | ||
} | ||
} | ||
|
||
return new LogicSig | ||
{ | ||
Program = from.Logic, | ||
Args = args, | ||
Multisig = from.Msig.ToUnity(), | ||
Sig = from.Sig.ToUnity() | ||
}; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Runtime/Algorand.Unity.Net/Extensions/SignatureExtensions.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.