Implement secp256k1 and P256 crypto to full extent
Clarification and motivation
In !170 (merged) I've added secp256k1 and p256 crypto along with tz2 and tz3 addresses. However, there are some leftovers.
I tried to fully properly implement secp256k1 crypto, but was in hurry and couldn't do it quickly. The main obstacle is decoding: I couldn't find such functionality in cryptonite
and didn't want to add other dependencies. I've opened an issue about that. I think that implementing decoding from compressed format should be doable, I just decided to postpone it due to high importance of TM-89 and because it's not really necessary now (we just need to preserve decode . encode === id
property).
After that I didn't have time to work on proper P256, so for P256 I only store a bytestring and always return False
from checkSignature
.
These only visible effect of this leftover is that checkSignature
doesn't work correctly. We should make it work exactly as it does in the reference implementation.
Acceptance criteria
Here is what should be done:
- Implement decoding for
secp256k1
. I would do it withcryptonite
, but a backup option is to use anothersecp256k1
library (I am not sure there is a good one that will work though). After thatSecp256k1.PublicKey
can be turned back to anewtype
(pkBytes
hack can be removed). - Once it's done, check whether
checkSignature
works correctly. There are tests inTest.Tezos.Crypto
already, just updatesdValid
there. - Then implement P256 crypto. I know there is some P256 functionality in
cryptonite
, but I didn't look at it closely. Make sure to add tests. - Go over TODOs mentioning
#18
, make sure there are none.
Actual criteria:
- There are tests where
secp256k1
andp256
signatures are verified with public keys. Valid and invalid cases. We should assert that results are the same as fortezos-client
. - No TODOs mentioning
#18
are left.