-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
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,53 @@ | ||
using System.Numerics; | ||
using NUnit.Framework; | ||
using Sui.Cryptography.Ed25519; | ||
using Sui.ZKLogin.SDK; | ||
using UnityEngine; | ||
|
||
namespace Sui.Tests.ZkLogin | ||
{ | ||
[TestFixture] | ||
public class NonceTest : MonoBehaviour | ||
{ | ||
int maxEpoch = 26; | ||
string pkBase64 = "lHezoWY/4pRWe+iajFHw62hQjmVQ6wlL+C8CJxw4bY0="; | ||
string pubKeyBase64Expected = "/CTTrykDrvNxtl0WfBo3Q+H/L9VLJAzwXAJew6cMP70="; | ||
|
||
//BigInteger randomness = 91593735651025872471886891147594672981; // too long | ||
//BigInteger randomness = 9159373565102587247; | ||
BigInteger randomness = BigInteger.Parse("91593735651025872471886891147594672981"); | ||
|
||
/// <summary> | ||
/// PrivateKey: | ||
/// {"schema":"ED25519","privateKey":"lHezoWY/4pRWe+iajFHw62hQjmVQ6wlL+C8CJxw4bY0="} | ||
/// PublicKey: | ||
/// "/CTTrykDrvNxtl0WfBo3Q+H/L9VLJAzwXAJew6cMP70=" | ||
/// </summary> | ||
[Test] | ||
public void GenerateNonceTest() | ||
{ | ||
PrivateKey pk = new PrivateKey(pkBase64); | ||
string pubKey = pk.PublicKey().KeyBase64; | ||
|
||
Assert.AreEqual(pubKeyBase64Expected, pubKey); | ||
|
||
string nonce = NonceGenerator.GenerateNonce( | ||
(PublicKey)pk.PublicKey(), | ||
maxEpoch, | ||
randomness | ||
); | ||
|
||
string nonceExpected = "LSLuhEjHLSeRvyI26wfPQSjYNbc"; | ||
Debug.Log("RAND: LOG: " + randomness); | ||
Assert.AreEqual(nonceExpected, nonce, "RAND: " + randomness.ToString()); | ||
} | ||
|
||
[Test] | ||
public void ToBigIntBETest() | ||
{ | ||
byte[] bytes = { }; | ||
BigInteger toBigintBE = NonceGenerator.ToBigIntBE(bytes); | ||
Assert.AreEqual(null, bytes, "BigInteger Valye: " + "[IMPLEMENT]"); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.