---
title: How to Validate a Public Key
description:
  "Public keys on Solana can be validated with a small amount of code. Learn how
  to validate public keys on Solana."
---

In certain special cases (e.g. a Program Derived Address), public keys may not
have a private key associated with them. You can check this by looking to see if
the public key lies on the ed25519 curve. Only public keys that lie on the curve
can be controlled by users with wallets.

<CodeTabs storage="cookbook" flags="r">

```ts !! title="Legacy" file=packages/docs-examples/cookbook/wallets/check-publickey/legacy.ts#region=check

```

```rust !! title="Rust" file=packages/docs-examples/cookbook/wallets/check-publickey/rust/src/main.rs#region=check

```

```py !! title="Python"

from solders.pubkey import Pubkey

def main():
    # on curve address
    key = Pubkey.from_string("5oNDL3swdJJF1g9DzJiZ4ynHXgszjAEpUkxVYejchzrY")
    print(key.is_on_curve())

    off_curve_address = Pubkey.from_string("4BJXYkfvg37zEmBbsacZjeQDpTNx91KppxFJxRqrz48e")
    print(off_curve_address.is_on_curve())

if __name__ == "__main__":
    main()
```

</CodeTabs>
