-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
crypto: add secp256r1 #8559
crypto: add secp256r1 #8559
Conversation
crypto/keys/ecdsa/ecdsa_pubkey.go
Outdated
compressed[1] = byte(pk.Y.Bit(0)) | 2 | ||
pk.X.FillBytes(compressed[2:]) | ||
return compressed | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When serializing I'm adding additional byte to add curve information. Alternative design would be to use duplicate structures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still a couple of tmcrypto.Address and XXX lying around, but apart from that I'm good with this PR 👍
} | ||
|
||
// PrivKey defines a secp256r1 ECDSA private key. | ||
message PrivKey { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need a PrivKey in protobuf? This should not be created in our keyring but just by hardware devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created it for completeness. Do you prefer to remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I don't have a strong preference, but generally prefer to not include things which won't/shouldn't be used. For tests we have an internal privkey to use already right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, tests and private key generation will work with the internal/ecdsa
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so I will remove the PrivKey proto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sdkcrypto.PrivKey
interface requires to be proto.Message
. While it doesn't need to implement Marsha and Unmarshal method, it's meant to be used in protobuf ecosystem as well as being marshaled (eg proto.Marshal(pb proto.Message)
. Hence I think it's better to keep the proto file and generated files. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. There are a few minor improvements that could be made before merging. Otherwise it has enough approvals
I've added and then removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge when you're ready @robert-zaremba
Description
closes: #7718
This design follows the
ecdsa
design in Go stdlib: we have one structure for all ecdsa keysWhen serializing key, we are prepending one byte to store information about the key type. For any other ecdsa key, we don't need to create different structure.
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes