diff --git a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto.Tests/RandomTest.cs b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto.Tests/RandomTest.cs index f2f60263d..b5f2ba56b 100644 --- a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto.Tests/RandomTest.cs +++ b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto.Tests/RandomTest.cs @@ -28,7 +28,7 @@ internal struct TestStruct [Test] public void CanGenerateRandomBytesForType() { - var test = Random.RandomBytes(); + var test = Random.Bytes(); UnityEngine.Debug.Log($"{test.byte0000},{test.byte0001},{test.byte0002},{test.byte0003},{test.byte0004}"); } } diff --git a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto.Tests/Sha512Test.cs b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto.Tests/Sha512Test.cs index fb1974cce..1f7a214fc 100644 --- a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto.Tests/Sha512Test.cs +++ b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto.Tests/Sha512Test.cs @@ -10,7 +10,7 @@ public class Sha512Test [Test] public void Sha512IsTruncatedTo32Bytes() { - var seed = AlgoSdk.Crypto.Random.RandomBytes(); + var seed = AlgoSdk.Crypto.Random.Bytes(); var hash = AlgoSdk.Crypto.Sha512.Hash256Truncated(seed); Assert.AreEqual(32, hash.Length); } diff --git a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto/Random.cs b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto/Random.cs index 396305ba6..0bdfbc7e8 100644 --- a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto/Random.cs +++ b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Crypto/Random.cs @@ -11,7 +11,7 @@ static Random() sodium_init(); } - public static T RandomBytes() where T : unmanaged + public static T Bytes() where T : unmanaged { var size = UnsafeUtility.SizeOf(); T result = default; diff --git a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Tests/MnemonicTest.cs b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Tests/MnemonicTest.cs index daa05ba36..fad5f6bde 100644 --- a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Tests/MnemonicTest.cs +++ b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk.Tests/MnemonicTest.cs @@ -6,7 +6,7 @@ public class MnemonicTest { private string RandomMnemonicString() { - var key = Random.RandomBytes(); + var key = Random.Bytes(); var mnemonic = key.ToMnemonic(); return mnemonic.ToString(); } diff --git a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/Account.cs b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/Account.cs index 5f90fa0f5..2d2dbd228 100644 --- a/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/Account.cs +++ b/Packages/com.careboo.unity-algorand-sdk/CareBoo.AlgoSdk/Account.cs @@ -1,12 +1,22 @@ -using System; - namespace AlgoSdk { - public struct Account + public readonly struct Account { + readonly public PrivateKey PrivateKey; + readonly public Address Address; + + public Account(in PrivateKey privateKey, in Address address) + { + PrivateKey = privateKey; + Address = address; + } + + public Account(in PrivateKey privateKey) : this(in privateKey, privateKey.ToAddress()) { } + public static Account Generate() { - throw new NotImplementedException(); + var privateKey = Crypto.Random.Bytes(); + return new Account(in privateKey); } } }