What type of figurative is used here? The stars twinkled like diamonds in the sky.

Simile.