Stacks.js: encryptECIES: verify that the public key is a secp256k1 point

Created on 28 May 2020  路  6Comments  路  Source: blockstack/stacks.js

The encryptECIES method in src/encryption/ec.ts does not verify that the given public key string encodes a point on the secp256k1 curve. While this doesn't pose a security risk in our case -- the worst an attacker can do with this is recover the ephemeralSK by using a specially-crafted public key -- it would still be better from a correctness standpoint to verify that the publicKey string is indeed a secp256k1 point. This can be achieved by either checking that publicKey is a compresssed secp256k1 public key, or if it isn't, compressing it and decompressing it and verifying that the re-decompressed public key is equal to the original public key (and that the compress and decompress steps don't throw an exception).

help wanted good first issue P3

All 6 comments

Gonna tackle this. What should be the desired result be if the key is not valid? Should it throw an exception? Or return something else?

Hey @gdstewart , thank you for reaching out and expressing interest. I know it's been a while, but it would be great to hear if you made any progress. As you can probably see, this repo has been refactored into a monorepo with multiple packages. This code is now in the @stacks/encryption NPM package, and the code referenced in this issue is now in packages/encryption/src/ec.ts.

I have not, but I'll take a look again this coming week when I get a chance

I am working on this issue. Assigning it to myself.

@agraebe This needs to be closed as PR is merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markmhx picture markmhx  路  7Comments

yknl picture yknl  路  7Comments

yknl picture yknl  路  5Comments

larrysalibra picture larrysalibra  路  6Comments

agraebe picture agraebe  路  3Comments