Skip to content

Commit

Permalink
validate public key is not empty prior to parsing it
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadav Ivgi committed Nov 29, 2013
1 parent 84e1699 commit 2cae304
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/bitcoin/key.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Key.random = (compressed=true) ->

# Returns a new Key instance from public key hex string or byte array
Key.from_pubkey = (pub) ->
throw new Error 'Empty public key' unless pub?.length
pub = hexToBytes pub if typeof pub is 'string'
throw new Error 'Invalid public key length' unless pub.length in [ PUBKEY_LEN, PUBKEY_C_LEN ]
new Key 'pub', pub
Expand Down

0 comments on commit 2cae304

Please sign in to comment.