maidsafe / safe_network

63 stars 37 forks source link

Client secret key should not be mutable / should implement RwLock if needed #1908

Open RolandSherwin opened 3 weeks ago

RolandSherwin commented 3 weeks ago

Currently the client secret key can be modified with this public interface Client::set_signer_key, but since client is assumed to be freely-clonable without any mutable states, changing the sk would only affect 1 instance of the client and not all the clones.

This is currently used inside acc-packet::init to update the Client sk with root_sk.dervide_sk(). So maybe we should just initialize the Client with this root_sk.dervide_sk() or introduce RwLock<SK>, but the lock would run deep into Registers and that might not be a good approach.

c.c @bochaco

bochaco commented 2 weeks ago

changing the sk would only affect 1 instance of the client and not all the clones.

That's correct and I think that's desirable; apps will most likely work with many different keys to sign reqs. and/or encrypt content, so they may use different Client instances, each of them with these different keys set.

RolandSherwin commented 2 weeks ago

If so, would it be possible to maybe provide the keys during the init of client rather than with Client::set_signer_key? Since set_signer_key can be easily overlooked and the caller would expect all the instance to have the updated value?