From: Nokan Emiro Date: 2012-10-28T04:23:52+09:00 Subject: Re: OpenSSL ECDSA public key from private --14dae93a1145533fc204cd0f604c Content-Type: text/plain; charset=UTF-8 Thanks Carlo, but it's not what I was looking for. I know about #generate_key. It creates a random private key and calculates the corresponding public key too. But I already have a (non-random) private key. (I mean it is an input for my script.) Now what I need is to set my own private key, and calculate the public key that matches my already existing private key. I have a private key which is not a random number. Well, maybe it was some time ago in another software, but for now, I can read it from a file, and I have no problem setting that data as a private key. The problem is that I need the public key that matches the private one. So what I need is to ask the 'key' object to be so kind and calculate the the public key for me using my private key I've just set with #private_key=. key.private_key = ** * * key.plese_calculate_the_public_key_from_the_private_one! u. On Sat, Oct 27, 2012 at 8:37 PM, Carlo E. Prelz wrote: > Subject: OpenSSL ECDSA public key from private > Date: Sun 28 Oct 12 03:28:36AM +0900 > > Quoting Nokan Emiro (uzleepito@gmail.com): > > > Setting the private_key works fine, but I need to calculate the > public_key > > too. > > I'm sure there's a way to ask the key object to calculate the > corresponding > > public key, I just don't know how. > > I have never done this myself before , but I was curious, and gave it > a look. > > Your OpenSSL::PKey::EC instance has a method called > #generate_key. After I run > > key.generate_key > > I find that key.private_key is populated with an instance of > OpenSSL::BN, and key.public_key is populated with an instance of > OpenSSL::PKey::EC::Point. > > I hope this is what you were looking for. > > Carlo > > -- > * Se la Strada e la sua Virtu' non fossero state messe da parte, > * K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe > * di parlare tanto di amore e di rettitudine? (Chuang-Tzu) > > --14dae93a1145533fc204cd0f604c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks Carlo, but it's not what I was looking for. =C2=A0I know about #= generate_key.
It creates a random private key and calculates the corres= ponding public key
too. =C2=A0But I already have a (non-random) p= rivate key. =C2=A0(I mean it is an input
for my script.)

Now what I need is to set my = own private key, and calculate the public key
that matches my alr= eady existing private key. =C2=A0I have a private key which is
no= t a random=C2=A0number. =C2=A0Well, maybe it was some time ago in another s= oftware,
but for now, I can read it from a file, and I have no problem setting = that
data as a private key. =C2=A0The problem is that I need the = public key that
matches the private one.

So what I need is to ask the 'key' object to be so kind and calcula= te the the
public key for me using my private key I've just s= et with #private_key=3D.

key.private_key =3D =C2=A0 <a paramether from outs= ide>

key.plese_calculate_the_public_key_fr= om_the_private_one!

u.



On Sat, Oct 27, 2012 at 8= :37 PM, Carlo E. Prelz <fluido@fluido.as> wrote:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Subject: OpenSSL ECDSA public key from private<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Date: Sun 28 Oct 12 03:28:36AM +0900

Quoting Nokan Emiro (uzleepito@gmail= .com):

> Setting the private_key works fine, but I need to calculate the public= _key
> too.
> I'm sure there's a way to ask the key object to calculate the = corresponding
> public key, I just don't know how.

I have never done this myself before , but I was curious, and gave it=
a look.

Your OpenSSL::PKey::EC instance has a method called
#generate_key. After I run

key.generate_key

I find that key.private_key is populated with an instance of
OpenSSL::BN, and key.public_key is populated with an instance of
OpenSSL::PKey::EC::Point.

I hope this is what you were looking for.

Carlo

--
=C2=A0 * =C2=A0 =C2=A0 =C2=A0 =C2=A0 Se la Strada e la sua Virtu' non f= ossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 che bisogno ci sarebbe
=C2=A0 * =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 di parlare tanto = di amore e di rettitudine? (Chuang-Tzu)


--14dae93a1145533fc204cd0f604c--