【NeoLine Talk】The life cycle of the private key

NeoLine
5 min readMay 14, 2020

In the blockchain system, since there is no centralized organization responsible for managing the backup user sensitive data, the generation, storage, use, retrieval, destruction, and update of the user’s private key all need to be guaranteed by the user. Therefore, for the entire life cycle of the private key, there needs to be a strict way to manage and control it, to ensure the security of the asset.

Today ’s NeoLine Talk, let ’s talk about how to ensure the security of the private key life cycle.

Private key generation

Private key: A 256-bit binary random number whose quality depends entirely on the quality of the random number that generated the private key. If the randomness of the key generation process is insufficient to make it predictable, then all subsequent security protection measures will be in vain.

Random numbers are the cornerstone of information security systems based on modern cryptography. The security of the entire system depends entirely on the generation efficiency and quality of random number sequences. The core of high-quality random numbers is “unpredictability”. There are two types of random numbers: pseudo-random and true random.

Pseudo-random is also called pseudo-random. It generally relies on seeds and algorithms. Knowing the seeds or the random numbers that have been generated, you can get the next random numbers, which is predictable. The current mainstream blockchain system is the private key generated by this method …

True random numbers are generally based on the design of hardware. Random numbers are generated according to the external temperature, voltage, electromagnetic field, environmental noise, etc., and the unpredictability of randomness is greatly increased. All security cryptographic chips in the financial field adopt this design.

Let’s see in detail how to generate a private key from a random number?

The first step in generating a private key is also the most important. It is to find a sufficiently secure source of entropy, that is, a source of randomness. Generating a Bitcoin private key is essentially the same as “choose a number between 1 and 2256”. As long as the selected results are unpredictable or unrepeatable, the specific method of selecting numbers is not important. Bitcoin software uses a random number generator at the bottom of the operating system to generate 256 bits of entropy (randomness). Normally, the operating system random number generator is initialized by an artificial random source, and it may also need to be initialized by shaking the mouse continuously within a few seconds.

More precisely, the private key can be any number between 1 and n-1, where n is a constant (n = 1.158 * 1077, slightly less than 2256) and is defined by the order of the elliptic curve used by Bitcoin. To generate such a private key, we randomly choose a 256-bit number and check whether it is less than n-1. From a programming point of view, it is generally by taking a long string of random bytes from a cryptographically secure random source and using the SHA256 hash algorithm to perform operations, so that a 256-bit number can be easily generated. If the operation result is less than n-1, we have a suitable private key. Otherwise, we repeat it with another random number.

Private key storage

Each bitcoin address corresponds to a private key, and mastering the private key means mastering the bitcoin in its corresponding address. In layman’s terms, a key opens a lock. If the Bitcoin address is a lock, then the private key is the key to the lock.

The storage and use of private keys are generally divided into soft and hard implementations.

Soft implementation, storage and use are in the form of software. After the key is generated, it is stored in the user terminal or hosted on the server as a file or character string. When used, the private key plain text is read directly or through simple password control into the memory, and the private key calculation is completed by the CPU. This storage and use method has a lot of security risks, and is easy to be copied, stolen, brute-forced by hackers or ghosts.

Hard implementation generally relies on a dedicated cryptographic security chip or cryptographic device as a carrier. There are generally mechanisms such as physical protection, sensitive data protection, and key protection to ensure that the private key must be generated by dedicated hardware. At any time and under any circumstances, the private key cannot appear outside the cryptographic device in clear text; the key stored inside the cryptographic device should have an effective key protection mechanism to prevent dissection, detection, and illegal reading. The private key cannot be exported, and only the signature value can be calculated and output.

But whether it is soft or hard, as long as others know your private key, you can transfer your assets. Remember, whoever holds the private key is the real owner of the asset.

Safe use of private keys

When using the private key, it is necessary to ensure the security of the use environment, and access, reading, and writing of the private key file need to have relevant permission control. After the use is completed, all sensitive data cached in the memory needs to be cleared using a dedicated function to prevent the leakage of sensitive data. From the perspective of password cracking, the private key should be replaced after a certain period of use. This is a problem involving the destruction and update of the private key, which we will introduce later.

Private key recovery

If a traditional centralized bank loses its U-shield or forgets its password, it can rebind a new U-shield (private key) through the account system. Accounts and private keys are logically bound, and are operated by centralized banks while meeting risk control requirements. There are also some traditional centralized payment institutions. When the user’s asset certificate is lost, the centralized institution can retrieve the relevant data through its identity certificate.

But in the blockchain system, there is no centralized organization to help us back up sensitive data such as private keys. Therefore, when designing the system’s private key management scheme, it is necessary to provide multiple backup and recovery methods, such as the use of mnemonic words or the use of passwords plus local ciphertext files to restore private key data. But if your mnemonic is also lost, it means you lost everything.

Private key destruction

When the user needs to destroy the private key data, it is necessary to ensure that all the private key data stored in the backup are completely deleted and destroyed.

Private key update

In the field of blockchain, the private key is the only credential that represents the user’s identity or digital assets. If the private key needs to be updated, registration or digital asset transfer must be re-bound. Therefore, when you need to replace the private key, you need to ensure that the new private key is safely generated or imported, the assets have been safely transferred, and the old private key is safely destroyed.

Everything starts with visibility. The security of the private key is related to the security of digital assets and the security of personal privacy, so it is very important to securely ensure every step of the life cycle of the private key.

--

--

NeoLine

NeoLine mobile is an easy-to-use mobile gateway to the Neo smart economy。