-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ECDSA With Public Key Recovery #41
Comments
I agree that the current API has the limitation. |
Okay, I looked into this but there are some things I am unsure about. Key Recovery Information in
|
Apparently this is related to the problem of "ECDSA Malleability". I do not know how important it is for crypton to avoid this problem. It might also be acceptable to push this responsibility downstream and have users of the |
Another question is if the functions in |
What I can suggest is two ways: Easy way: provide your own new ECDSA module, e.g., Crypto.PubKey.ECC.ECDSA.Parity. This maintain backward compatibility completely. Difficult way: stop exporting If you want to provide signature normalization, the best way is provide test cases to show that the current code is not perfect. Then add a commit to fix it. This convinces me that there is actually a problem and it is surely fixed. |
I would like to avoid adding a third ECDSA module if you are okay with a breaking change and major version bump. In my opinion, the public key recovery information should not be part of the data Signature = Signature { r :: Integer, s :: Integer }
type ExtendedSignature = (Bool, Signature)
sign :: PrivateKey -> Digest -> ExtendedSignature
verify :: PublicKey -> Digest -> Signature -> Bool
recover :: Digest -> ExtendedSignature -> PublicKey I think it would be really strange for I am not yet sure if it would be better to have
From what I understand, there is no problem that needs to be fixed, and it is just a matter of how the signature is used. Also, the entire normalization problem can just be solved with postprocessing of the signature after it is generated. So the |
One technique to maintain backward compatibility is to provide a new function name: sign :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m) => PrivateKey -> hash -> msg -> m Signature
sign' :: whatever you want What do you think? |
I think it really depends on how important backwards compatibility is to you. If you do not care about breaking changes, then I think changing the existing |
I can also make a draft PR tomorrow and then you can see what it would look like. Then you can tell me if you think that is okay or if you would rather have additional functions. |
I prefer to adding functions since I want to avoid breaking changes if possible. |
I want to use crypton to sign transactions in the Ethereum protocol. This is done via ECDSA but with a parity output for public key recovery in addition to the regular
r
ands
parameters in the signature.This additional parity output is easily calculated given both coordinates of the
pointMul curve k g
value. Unfortunately,Crypto.PubKey.ECC.ECDSA.signDigestWith
does not expose these and there is no intermediate function either, so I currently have to basically copy most ofsignDigestWith
and make small adjustments to get a version that includes the parity information. In fact, theweb3-crypto
package does exactly that in itsCrypto.Ecdsa.Signature.sign
function (see https://github.com/airalab/hs-web3/blob/master/packages/crypto/src/Crypto/Ecdsa/Signature.hs).Is there a proper way to do this? If not, would it be possible to extend the
Crypto.PubKey.ECC.ECDSA.Signature
record to include more information?The text was updated successfully, but these errors were encountered: