Subject: Re: OpenSSL ECDSA public key from private
	Date: Sun 28 Oct 12 05:59:21AM +0900

Quoting Nokan Emiro (uzleepito / gmail.com):

> ...I think EC_POINT_mul() could be a solution.  It's a C function
> in OpenSSL, and it does the calculation I need.  But I don't know
> much about how Ruby and C are married in native gems, and
> I think the Ruby API does not allow me to call this C function. :(
> 
> Or does it?

These mappings are generally done with quite a lot of care. Indeed,
you can call EC_POINT_mul() - the OpenSSL::PKey::EC::Point class has a
#mul method.

It can be called in four ways:

   point.mul(bn)  => point
   point.mul(bn, bn) => point
   point.mul([bn], [point]) => point
   point.mul([bn], [point], bn) => point

The EC_POINT_mul function is called if you pass one or two OpenSSL::BN
objects to it. 

If I execute this script:

require 'openssl'
key=OpenSSL::PKey::EC.new('secp256k1')
bn1=OpenSSL::BN::new('123')
bn2=OpenSSL::BN::new('456')
pubkey=OpenSSL::PKey::EC::Point.new(key.group).mul(bn1,bn2)
p pubkey.to_bn.to_s

I get a beautiful 155-digit number. Then, I have no idea about what
all these big numbers should be... 

The Openssl mapping is included in Matz's Ruby sources, under
ext/openssl.

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)