How can get a mnemonic phrase wallet key (12 words ) from a private key? - private-key

How can you get a mnemonic phrase wallet key (12 words login key) from a private key?
actually I Will create a mobile app in flutter and a web app in react js
so can you please guide me

It's the other way around. Multiple private keys can be derived from the mnemonic phrase, but it's not mathematically possible to derive the phrase from a private key.
See the original BIP39 standard introducing the mnemonic phrase: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

Related

How to Use Private key to encrypt a message and decrypt it using the same block's public key?

I am building a DApp where I want to add a message to all the blocks that shows that the blocks are created by the same company i.e my website and no one can replicate that message. So, I think the best way is to add a message to every block that is encrypted using the block's private key and anyone else can decrypt the message using the block's public key. Is this possible? If yes, then how? I am using web3.js and solidity.
P.S- I know the concept of digital signature it is pretty much the same...but in my case I don't want to verify the user who has signed the block but I just want to verify if the block is from my website or not.

Find private Key from a set of public keys

my old laptop suddenly died and I need to recover my private/pub keys.
I manage to recover the files from the HD but I have around 400 private keys.
I know tho, my public key.
Is it possible to figured out which one is the right private key associated to that specific public key, looking among a set of 400 keys?
Any tips is very welcome!

Is it possible to generate a public key from private key?

If yes then they are really not a pair.
I was trying to figure out how ssh git#github.com resolves my name using my private key. SSH debug suggests public key is passed to server.
Yes, it is possible.
Sidebar: I'm not sure what you mean by, "they are really not a pair". A pair is when you have two things. A public key and a private key are two things, ergo, you have a pair. The fact that you can derive one from the other is immaterial.
I don't know how github does this, but my guess is simply that they use the public key to identify your account (your public key is unique, pretty much by definition).
I hope this answers your question. I have a feeling I'm not quite getting it.
No, it's not possible.
Neither private key, nor public key cannot be produced form the other one. Remember, private key is the same as public key by design and we call them public or private optionally (keeping one of them private and reveal the other).

How to export a public key in OpenSSL/libcrypto?

I've created an RSA key using:
RSA_generate_key(2048, RSA_F4, NULL, NULL);
Now I want to export the public key to another party B. Right now, I've just memcpy'd the entire RSA* struct and sent that over the wire, and B is able to use that to encrypt using RSA_public_encrypt().
But I think in this case I've actually exported the entire public/private key pair, and not just the public key. I want to only export the public component of the RSA key. How do I use OpenSSL APIs to do that?
Thanks
You probably want the functions d2i_RSAPublicKey and i2d_RSAPublicKey. i2d serializes a RSA key struct to a bytestring, and d2i does the reverse operation.

Importing a private-public exchange key pair

I want to export a RSA 1024 private-public exchange key pair from Machine-1 to Machine-2. I am using cryptoAPI in XP.
In Machine-1, I generated the key pair. I wrapped a session key which actually encrypts some real data. The key container name is "PAIR1".
In Machine-2, I wanted to unwrap the session key with the private key(which I generated in Machine-1). For this purpose, I wanted to export the key pair from Machine-1 to Machine-2.
I am aware of security flaws of exporting the persistent keys.
What I have tried?
I exported the keypair as a PKCS#12 -pfx file from Machine_1. When i imported it to Machine-2, the key container name has changed from "PAIR1" to nothing. My application requires the same container name to pick the right private key in the exchange key pair. Is it possible to change the key container name?
Will this work?
Wrap the exchange key pair with Machine-2's public key and import it to Machine-2. In this case, do think, the key container name will remain the same or will it change? I feel that this might be the right approach.
Edited:
The reason I asked this query is because I wrapped a session key with an exchange key pair (public key) and put the wrapped key along with the encrypted data in a medium at the server.
This medium will go-around different clients and will come back to the server. At this point, I will be decrypting my data with the unwrapped session key. This unwrapping needs the exchange private key.
I am doing this for a demo purpose and I cannot expect our marketing guys to perform key exchange etc. We wanted to show the client the security aspects and reduce the hassle of setting up things with our marketing guys.
Finally I exported the key pair and imported the same where ever I wanted though Ramsus approach is the right way of doing it.
The right way to do this, is to generate the keypair on machine-2, export the public key only, transport this to machine-1 and use it to wrap the session key.
How did you export and import the PKCS#12-file? Windows will usually add the key container name as a proprietary extension inside the PKCS#12-file, so it should have been transported together with the rest of the key pair.

Resources