-
Notifications
You must be signed in to change notification settings - Fork 30
impl Clone for generic structs. #1227
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
base: main
Are you sure you want to change the base?
Conversation
In particular, this allows public keys to be Clone-able.
|
@franziskuskiefer friendly bump here! |
franziskuskiefer
left a comment
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.
Cloning here is generally fine, but we should only do it for non private keys.
| @@ -1,5 +1,6 @@ | |||
| macro_rules! impl_generic_struct { | |||
| ($name:ident, $doc:expr) => { | |||
| #[derive(Clone)] | |||
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 is also used for the private keys, which shouldn't make it that easy. Can you move the struct definition out of here? Then you can add clone only for the public keys.
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 can, just to understand better the desired feature tho: why are secret keys not clone-able?
Currently it's not possible to use secret keys across threads, or have it be serialized with zerocopy. I don't think cloning secret keys explicitly (differently than, say, Copy) causes security issues, right?
Anyways, going first with the external implementation.
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's not a strong requirement. But copying any secret bytes may be a security issue. Making it easier is just not great. But it's not a huge deal, and this bit is changing anyway. So maybe let's just keep it as is for now.
I'm having trouble being able to clone public keys without wacky work-around via
AsRefandFrom.Is there any way they could be made clone-able?