@@ -60,10 +60,9 @@ SecureString CMnemonic::FromData(const SecureVector& data, int len)
6060 int mlen = len * 3 / 4 ;
6161 SecureString mnemonic;
6262
63- int i, j, idx;
64- for (i = 0 ; i < mlen; i++) {
65- idx = 0 ;
66- for (j = 0 ; j < 11 ; j++) {
63+ for (int i = 0 ; i < mlen; i++) {
64+ int idx = 0 ;
65+ for (int j = 0 ; j < 11 ; j++) {
6766 idx <<= 1 ;
6867 idx += (bits[(i * 11 + j) / 8 ] & (1 << (7 - ((i * 11 + j) % 8 )))) > 0 ;
6968 }
@@ -76,7 +75,7 @@ SecureString CMnemonic::FromData(const SecureVector& data, int len)
7675 return mnemonic;
7776}
7877
79- bool CMnemonic::Check (SecureString mnemonic)
78+ bool CMnemonic::Check (const SecureString& mnemonic)
8079{
8180 if (mnemonic.empty ()) {
8281 return false ;
@@ -98,7 +97,7 @@ bool CMnemonic::Check(SecureString mnemonic)
9897 SecureString ssCurrentWord;
9998 SecureVector bits (32 + 1 );
10099
101- uint32_t nWordIndex, ki, nBitsCount{};
100+ uint32_t ki, nBitsCount{};
102101
103102 for (size_t i = 0 ; i < mnemonic.size (); ++i)
104103 {
@@ -110,7 +109,7 @@ bool CMnemonic::Check(SecureString mnemonic)
110109 ssCurrentWord += mnemonic[i + ssCurrentWord.size ()];
111110 }
112111 i += ssCurrentWord.size ();
113- nWordIndex = 0 ;
112+ uint32_t nWordIndex = 0 ;
114113 for (;;) {
115114 if (!wordlist[nWordIndex]) { // word not found
116115 return false ;
@@ -140,7 +139,7 @@ bool CMnemonic::Check(SecureString mnemonic)
140139}
141140
142141// passphrase must be at most 256 characters otherwise it would be truncated
143- void CMnemonic::ToSeed (SecureString mnemonic, SecureString passphrase, SecureVector& seedRet)
142+ void CMnemonic::ToSeed (const SecureString& mnemonic, const SecureString& passphrase, SecureVector& seedRet)
144143{
145144 SecureString ssSalt = SecureString (" mnemonic" ) + passphrase;
146145 SecureVector vchSalt (ssSalt.begin (), ssSalt.begin () + strnlen (ssSalt.data (), 256 ));
0 commit comments