-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not return err
when pass random str or invalid privateKey
to func PrivateKeyFromBase58
#232
Comments
Also, I want to add some notes if pass panic: runtime error: slice bounds out of range [x:x] | panic: ed25519: bad private key length If pass correct |
Hi @Almazatun , can you explain what is the "some other behaviour"?
Can you give the sample of the code that give that exact error? It will help us to debugging. Thank you |
@pikomonde Thank you very much for your reply. The invalidPrivateKey := "6HsFaXKVD7mo43oTbdqyGgAnYFeNNhqY75B3JGJ6K8a227KjjG3uW3v"
_, err := solana.PrivateKeyFromBase58(invalidPk)
fmt.Println(err) Is this the correct behavior of the method? |
Ah, I got your question now. My question is, how do you know that |
@pikomonde You can copy and paste it to |
I'm not sure if it is the correct behaviour or not (I think we need to compare with solana's official client) But I think it is invalid because it is not on the a valid "ed25519" pair, and unfortunately the golang's "crypto/ed25519" package not providing a valid validation for it. Need to implement using this: https://security.stackexchange.com/questions/233099/validating-an-ed25519-public-key (haven't check it yet) So I think there are 2 action items:
|
Just realized that there is already a function provided by this library:
|
I just tried to use the
func
tovalidate private key
but got some other behavior thatfunc
.https://github.com/gagliardetto/solana-go/blob/main/keys.go#L48
It's correct behavior ?
The text was updated successfully, but these errors were encountered: