Added Drop to SharedSecret and SecretKey#9
Conversation
| } | ||
| } | ||
|
|
||
| impl Into<Scalar> for SecretKey { |
There was a problem hiding this comment.
Why is Into<Scalar> removed?
There was a problem hiding this comment.
Because this creates an error.
You can't move out the inside of a type that implements Drop
There was a problem hiding this comment.
Maybe this will work:
let ret = self.0.clone();
ret
I understand that this may be a little bit more inefficient but it preserves the API, as someone might need it.
There was a problem hiding this comment.
Hmm ok, although that will leak the scalar and then the Drop won't run on it
|
BTW, one thing about this is that if you pass one of these things by value to somewhere they will be moved in memory and create another copy of the data that won't be removed. e.g: Edit: |
|
@elichai Do you think this may be better suited for libraries using FYI, on paritytech/parity-common#80 @cheme uses the |
|
Hey, You might be right and it is more suited for the users to put |
oh yeah, I personally don't like About the Pin, it's nice because it's accessible from core and you don't need std, but I still haven't managed to make it work as I want and the docs around it are lacking |
|
@sorpass so what do you think? |
|
Sorry! |
clear(),write_volatileto prevent the compiler from optimizing it out.