Skip to content

Commit

Permalink
Speed up to use libsecp256k1 with ExtPubkey#derive same as ExtKey#derive
Browse files Browse the repository at this point in the history
  • Loading branch information
azuchi committed May 12, 2021
1 parent e76b515 commit b3b2ec9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bitcoin/ext_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def derive(number)
l = Bitcoin.hmac_sha512(chain_code, data)
left = l[0..31].bth.to_i(16)
raise 'invalid key' if left >= CURVE_ORDER
p1 = Bitcoin::Secp256k1::GROUP.generator.multiply_by_scalar(left)
p1 = Bitcoin::Key.new(priv_key: left.to_s(16), key_type: Bitcoin::Key::TYPES[:uncompressed]).to_point
p2 = Bitcoin::Key.new(pubkey: pubkey, key_type: key_type).to_point
new_key.pubkey = (p1 + p2).to_hex
new_key.chain_code = l[32..-1]
Expand Down

0 comments on commit b3b2ec9

Please # to comment.