Module: TencentTrustsql::Tools::KeyGenerator::ClassMethods

Defined in:
lib/tencent_trustsql/tools/key_generator.rb

Instance Method Summary collapse

Instance Method Details

#encoded_public_key(private_key) ⇒ Object

获取公钥字符串



33
34
35
36
37
38
# File 'lib/tencent_trustsql/tools/key_generator.rb', line 33

def encoded_public_key private_key
  pub_key = public_key(private_key)
  output_formatter.out_public_key pub_key
  # public_key_string = ECDSA::Format::PointOctetString.encode(pub_pair, compression: true).force_encoding('utf-8')
  # Base64.encode64(public_key_string).gsub(/[\n]/, '')
end

#public_key(p_key) ⇒ Object

获取公钥



23
24
25
26
27
28
29
30
# File 'lib/tencent_trustsql/tools/key_generator.rb', line 23

def public_key(p_key)
  if p_key.respond_to? :length
    p p_key = input_formatter.localize_private_key(p_key)
  end

  public_key = CURVE.generator.multiply_by_scalar(p_key)
  # ECDSA::Format::PointOctetString.encode(public_key, compression: true)
end

#user_private_keyObject

新建用户私钥



16
17
18
19
# File 'lib/tencent_trustsql/tools/key_generator.rb', line 16

def user_private_key
  p private_key = 1 + SecureRandom.random_number(CURVE.order - 1)
  output_formatter.out_private_key private_key
end