Repository: aptos-labs/aptos-core
File: consensus/src/pipeline/decryption_pipeline_builder.rs (Rust)

Code before:

        // TODO: figure out handling of
        // if encrypted_txns.is_empty() {
        //     return Ok((
        //         unencrypted_txns,
        //         max_txns_from_block_to_execute,
        //         block_gas_limit,
        //         Some(None),
        //     ));
        // }

        // TODO(ibalajiarun): FIXME
        let len = 32;
        let encrypted_txns = if encrypted_txns.len() > len {
            let mut to_truncate = encrypted_txns;
            to_truncate.truncate(len);
            to_truncate
        } else {
            encrypted_txns
        };

        let txn_ciphertexts: Vec<Ciphertext> = encrypted_txns
            .iter()
            .map(|txn| {
                // TODO(ibalajiarun): Avoid clone and use reference instead
                txn.payload()
                    .as_encrypted_payload()
                    .expect("must be a encrypted txn")
                    .ciphertext()
                    .clone()
            })
            .collect();

        // TODO(ibalajiarun): Consider using commit block height to reduce trusted setup size
        // TODO(ibalajiarun): Fix this wrapping
        let encryption_round = block.round() % 200;
        let (digest, proofs_promise) = FPTXWeighted::digest(
            secret_share_config.digest_key(),
            &txn_ciphertexts,
            encryption_round,
        )?;

        let metadata = SecretShareMetadata::new(
            block.epoch(),
            block.round(),
            block.timestamp_usecs(),
            block.id(),
            digest.clone(),
        );

        let derived_key_share =

Review comment (security):
Note for later: we'll have to carefully discuss using something other than block round for FPTX, in order not to break the security of the scheme.

Code after:

        // TODO(ibalajiarun): figure out handling of empty encrypted txn vec

        // TODO(ibalajiarun): FIXME
        let len = 32;
        let encrypted_txns = if encrypted_txns.len() > len {
            let mut to_truncate = encrypted_txns;
            to_truncate.truncate(len);
            to_truncate
        } else {
            encrypted_txns
        };

        let txn_ciphertexts: Vec<Ciphertext> = encrypted_txns
            .iter()
            .map(|txn| {
                // TODO(ibalajiarun): Avoid clone and use reference instead
                txn.payload()
                    .as_encrypted_payload()
                    .expect("must be a encrypted txn")
                    .ciphertext()
                    .clone()
            })
            .collect();

        // TODO(ibalajiarun): Consider using commit block height to reduce trusted setup size
        // TODO(ibalajiarun): Fix this wrapping
        let encryption_round = block.round() % 200;
        let (digest, proofs_promise) = FPTXWeighted::digest(
            secret_share_config.digest_key(),
            &txn_ciphertexts,
            encryption_round,
        )?;

        let metadata = SecretShareMetadata::new(
            block.epoch(),
            block.round(),
            block.timestamp_usecs(),
            block.id(),
            digest.clone(),
        );

        let derived_key_share =
            FPTXWeighted::derive_decryption_key_share(secret_share_config.msk_share(), &digest)?;
        if derived_self_key_share_tx
            .send(Some(SecretShare::new(
                author,
                metadata.clone(),
                derived_key_share,
            )))
            .is_err()