Does ipfs takes more time to upload and download encrypted data?

I am inegrating security features with ipfs. When i try to upload encrypted data, ipfs takes more time perform following operation compared with plain text "
buffer := bytes.NewBuffer(encryptedShard)
ipfsHash, err := api.Add(buffer)
if err != nil {
}" can anyone explain why it takes more time (3x) ? looking for your response

It would be nice to see a reproduction.
On the top of my head, it makes no sense and looks like a bug, Kubo does not even parse the content and blindly hash and chunk it.

I am using AESGCM encryption. the data size is also the same before and after encryption.

I mean, could you share a script that shows this behavior ?

package main

import (

	shell ""

const AESKeyHex = "0b3a29ef29afed5e0ac68f97a96036cedfa8f79a3867bbf6c607d53b07cfd44e" // Private Key for AES

func encodingData(data []byte, AESKey []byte, api *shell.Shell) {

	encryptedShard, err := encrypt(data, AESKey)
	if err != nil {
		fmt.Println("error while encrypting",err)

	encodingTime := time.Now()

	buffer := bytes.NewBuffer(encryptedShard) // please replace encryptedShard with data if you want to upload plain text 
	//start := time.Now()
	ipfsHash, err := api.Add(buffer)
	if err != nil {
	Encoding_time := time.Since(encodingTime)
	fmt.Println("data encryption time", Encoding_time)
	fmt.Println("length od plaintext", len(data))
	fmt.Println("length of enrypted text", len(encryptedShard))
	fmt.Println("IPFS hash", ipfsHash)


func encrypt(data []byte, key []byte) ([]byte, error) {
	block, err := aes.NewCipher(key)
	if err != nil {
		return nil, err
	gcm, err := cipher.NewGCM(block)
	if err != nil {
		return nil, err
	nonce := make([]byte, gcm.NonceSize())
	if _, err = io.ReadFull(rand.Reader, nonce); err != nil {
		return nil, err
	return gcm.Seal(nonce, nonce, data, nil), nil

func main() {
	var filePath string
	api := shell.NewShell("localhost:5001")
	fmt.Println("Enter full path of the file:")
	data, err := ioutil.ReadFile(string(filePath))
	if err != nil {
	keyBytes, err := hex.DecodeString(AESKeyHex)
	if err != nil {
		fmt.Println("Error decoding key string:", err)
	encodingData(data, keyBytes, api) // Encoding and encrypting the data


You can create a codeblock like this:
// Code goes there …
Your code is being interpreted as markdown syntax right now.

Edit: thx, way easier to read.

1 Like

Dear, You just need to upload any file from your local directory. You can replace replace encryptedShard with data if you want to upload plain text.

@hector can you help

I don’t think this has anything to do with Kubo per se and that we can offer any light beyond what you would discover yourself with more testing.

Are you running this twice in a row and seeing different encoding times?

Is the data and encrypted data the same size ?

Are you testing in a Kubo instance that is in the same state in both cases? (i.e. offline, empty repo)?

Have you tried adding 100x times and comparing that it is consistent? Restarting Kubo between adds?