jmcardon / tsec

Type-safe general-cryptography library - https://jmcardon.github.io/tsec/
MIT License
350 stars 58 forks source link

ECKFTag methods are misnamed? #197

Open fiadliel opened 6 years ago

fiadliel commented 6 years ago

Some comments on methods in ECKFTag:

buildPrivateKeyFromPoint/unsafeBuildPrivateKeyFromPoint delegate to java.security.spec.ECPrivateKeySpec, and the parameter passed is "the private value S". This is a secret value, not a point, so the method are misnamed.

unsafeBuildPublicKeyFromPoints delegates to java.security.spec.ECPublicKeySpec, and the parameters passed in are the affine x-coordinate and affine y-coordinate of the public point of the curve. Since we are passing in the coordinates of a single point, not multiple points, this method is also misnamed.

One more thing to note: there is a lack of symmetry between buildPublicKey and unsafeBuildPublicKeyFromPoints, since in most other cases, unsafe is appended to another method name without any other changes.

jmcardon commented 6 years ago

You're right and naming is hard.

jmcardon commented 6 years ago

Also, to be honest, tsec 0.1 should really revamp these to just return Option.

Majority of these unsafeBlah is just laziness on my part when I wrote them months ago. There's no real observable side effect from doing this, despite forcing a try/catch