# Account and Address
# Address introduction
The ownership of Bytom's assets is established on addresses and digital signatures. Every transaction requires a valid signature to be stored on the blockchain, and only a valid digital key can produce a valid digital signature. Therefore, possessing the digital key is equivalent to possessing the asset control right of the account. The private keys come in pairs and consist of a public key and a private key. Simply put, the public key can be used as the address of the transaction output, and the private key can generate a digital signature for the transaction. Generally, they are stored in wallet files and managed by wallet software.
When an asset is issued, the asset will be issued to the designated address. When an asset is spent, it will be consumed from an existing address and transferred to a new address. When an asset is destroyed, it is also consumed from an existing address but transferred to an address that can never be consumed.
In addition, not all addresses are public keys, they can also represent other payment objects, such as scripts. We call the payment script a control program, and each control program contains a series of predicates that need to be satisfied in order to spend the output.
# Account control program
Among them, the basic control program belongs to the account control program, which defines multiple keys and the number of signatures required when spending asset units. When depositing an asset to a specified account, the wallet client will derive a series of new sub-public keys from the root private key and create a unique control program that is used only once. The control program uses the previous number of signatures defined. According to the number of private keys in the account, it can be divided into single-signature accounts and multi-signature accounts. Single-signature accounts adopt P2PKH when creating control programs. It mainly verifies whether the Public Key can be converted into the correct address and whether the signature is correct, which is to prove whether you are the owner of this Public Key. The multi-signature account uses the P2SH method when creating the control program. For example, for a 3-2 multi-signature account, it needs to verify at least two valid signatures. Although the sub-public keys used by all control programs of the same account are derived from the same root key, it is impossible for other participants on the blockchain to identify the connection between them. This technique is called hierarchical deterministic key derivation, and it ensures that only participants on the blockchain with which you are trading will know that the control program belongs to you. For others, it is impossible to know the creator of the control program.
# Destroy Control program
Destroy Control program is a very simple control program, it has only a simple predicate: FAIL. That is, it ensures that the asset unit on it can never be consumed, so it is equivalent to that the asset is removed from the blockchain.
# Customized control program
Bytom’s contract virtual machine supports customized control program. We have developed a high-level language that allows developers to write smart contract programs on Bytom. Check the smart contract documentation for details.
# Account introduction
In Bytom, an account is an abstract entity that can determine the ownership of assets on the blockchain by tracking control programs or addresses. The control program or address will appear in the output of each transaction. Among them, the control program defines a series of conditions that must be met when consuming this output; the address is generated by hashing the public key or script. Both the control program and the address can be used as the output address of a transaction. When the next transaction consumes the output, a private key matching the public key of the output address is required to sign.
There can be multiple account entities locally. The account entity will not be saved on the blockchain, but will only exist locally. Only the control program or address created in the account will appear on the blockchain. However, when a transaction is processed, the local account data can provide more powerful and easier-to-understand queries for users.
# Account Balance
The account balance itself is also an abstract concept that is easy for users to understand. It represents the sum of all assets in the UTXO that uses the account's address or control program. When creating an asset transfer transaction, your account will collect a sufficient amount of UTXO as input for the new transaction.
# Create account
When creating an account, you need to provide the alias of the account, one or more keys, and the number of signatures.
- The account alias is required, it is the only identifier used to operate the local account.
- In less strict terms, the private key can be used to generate addresses and sign transactions. According to whether the key is one or more, there are single-signature account and multi-signature account. Check the address section for details.
- The number of signatures indicates the number of signatures that require minimum of the private key when using the account to consume an asset and a signature is required.