8
votes
Accepted
Splitting a Solana Keypair into Public and Private Keys
The first 32 values represent the private key:
private_key_bytes = [4, 182, 130, 247, 119, 117, 227, 207, 112, 73, 170, 126, 222, 197, 244, 99, 215, 107, 255, 202, 33, 43, 36, 17, 104, 111, 157, 246, ...
6
votes
Accepted
How do you generate a base58 private key?
You can generate the base58 private key with the following code in js:
var web3 = require('@solana/web3.js')
var bs58 = require('bs58')
let keypair = web3.Keypair.generate()
let base58PrivateKey = ...
5
votes
Accepted
Does Solana have an official Python implementation?
No, to my knowledge, this is the most popular (unofficial) one, and there is not one officially supported by the Solana Foundation.
However, that unofficial one's most recent version is built with the ...
5
votes
Accepted
How do off-curve public keys work?
What exactly is an off-curve address used for?
An off-curve address is anything that isn't on-curve so like you said any address which cannot have a corresponding private key.
so if you craft up an ...
4
votes
Creating a Custom Vanity Key / Wallet
When a Solana wallet is generated using a mnemonic, is has a set "derivation path". The reason the wallet you generated with the CLI is different in the CLI and in your web wallet is because ...
4
votes
Accepted
Are wallet addresses "created" or are they "discovered"?
There is a subtle difference between the terms address, keypair and account.
As you mention correctly, keypairs (and with them addresses, which is just a public key) can be created off-chain, and can ...
4
votes
Accepted
How do I import and export a wallet keypair generated from CLI to a wallet provider like phantom or solflare?
Open the the .json file created by the CLI and copy the contents(it should look like [12,54,11,64,etc...]). Then go to the wallet you want to use, select import private key and paste the contents.
...
4
votes
Accepted
ValueError: signature error: Cannot decompress Edwards point
This is a mistake in the cookbook. It's passing in a seed to from_bytes, when there's already a Keypair.from_seed implementation. Use that instead, ie:
mnemo = Mnemonic("english")
words = ...
3
votes
Accepted
How do I sign a message with my keypair
You can sign a message a message using Javscript with the following:
import { Keypair } from "@solana/web3.js";
import nacl from "tweetnacl";
import { decodeUTF8 } from "...
3
votes
Accepted
Is there a rust crate for generating solana keypairs?
Yes, the solana_sdk crate provides this
use solana_sdk::signature::{Keypair};
fn main() {
let wallet = Keypair::new();
}
3
votes
How to create a Keypair json in solana.py?
That library misuses a bunch of words. I believe the secret_key field is in fact the full keypair (ed25519 secret/private keys are 32-bytes). You should be able to convert the byte array into a uint ...
3
votes
Accepted
How to bypass wallet approval and use the keypair on backend?
The first picture is my provider, where I get my provider, wallet and keypair (you don't need this one TBH).
In the second picture I'm fetching the same parameters I exported and using them to call ...
3
votes
How to bypass wallet approval and use the keypair on backend?
So what I did was, To make transactions on backend, You need a wallet right. I saved a private key on the .env file and used that as my private key, Then I created a keypair from it, Then I imported a ...
3
votes
Accepted
Deriving a public key from a private key programmatically
You can use tweetnacl to generate pubkey from the secret key.
...
import * as nacl from 'tweetnacl';
import * as bs58 from 'bs58';
...
export function deriveSolAddressFromKey(key: string): string {
...
3
votes
Accepted
How do I create a keypair using a custom derivation path with Javascript?
Using Javascript
This can be done with the ed25519-hd-key and tweetnacl libraries.
Make sure you start the path with m/44'/501', as this is required for Solana addresses.
Setup (run this in your ...
3
votes
Accepted
When importing wallet by mnemonic phrase, how can I check whether it is correct or not?
try something like:
if(bip39.validateMnemonic("test test test....junk") === true) { // do things }
3
votes
How to generate a number of Solana addresses
I'd suggest using web3.js for this:
import { Keypair } from '@solana/web3.js';
for (let i = 0; i < NUM_TO_GENERATE; i++){
const kp = Keypair.generate();
console.log(kp.secretKey);
...
3
votes
How is a Solana wallet created behind the hood?
You've got it! Unlike EVM where the pubkey still gets hashed and cropped, a Solana keypair is nothing more than a normal ed25519 keypair. Using OpenSSH or any other tool/library that correctly ...
2
votes
How to i sign message with Keypair in rust
If you have a Keypair, you can simply call sign_message on the Signer trait, which would look like:
let keypair = Keypair::new();
let message = "To avoid digital dognappers, sign below to ...
2
votes
Accepted
how can I read a keypair from a json file that contains many objects?
You can get the number array for the desired keypair as a Vec<serde_json::Value> within the JSON file using serde_json and convert it to a Vec<u8> using serde::from_value.
Once you have ...
2
votes
Accepted
How should generate account keys be treated?
In this scenario, the keypair is used to generate the Account and the Owner of the Account Is the custom executing program. Hence If the Keypair is compromised, a malicious actor is unable to do ...
2
votes
How I can create a wallet from keypair in frontend?
import NodeWallet from '@project-serum/anchor/dist/cjs/nodewallet'
let wallet = new NodeWallet(Keypair.generate())
2
votes
Keypair.generate() vs creating keypair with solana-keygen?
The main difference is that Keypair.generate() generates a new random keypair everytime, while Keypair.fromSecretKey() allows you to deterministically load a keypair that you've generated earlier. In ...
2
votes
Accepted
How to get public and secret key from keypair Solders
It's in bytes and is correct, but my understanding is the keys are commonly Base58 encoded.
You can do the following:
import base58 # You'll need to install this
def create_keypair():
kp = ...
2
votes
Accepted
Converting a generated keypair into a base58 or seed phrase?
For converting your Public Key into base58, look at this reference.
Also, it is not possible to generate a mnemonic from a Keypair.
However, the vice-versa is true, as highlighted in the docs you ...
2
votes
Can another wallet pay for, Sign and Send transaction signature of another Keypair
Yes. you can however, there are some caveats:
If the keypair is used as the payer it will need enough funds for gas fees + account rent exemption.
You can then use the partialSign method to ...
2
votes
How do you generate a base58 private key?
Jacob's answer is fine, but here's a slightly more modern example for ESM modules:
npm i bs58 @types/bs58
Then:
import { Keypair } from "@solana/web3.js";
import { encode } from "bs58&...
2
votes
Does program keypair has any other usage besides program deployment?
The primary purpose of the program keypair in Solana is indeed for the initial deployment of a program. The keypair is used to sign the instructions during the creation of the program account, ...
2
votes
How to convert Keypair.secret_key to Phantom compatible private key in python?
I solved this today and the issue for me was with how I was generating the PrivateKey. The private key is a combination of the private+public key in bytes and this is then base 58 decoded here is my ...
2
votes
How to convert Keypair.secret_key to Phantom compatible private key in python?
Since Keypair.generate() doesn't even exist anymore, and the class itself has been moved into solders.py, here's an up-to-date(solana.py v0.32, solders v0.20) solution:
I tried all of this and a lot ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
keypair × 58wallet × 13
private-key × 7
python × 6
solana-program × 6
solana-keygen × 6
rust × 5
anchor × 4
account × 4
validator × 4
publickey × 4
web3.js × 4
pubkey × 4
address × 4
transactions × 3
seed × 3
phantom × 3
token × 3
signature × 2
pda × 2
error × 2
deploy × 2
cli × 2
solana-cli × 2
node.js × 2