fn encrypt_key_to(
        &mut self,
        key_derive_info: &[&[u8]],
        ecdh_pubkey: &EcdhPublicKey,
        secret_key: &Sr25519SecretKey,
        block_number: chain::BlockNumber,
    ) -> EncryptedKey {
        let derived_key = self
            .master_key
            .derive_sr25519_pair(key_derive_info)
            .expect("should not fail with valid info; qed.");
        let my_ecdh_key = derived_key
            .derive_ecdh_key()
            .expect("ecdh key derivation should never failed with valid master key; qed.");
        let secret = ecdh::agree(&my_ecdh_key, &ecdh_pubkey.0)
            .expect("should never fail with valid ecdh key; qed.");
        let iv = self.generate_iv(block_number);
        let mut data = secret_key.to_vec();
        aead::encrypt(&iv, &secret, &mut data).expect("Failed to encrypt master key");

        EncryptedKey {
            ecdh_pubkey: sr25519::Public(my_ecdh_key.public()),
            encrypted_key: data,
            iv,
        }
    }
// Manually encrypt the secret key for sharing
//
// The encrypted key intends to be shared through public channel in a broadcast way,
// so it is possible to share one key to multiple parties in one message.
// For end-to-end secret sharing, use `SecretMessageChannel`.
Manually encrypt the secret key for sharing
The encrypted key intends to be shared through public channel in a broadcast way,
so it is possible to share one key to multiple parties in one message.
For end-to-end secret sharing, use `SecretMessageChannel`.
Manually encrypt the secret key for sharing The encrypted key intends to be shared through public channel in a broadcast way so it is possible to share one key to multiple parties in one message . For end - to - end secret sharing use ` SecretMessageChannel ` .
fn encrypt_key_to(
        &mut self,
        key_derive_info: &[&[u8]],
        ecdh_pubkey: &EcdhPublicKey,
        secret_key: &Sr25519SecretKey,
        block_number: chain::BlockNumber,
    ) -> EncryptedKey {
        let derived_key = self
            .master_key
            .derive_sr25519_pair(key_derive_info)
            .expect("should not fail with valid info; qed.");
        let my_ecdh_key = derived_key
            .derive_ecdh_key()
            .expect("ecdh key derivation should never failed with valid master key; qed.");
        let secret = ecdh::agree(&my_ecdh_key, &ecdh_pubkey.0)
            .expect("should never fail with valid ecdh key; qed.");
        let iv = self.generate_iv(block_number);
        let mut data = secret_key.to_vec();
        aead::encrypt(&iv, &secret, &mut data).expect("Failed to encrypt master key");
        EncryptedKey {
            ecdh_pubkey: sr25519::Public(my_ecdh_key.public()),
            encrypted_key: data,
            iv,
        }
    }
fn encrypt_key_to ( & mut self , key_derive_info : & [ & [ u8 ] ] , ecdh_pubkey : & EcdhPublicKey , secret_key : & Sr25519SecretKey , block_number : chain :: BlockNumber , ) -> EncryptedKey { let derived_key = self . master_key . derive_sr25519_pair ( key_derive_info ) . expect ( " " ) ; let my_ecdh_key = derived_key . derive_ecdh_key ( ) . expect ( " " ) ; let secret = ecdh :: agree ( & my_ecdh_key , & ecdh_pubkey . 0 ) . expect ( " " ) ; let iv = self . generate_iv ( block_number ) ; let mut data = secret_key . to_vec ( ) ; aead :: encrypt ( & iv , & secret , & mut data ) . expect ( " " ) ; EncryptedKey { ecdh_pubkey : sr25519 :: Public ( my_ecdh_key . public ( ) ) , encrypted_key : data , iv , } }
Manually encrypt the secret key for sharing
The encrypted key intends to be shared through public channel in a broadcast way,
so it is possible to share one key to multiple parties in one message.
Manually encrypt the secret key for sharing The encrypted key intends to be shared through public channel in a broadcast way so it is possible to share one key to multiple parties in one message .
&mut self
key_derive_info
&[&[u8]]
ecdh_pubkey
&EcdhPublicKey
secret_key
&Sr25519SecretKey
block_number
chain::BlockNumber
&mut self
key_derive_info
&[&[u8]]
ecdh_pubkey
&EcdhPublicKey
secret_key
&Sr25519SecretKey
block_number
chain::BlockNumber