ig-crypto-utils/lib/ig-crypto-utils.rb
# for a 256-bit ECDSA curve, the uncompressed pubkey is 512 bits (256 bits of x, 256 bits of y, no sign bit).
# The compressed pubkey is 257 bits (256 bits of x, one bit of the sign of y).
for a 256-bit ECDSA curve, the uncompressed pubkey is 512 bits (256 bits of x, 256 bits of y, no sign bit).
The compressed pubkey is 257 bits (256 bits of x, one bit of the sign of y).
for a 256 - bit ECDSA curve the uncompressed pubkey is 512 bits ( 256 bits of x 256 bits of y no sign bit ) . The compressed pubkey is 257 bits ( 256 bits of x one bit of the sign of y ) .
def create_key_pair
      group_name = 'secp256k1'
      group = OpenSSL::PKey::EC::Group.new(group_name)
      group.point_conversion_form = :compressed
      curve = OpenSSL::PKey::EC.new(group)
      curve.generate_key
      public_key = curve.public_key
      private_key = curve.private_key
      pk_bn_bin = public_key.to_bn.to_s(2)
      sk_bn_bin = private_key.to_s(2)
      encoded_pk = Base64.encode64(pk_bn_bin)
      encoded_sk = Base64.encode64(sk_bn_bin)
      {:pk => encoded_pk, :sk => encoded_sk}
    end
def create_key_pair group_name = 'secp256k1' group = OpenSSL :: PKey :: EC :: Group . new ( group_name ) group . point_conversion_form = :compressed curve = OpenSSL :: PKey :: EC . new ( group ) curve . generate_key public_key = curve . public_key private_key = curve . private_key pk_bn_bin = public_key . to_bn . to_s ( 2 ) sk_bn_bin = private_key . to_s ( 2 ) encoded_pk = Base64 . encode64 ( pk_bn_bin ) encoded_sk = Base64 . encode64 ( sk_bn_bin ) { :pk => encoded_pk , :sk => encoded_sk } end
for a 256-bit ECDSA curve, the uncompressed pubkey is 512 bits (256 bits of x, 256 bits of y, no sign bit).
for a 256 - bit ECDSA curve the uncompressed pubkey is 512 bits ( 256 bits of x 256 bits of y no sign bit ) .
# set compression to true for key generation on the group # instantiate the curve and generate the keys # get binary representation of keys #base64 encode keys