1. The sun having set, we started for home.

2. After the sun had set, we started for home.

3. Because the sun had set, we started for home.
-----------------------
Does #1 mean #2 or #3?

4. The sun set, so we started for home.
5. The sun had set, so we started for home.
(Which one is correct? Are both correct?)

Yes, 1, 2, and 3 all mean the same thing.

Both 4 and 5 are correct, although in 5, we were probably driving in the dark. In 4, we may not have had to drive in the complete dark yet!