Bitcoin has hit the mainstream - largely thanks to a spiking value and criticism from major financial institutions that it will end in disaster. But to many, the cryptocurrency remains a mystery.

This week, a company in Slovenia that mines bitcoin said it had been hacked, with a potential loss of tens of millions of dollars. The company, NiceHash, gives customers the ability to mine for bitcoins.

As the price of the world's most popular virtual currency keeps surging — to a record $17,000 on Thursday — here's a quick look at what it is and how it is "mined."

What is a bitcoin?

Bitcoin is a digital currency that's not tied to any bank or government.

Like cash, it lets users spend or receive money anonymously, or mostly so; like other online payment services, it also lets them do so over the internet.

There are several other virtual currencies, such as ethereum, but bitcoin is the most popular. Bitcoins are basically lines of computer code that are digitally signed each time they travel from one owner to the next.

Transactions can be made anonymously, making the currency popular with libertarians as well as tech enthusiasts, speculators — and criminals.

How is a bitcoin mined?

Tech-savvy users called "miners" use their computers to make complex calculations that verify transactions in bitcoins. This so-called blockchain is a global running tally of every bitcoin transaction. The miners receive bitcoins in exchange according to a set of established rules. In this way, the bitcoin network harnesses individuals' greed for the collective good.

NiceHash, the company that got hacked, made a business from matching people with spare computing power to those wanting to mine bitcoin.

How are Bitcoin's kept secure?

Because the tally of bitcoin transactions, or blockchain, is verified constantly by a network of miners, rogues cannot spend the same bitcoin twice. As long as miners keep the blockchain secure, counterfeiting shouldn't be an issue.

How did Bitcoin come to be?

It's a mystery. Bitcoin was launched in 2009 by a person or group of people operating under the name Satoshi Nakamoto. Bitcoin was then adopted by a small clutch of enthusiasts. Nakamoto dropped off the map as bitcoin began to attract widespread attention. But proponents say that doesn't matter: The currency obeys its own internal logic.

Gold plated souvenir Bitcoin coins are arranged for a photograph in London on November 20, 2017 JUSTIN TALLIS/AFP/Getty Images