Skip to content

Commit 964d268

Browse files
committed
feat(demo): add KeyUtils.ParseEd25519PublicKey
1 parent 6aadf4a commit 964d268

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

TonLibDotNet.Demo/Samples/KeysAndMnemonics.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.Extensions.Logging;
2+
using TonLibDotNet.Utils;
23

34
namespace TonLibDotNet.Samples
45
{
@@ -31,6 +32,9 @@ public async Task Run(bool inMainnet)
3132
var key = await tonClient.CreateNewKey(localPass, mnemonicPass, randomExtra);
3233
logger.LogInformation("New key: public = {PublicKey}, secret = {Secret}", key.PublicKey, key.Secret);
3334

35+
var decodedPublicKey = KeyUtils.Instance.ParseEd25519PublicKey(key.PublicKey);
36+
logger.LogInformation("Decoded public key (hex): {Value}", Convert.ToHexString(decodedPublicKey).ToLowerInvariant());
37+
3438
var ek = await tonClient.ExportKey(key, localPass);
3539
logger.LogInformation("Mnemonic for this key is: {Words}", string.Join(" ", ek.WordList));
3640

@@ -41,7 +45,8 @@ public async Task Run(bool inMainnet)
4145
logger.LogInformation("Same key exported with password: {Value}", eek.Data);
4246

4347
var euk = await tonClient.ExportUnencryptedKey(key, localPass);
44-
logger.LogInformation("Same key in unencrypted form: {Value}", euk.Data);
48+
logger.LogInformation("Same key in unencrypted form (base64): {Value}", euk.Data);
49+
logger.LogInformation("Same key in unencrypted form (hex): {Value}", Convert.ToHexString(Convert.FromBase64String(euk.Data)).ToLowerInvariant());
4550

4651
//// does not work, see https://github.com/ton-blockchain/ton/issues/202
4752
//// key = await tonClient.ChangeLocalPassword(key, localPass, Convert.ToBase64String(new byte[] { 7, 6, 5 }));

0 commit comments

Comments
 (0)