secp256kfun icon indicating copy to clipboard operation
secp256kfun copied to clipboard

Feedback for `secp256k1`

Open Kixunil opened this issue 2 years ago • 2 comments

From your readme:

type safety: Error cases you would typically have to deal with when using other APIs are ruled out at compile time using rust's type system.

Could you give examples or help to make the upstream secp256k1 itself more type safe? I think this kind of thing belongs there.

Kixunil avatar Dec 19 '22 17:12 Kixunil

note secp256k1 is not upstream from this crate. secp256k1 offers a high level API which is pretty type safe for most things that are designed to be done with it.

To give an example where secpfun's type safety is better than secp1s, when multiplying a non-zero point by a non-zero scalar we can rule out zero being a possibility here where as in secp256k1 you have to deal with a result: https://docs.rs/secp256k1/0.25.0/secp256k1/struct.PublicKey.html#method.mul_tweak.

This is not really a big deal though since you are not meant to implement crypto algorithms with secp1. The zero/non_zero type provided by secpfun really shines when you are implementing schnorr, musig, frost zkps from these primitives (which you should absolutely not do using secp1's API). It has caught loads of my mistakes!

LLFourn avatar Dec 19 '22 23:12 LLFourn

Oh, so mul_tweak we should have NonZeroScalar and have a conversion for ThirtyTwoBitHash. That makes sense.

Kixunil avatar Dec 20 '22 07:12 Kixunil