You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: ecdh.go
    path of file: ./repos/goldfish/vendor/github.com/keybase/go-crypto/openpgp/packet
    
    the code of the file until where you have to start completion: package packet

import (
	"bytes"
	"io"
	"math/big"

	"github.com/keybase/go-crypto/openpgp/ecdh"
	"github.com/keybase/go-crypto/openpgp/errors"
	"github.com/keybase/go-crypto/openpgp/s2k"
)

// ECDHKdfParams generates KDF parameters sequence for giv
    
func serializeEncryptedKeyECDH(w io.Writer, rand io.Reader, header [10]byte, pub *PublicKey, keyBlock []byte) error {
	ecdhpub := pub.PublicKey.(*ecdh.PublicKey)
	kdfParams := ECDHKdfParams(pub)

	hash, ok := s2k.HashIdToHash(byte(pub.ecdh.KdfHash))
	if !ok {
		return errors.InvalidArgumentError("invalid hash id in private key")
	}

	kdfKeySize := CipherFunction(pub.ecdh.KdfAlgo).KeySize()
	Vx, Vy, C, err := ecdhpub.Encrypt(rand, kdfParams, keyBlock, hash, kdfKeySize)
	if err != nil {
		return err
	}

	mpis, mpiBitLen := ecdh.Marshal(ecdhpub.Curve, Vx, Vy)

	packetLen := len(header) /* header length in bytes */
	packetLen += 2 /* mpi length in bits */ + len(mpis)
	packetLen += 1 /* ciphertext size in bytes */ + len(C)

	err = serializeHeader(w, packetTypeEncryptedKey, packetLen)
	if err != nil {
		return err
	}

	_, err = w.Write(header[:])
	if err != nil {
		return err
	}

	_, err = w.Write([]byte{byte(mpiBitLen >> 8), byte(mpiBitLen)})
	if err != nil {
		return err
	}

	_, err = w.Write(mpis[:])
	if err != nil {
		return err
	}

	w.Write([]byte{byte(len(C))})
	w.Write(C[:])
	return nil
}