0
$\begingroup$

I want to check if some pubkey belongs to twisted edwards25519 (I guess this is used for ed25519 ?) The problem is that I have in theory some valid pubkeys like:

hash_hex = "3afe3342f7192e52e25ebc07ec77c22a8f2d1ba4ead93be774f5e4db918d82a0"
or
hash_hex = "fd739be0e59c072096693b83f67fb2a7fd4e4b487e040c5b128ff602504e6c72"

and to check if they are valid I use from libsodium:

auto result = crypto_core_ed25519_is_valid_point(reinterpret_cast<const unsigned char*>(hash_hex.c_str()));

and the thing is that for those pubkeys which should be in theory valid, I have in both cases 0 as a result, which means that checks didn't pass (according to https://doc.libsodium.org/advanced/point-arithmetic#point-validation). So my question is if I am using this function wrong ? should that key be delivered in another form ? or maybe somehow those keys are not valid for some reasons (I have them from some coin explorer, so in theory they should be valid) ? is there some online tool where I can check if those pubkey belongs to that eliptic curve ?

$\endgroup$
4
  • 1
    $\begingroup$ It looks like you're not converting the hex to bytes. I unfortunately have no knowledge of that language, but you should use sodium_hex2bin. $\endgroup$ Aug 10 at 11:16
  • $\begingroup$ @Samuel, oh I see, why I need to do such a conversion ? I am asking because I don't see such a thing in libsodium doc unless I missed something :P $\endgroup$
    – bladzio
    Aug 10 at 11:44
  • 1
    $\begingroup$ I checked, and your hex points are valid. The only data type in the C language that is 8 bits is a char, which is why crypto libraries in C use char* for byte arrays. The libsodium docs do not appear to explicitly state that they are expecting raw byte sequences, but it's not normal for crypto libraries to operate on ASCII hex strings. $\endgroup$
    – knaccc
    Aug 10 at 12:11
  • 1
    $\begingroup$ here is the function. @knaccc is right. I've written a libsodium binding for C#, and it involves passing a byte array/pointer. $\endgroup$ Aug 10 at 12:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy