Neither of these seems right. The first one is possible, but it is awkward. It would mean that while someone is trying to learn something new (acquire the knowledge), they hope to be happy.
I think what you want to say is this:
We hoped to acquire the secret to happiness.