Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

SEOUL, South Korea — Teenage math whiz Ri Jong Yol was a solid candidate to join Kim Jong Un's army of elite hackers.

He had just won silver for the third year in a row at the world's premier high school mathematics championship, the International Mathematical Olympiad, which was held in Hong Kong in 2016.

But the night before he was supposed to return to North Korea with his team, the 18-year-old walked off the campus of the Hong Kong University of Science and Technology and defected.

Students participate in a cyber-defense programming class at Korea University in Seoul, South Korea. They were practicing hacking each other as part of a government program to train them to battle Kim Jong Un's techno-soldiers. Bloomberg via Getty Images file

According to Kim Heung-Kwang, a former science professor who also escaped from North Korea, Ri is now studying at a university in Seoul. Little else is known about him.

Had Ri stayed in North Korea, says Kwang, who now runs a nongovernmental organization that advocates for defectors' rights, he could have become a mathematician — or he could have joined the Kim regime’s advanced cyberwarfare unit. It features thousands of members.

Last month, experts from around the world gathered in Seoul to discuss Pyongyang's hacking abilities —and how to defend against them.

Martyn Williams, the editor of North Korea Tech, a San Francisco-based website, said that while hackers in many countries are often self-trained, no one has home internet access in North Korea and few even have computers.

The Morning Rundown Get breaking news and insider analysis on the rapidly changing world of media and technology right to your inbox. This site is protected by recaptcha

That means the North Korean regime hand-picks and trains its hacking elite.

"The training system that North Korea uses is really unlike many others in the world, because North Korea is a country like no other in the world," says Williams, who is also a contributor at 38 North, a North Korean-monitoring group based at Johns Hopkins University.

Math and science are pushed in elementary school in the North, and the best students in those subjects are exposed to computers, according to Williams.

From then on, the kids with a knack for computing will advance through a series of special schools that emphasize programming. There are hundreds of students, says Kim, the North Korean professor, and about 70 percent of graduates are men.

Many will compete in programming contests around the country, and the best will go on to top universities.

It’s largely at the university level that hacking is introduced. Williams says students may attend Kim Il Sung University or Kim Chaek University of Technology to develop traditional software.

But some of the brightest programmers, he says, are sent to Moranbong University or Mirim College, schools where the best hackers are said to learn their trade.

North Korea's rigorous schooling to train programmers and future hackers appears to be part of a grand vision the leadership has had for decades to strengthen both its economy and military.

In 1996, former leader Kim Jong Il reportedly told a group of frontline troops that "all wars in the future will be computer wars."

Despite the Western stereotype that North Korean leaders are running a backward nation, the "Dear Leader" seemed to have recognized the importance of computers early on.

"It was a pretty early prediction," Williams says, "and it turned out to be pretty good."

Related: Iran-sponsored hackers have targeted Israel, Saudis, Turkey

Now, North Korea’s computer literate are allegedly masterminding attacks around the globe, such as the hack on Sony Pictures in 2014 that crashed the bulk of the company’s servers and cost it tens of millions of dollars.

The FBI also suspects North Korea was behind last year's $81-million cyberheist of the Bangladesh central bank’s account at the Federal Reserve Bank of New York.

Kim, the professor, warned that North Korean hackers might one day aim to sow chaos by attacking transportation and communication systems, among other crucial infrastructure in developed nations.

"That situation is drawing near," he says.