-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Keypair: implement clone() #26248
Keypair: implement clone() #26248
Conversation
I see the utility but am concerned about using
|
How about we put the Alternatively there could be an |
5b578ff
to
7aa8c84
Compare
Yeah, something like that sgtm! |
7aa8c84
to
90fff18
Compare
@mvines Updated so you need to explicitly use a separate |
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 once CI is green
90fff18
to
23d9ca2
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
23d9ca2
to
ab9562f
Compare
Looks like a rebase is needed to resolve the cargo audit issue in CI |
ab9562f
to
315b53e
Compare
This was not implemented upstream in ed25519-dalek to force everyone to think twice before creating another copy of a potentially sensitive private key in memory. See dalek-cryptography/ed25519-dalek#76 However, there are now 9 instances of Keypair::from_bytes(&keypair.to_bytes()) in the solana codebase and it would be preferable to have a function. In particular since this also comes up when writing programs and can cause users to either start messing with lifetimes or discover the from_bytes() workaround themselves. This patch opts to not implement the Clone trait. This avoids automatic use in order to preserve some of the original "let developers think twice about this" intention.
315b53e
to
7e2a5ab
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
@mvines Please merge if you think this makes sense to have. |
Thanks for the contribution! |
* Keypair: implement clone() This was not implemented upstream in ed25519-dalek to force everyone to think twice before creating another copy of a potentially sensitive private key in memory. See dalek-cryptography/ed25519-dalek#76 However, there are now 9 instances of Keypair::from_bytes(&keypair.to_bytes()) in the solana codebase and it would be preferable to have a function. In particular since this also comes up when writing programs and can cause users to either start messing with lifetimes or discover the from_bytes() workaround themselves. This patch opts to not implement the Clone trait. This avoids automatic use in order to preserve some of the original "let developers think twice about this" intention. * Use Keypair::clone
* Keypair: implement clone() This was not implemented upstream in ed25519-dalek to force everyone to think twice before creating another copy of a potentially sensitive private key in memory. See dalek-cryptography/ed25519-dalek#76 However, there are now 9 instances of Keypair::from_bytes(&keypair.to_bytes()) in the solana codebase and it would be preferable to have a function. In particular since this also comes up when writing programs and can cause users to either start messing with lifetimes or discover the from_bytes() workaround themselves. This patch opts to not implement the Clone trait. This avoids automatic use in order to preserve some of the original "let developers think twice about this" intention. * Use Keypair::clone
What is the benefit of using a The |
There's no advantage to the trait. The goal was to gate the function via the suspicious-looking |
@ckamm Do you agree this is introducing this risk:
|
Yes. Marking at each callsite would avoid accidental bugs like this and stick out more while reviewing. |
wondering why the solution here was to implement |
Problem
Keypair::clone()
was not implemented upstream in ed25519-dalek to force everyone to think twice before creating another copy of a potentially sensitive private key in memory.See dalek-cryptography/ed25519-dalek#76
However, there are now 9 instances of
in the solana codebase and it would be preferable to have a function.
In particular since this also comes up when writing programs and can cause users to either start messing with lifetimes or discover the from_bytes() workaround themselves.
Summary of Changes
Add
clone()
toKeypair
.This patch opts to not implement the Clone trait. This avoids automatic use in order to preserve some of the original "let developers think twice about this" intention.