pub fn sign_for_randomly_generated_sender(mut self) -> Self {
        use ed25519_dalek::Signer;
        // create key pair
        let ed25519_keypair = {
            // use `ChaChaRng::seed_from_u64` for deterministic keys
            let mut rng = OsRng::default();
            ed25519_dalek::Keypair::generate(&mut rng)
        };
        let sender_pubkey = ed25519_public_key_to_der(ed25519_keypair.public.to_bytes().to_vec());
        self.sender_pubkey = Some(sender_pubkey.clone());
        self.update.sender = Blob(
            UserId::from(PrincipalId::new_self_authenticating(&sender_pubkey))
                .get()
                .into_vec(),
        );
        let message_id = self.update.id();
        let bytes_to_sign = {
            let mut buf = vec![];
            buf.extend_from_slice(DOMAIN_IC_REQUEST);
            buf.extend_from_slice(message_id.as_bytes());
            buf
        };
        self.sender_sig = Some(ed25519_keypair.sign(&bytes_to_sign).to_bytes().to_vec());
        self
    }
/// Create keypair, set sender and signature accordingly
Create keypair, set sender and signature accordingly
Create keypair set sender and signature accordingly
pub fn sign_for_randomly_generated_sender(mut self) -> Self {
        use ed25519_dalek::Signer;
        // create key pair
        let ed25519_keypair = {
            // use `ChaChaRng::seed_from_u64` for deterministic keys
            let mut rng = OsRng::default();
            ed25519_dalek::Keypair::generate(&mut rng)
        };
        let sender_pubkey = ed25519_public_key_to_der(ed25519_keypair.public.to_bytes().to_vec());
        self.sender_pubkey = Some(sender_pubkey.clone());
        self.update.sender = Blob(
            UserId::from(PrincipalId::new_self_authenticating(&sender_pubkey))
                .get()
                .into_vec(),
        );
        let message_id = self.update.id();
        let bytes_to_sign = {
            let mut buf = vec![];
            buf.extend_from_slice(DOMAIN_IC_REQUEST);
            buf.extend_from_slice(message_id.as_bytes());
            buf
        };
        self.sender_sig = Some(ed25519_keypair.sign(&bytes_to_sign).to_bytes().to_vec());
        self
    }
pub fn sign_for_randomly_generated_sender ( mut self ) -> Self { use ed25519_dalek :: Signer ; // create key pair let ed25519_keypair = { // use `ChaChaRng::seed_from_u64` for deterministic keys let mut rng = OsRng :: default ( ) ; ed25519_dalek :: Keypair :: generate ( & mut rng ) } ; let sender_pubkey = ed25519_public_key_to_der ( ed25519_keypair . public . to_bytes ( ) . to_vec ( ) ) ; self . sender_pubkey = Some ( sender_pubkey . clone ( ) ) ; self . update . sender = Blob ( UserId :: from ( PrincipalId :: new_self_authenticating ( & sender_pubkey ) ) . get ( ) . into_vec ( ) , ) ; let message_id = self . update . id ( ) ; let bytes_to_sign = { let mut buf = vec ! [ ] ; buf . extend_from_slice ( DOMAIN_IC_REQUEST ) ; buf . extend_from_slice ( message_id . as_bytes ( ) ) ; buf } ; self . sender_sig = Some ( ed25519_keypair . sign ( & bytes_to_sign ) . to_bytes ( ) . to_vec ( ) ) ; self }
Create keypair, set sender and signature accordingly
Create keypair set sender and signature accordingly
mut self
mut self