Home > database >  Why is the answer of the pbkdf2 chilkat function for bip39 and creating a seed from a 12-word passwo
Why is the answer of the pbkdf2 chilkat function for bip39 and creating a seed from a 12-word passwo

Time:07-17

To generate seed from HDWallet's 12-word password, PBKDF2 formula with 2048 repetitions in HMAC-512 should be used. I have taken this formula from https://www.example-code.com/vb6/crypt2_pbkdf2.asp .

The following code for the sentence: "year rather cable response transfer abuse fade attend make multiply color subway" is:

Private Sub Command77_Click()
Dim crypt As New ChilkatCrypt2
Dim wpaHexKey As String
' The "ps" is the WPA passphrase
Dim pw As String
pw = ""
Dim pwCharset As String
pwCharset = "ansi"
' Hash algorithms may be: sha1, md2, md5, etc.
Dim hashAlg As String
hashAlg = "HMAC-SHA512"
' Specify the SSID in hex:
' For example, if the SSID is "ABC", then the
Dim ssidHex As Variant
ssidHex = crypt.EncodeString("year rather cable response transfer abuse fade 
attend make multiply color subway", "utf-8", "hex")
'MsgBox HexToBytes(CStr(TXTDEC))
' The WPA key calculation will always use 4096 iterations.
Dim iterationCount As Long
' The WPA hex output should be 256 bits.
Dim outputBitLen As Long
outputBitLen = 512
' Indicate that "hex" is to be returned.
Dim enc As String
enc = "hex"
TXTPBKDF2 = crypt.Pbkdf2(pw, pwCharset, hashAlg, ssidHex, iterationCount, 
outputBitLen, enc)
' The output should have this value:
' 284C82D68B4E5A244507A858851215344140FC401421E615A10E067BE4CE27C7FF54E037EEA93BCEE50FF337AAE167B5D482260DFD170889865E9169CEF0847B
End Sub

1

But the result of this function is not correct for the term Seed bip39, but when we enter the same 12-word code on the site https://iancoleman.io/bip39/, the result of seed bip39 is :

"a364230f7c915db7a36ed31ff8e23ad34d99694b012fb85b6592d2aa630fdc017a1c5a596293101966d73143f53eb2d1d4a0547640d3cfd29fc42012581f62c8"

2

The result on the site https://iancoleman.io/bip39/ is correct

Can you help me why the result is wrong in the ChilkatCrypt2 codes, is the way I am doing to generate bip39 wrong?

CodePudding user response:

See the example for BIP39 computation here: https://www.example-code.com/vb6/bip39_computation_of_binary_seed.asp

  • Related