Synthesis and assembly of nanoparticles