North Korea said it tested a miniaturized nuclear warhead as protection against "threats and sanctions" from hostile elements.