File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 1
1
using Chaos . NaCl ;
2
2
using Solnet . Wallet . Utilities ;
3
+ using System ;
3
4
using System . Diagnostics ;
4
5
5
6
namespace Solnet . Wallet
@@ -50,7 +51,23 @@ public Account(byte[] privateKey, byte[] publicKey)
50
51
PrivateKey = new PrivateKey ( privateKey ) ;
51
52
PublicKey = new PublicKey ( publicKey ) ;
52
53
}
54
+ /// <summary>
55
+ /// Initialize an account with the passed secret key
56
+ /// </summary>
57
+ /// <param name="secretKey">The private key.</param>
58
+ public static Account FromSecretKey ( string secretKey )
59
+ {
60
+ var B58 = new Base58Encoder ( ) ;
61
+ byte [ ] skeyBytes = B58 . DecodeData ( secretKey ) ;
62
+ if ( skeyBytes . Length != 64 )
63
+ {
64
+ throw new ArgumentException ( "Not a secret key" ) ;
65
+ }
53
66
67
+ Account acc = new Account ( skeyBytes , skeyBytes . Slice ( 32 , 64 ) ) ;
68
+
69
+ return acc ;
70
+ }
54
71
/// <summary>
55
72
/// Verify the signed message.
56
73
/// </summary>
You can’t perform that action at this time.
0 commit comments