Author

Topic: check sum a base58 private key (Read 151 times)

legendary
Activity: 1512
Merit: 7340
Farewell, Leo
December 28, 2021, 07:53:30 AM
#7
Since you want it to be .NET, check Autarkysoft.Bitcoin/Encoders/Base58.cs of Coding Enthusiast. The boolean you're searching is IsValid(string encoded). Check his stuff, he has done some pretty good work.
newbie
Activity: 23
Merit: 2
December 28, 2021, 07:52:00 AM
#6
Please check carefully the code I sent you. There is method DecodeWithChecksum, which returns correctly decoded private key or throws exception if checksum is invalid, just like you want.

oh yes just saw that, will try it out, thank you Smiley
legendary
Activity: 952
Merit: 1386
December 28, 2021, 07:48:07 AM
#5
Please check carefully the code I sent you. There is method DecodeWithChecksum, which returns correctly decoded private key or throws exception if checksum is invalid, just like you want.
legendary
Activity: 3668
Merit: 6382
Looking for campaign manager? Contact icopress!
December 28, 2021, 07:46:47 AM
#4
Although it tells it's not optimized, you may find useful parts for your needs here: https://gist.github.com/CodesInChaos/3175971
Another one I've found is https://github.com/adamcaudill/Base58Check and you can get it as NuGet package.
Both are not my code, I've just found them on the internet.


newbie
Activity: 23
Merit: 2
December 28, 2021, 07:45:16 AM
#3
thank you for the information.

is there no library out there ? all i want to do is run some code that does

print IsValidKey("testkey")

i.e. prints true or false

there must be some library out there already that does that?
legendary
Activity: 952
Merit: 1386
December 28, 2021, 07:39:59 AM
#2
Take a look here:
https://learnmeabitcoin.com/technical/wif

Checksum is in fact double sha256. You will have to decode your private key, remove last 4 bytes (8 decoded characters), calculate double hash and compare first 4 bytes (8 characters) of result with checksum received after decoding WIF.

Maybe this is what you look for:
https://gist.github.com/CodesInChaos/3175971#file-base58encoding-cs
newbie
Activity: 23
Merit: 2
December 28, 2021, 07:32:17 AM
#1
hi,

i want some code, preferably .net (c# or vb.net) to check sum base 58 (51 character) private keys to see if they are valid or not.

can anyone point me in the right direction?

thank you

Jump to: