-
Notifications
You must be signed in to change notification settings - Fork 141
secp256r1: Deprecate openssl types in public API #126
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
Conversation
#### Problem This is anza-xyz#114, but for secp256r1 instead, removing external types from the public interface. #### Summary of changes This one was a bit more complicated because it uses openssl types, which aren't as straightforward as simple bytes, so it uses bytes encoded in DER as the interface. This seemed like the most standard format from simple web searching, but I'm certainly no expert in this area. There seemed to also be a lot of vecs in the new instruction implementation, which shouldn't be necessary, so I changed those to arrays.
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.
Looks good to me! Just two minor comments below.
secp256r1-program/src/lib.rs
Outdated
|
|
||
| pub fn sign_message( | ||
| message: &[u8], | ||
| der: &[u8], |
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.
This looks fine, but should we rename the der variable to priv_key_bytes_der or priv_key_der to be more specific? der can mean an encoding for signatures as well, so it might be worth making it clear from just the function syntax (though we immediately parse as a signing key below).
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.
Makes sense to me! I went with priv_key_bytes_der
| } | ||
|
|
||
| assert_eq!(pubkey.len(), COMPRESSED_PUBKEY_SERIALIZED_SIZE); | ||
| assert_eq!(signature.len(), SIGNATURE_SERIALIZED_SIZE); |
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.
It seems that the pubkey length check was added above, but the signature length check was removed. Is this intended?
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.
That's correct -- signing_key.public_key().to_bytes() returns Vec<u8>, so we aren't 100% sure the size is correct, whereas sign_message returns [u8; SIGNATURE_SERIALIZED_SIZE], so we already know statically that the size is correct, which means it's unnecessary to check the size.
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.
Looks good to me!
* secp256r1: Deprecate openssl types in public API #### Problem This is anza-xyz#114, but for secp256r1 instead, removing external types from the public interface. #### Summary of changes This one was a bit more complicated because it uses openssl types, which aren't as straightforward as simple bytes, so it uses bytes encoded in DER as the interface. This seemed like the most standard format from simple web searching, but I'm certainly no expert in this area. There seemed to also be a lot of vecs in the new instruction implementation, which shouldn't be necessary, so I changed those to arrays. * Rename variable
Problem
This is #114, but for secp256r1 instead, removing external types from the public interface.
Summary of changes
This one was a bit more complicated because it uses openssl types, which aren't as straightforward as simple bytes, so it uses bytes encoded in DER as the interface. This seemed like the most standard format from simple web searching, but I'm certainly no expert in this area.
There seemed to also be a lot of vecs in the new instruction implementation, which shouldn't be necessary, so I changed those to arrays.