09-02-2020 08:21 PM - edited 09-02-2020 08:32 PM
This is driving me nuts. I attempted to modify a base64 VI. I get the 51 characters I am looking for but they are not correct. I am using the modified base58 Character set, it doesn't use 0O or L.
Solved! Go to Solution.
09-03-2020 03:01 AM - edited 09-03-2020 03:11 AM
Hi n2,
there is so much wrong in your VI…
First point: there is no comment describing the algorithm you want to implement! How should we (and you) know, if your implementation fits to your requirements when you don't document the requirements?
Next point: silly implementations and using wrong datatypes!
Example:
Your implementation at the top uses way too much code, produces coercion dots, does silly conversions (from should-be U8 array to string and back to U8 array). The implementation below produces the same output in the correct datatype (for valid inputs)…
This one is also very silly:
What is the expected remainder when you calculate the remainder of an integer number divided by 1?
Why are there any orange wires at all? You should NEVER try to index bits from a boolean array using fractional indexes! (Here my first point comes into play: please describe/document the algorithm you want to implement!)
Why is the output labelled "Base64" when all the rest talks about "Base58"?
09-03-2020 06:13 AM
Thank you much for the tip! So the base58 in this case is specific to Bitcoin and some other cryptocurrency's.
In my Front panel shows a valid hey derived from the hex input. If use another program or web API, I get the correct private key output (5KasYynWv1ZtzvEAmvb51a4FpbA4hUwf78Y6L2kdbLZnNDpHBPZ) This Key will always start with 5 as the hex key is always prefixed with 4 bytes (80) then double hashed with sha-256 and a checksum. Here is a quick explanation of the base58 I am trying implement. https://en.wikipedia.org/wiki/Base58. The idea was to create an app so that I can covert the hex private key to what is known as WIF, Wall import format. This is more of journey to for me to understand the cryptography behind it. Forgive my playing around the fractions. I am just having troubling visualizing the code. I for to mention that the letter uppercase (i) is also excluded in this implementation. The erroy message is silly but I didn't do that. That was example found I found for base64. Thanks so much for you help!
Tom
09-03-2020 06:46 AM
Hi n2,
here's what I found about Base58 encoding.
See how far you get with this algorithm and ask when you run into specific problems…
09-03-2020 06:54 AM
Hi,
Base64 algorithm cannot be applied on base58. Here's an example I created based on the algorithm described here.
09-03-2020 06:57 AM
From https://en.bitcoin.it/wiki/Base58Check_encoding:
code_string = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" x = convert_bytes_to_big_integer(hash_result) output_string = "" while(x > 0) { (x, remainder) = divide(x, 58) output_string.append(code_string[remainder]) } repeat(number_of_leading_zero_bytes_in_hash) { output_string.append(code_string[0]); } output_string.reverse();
09-03-2020 07:18 AM - edited 09-03-2020 07:26 AM
@TCChun wrote:
Hi,
Base64 algorithm cannot be applied on base58. Here's an example I created based on the algorithm described here.
That inner while loop is a for loop with auto indexing. That will be faster.
In the first for loop, the build array can be replaced with concatenating indexing. The VI was probably build before that was possible? Benefit of the doubt...
Repeating converting the Boolean array to number will be slow... Rotate Left With Carry does exactly that.
The last loop is redundant.
Anyway, AFAIC your post should be marked as solution.
Before:
After:
09-03-2020 07:25 AM
Thanks, I have labview 2016 only, could you save for previous version and repost? Thanks!
Tom
09-03-2020 07:28 AM
This one's in LV13.
09-03-2020 07:36 AM
Thanks much! As usual, the solution should have been obvious to me!