The purpose of defining a data-structure for a SAFEcoin “wallet” is to provide some consistency between wallet APPs and to allow some additional functionality for the network
What is provided by this data-structure
- storage of addresses of the SAFEcoins that are sent to the ID.
- storage of sub-SAFEcoin balance
- storage of indexes (MD Address/Tag) to various wallet APPs specific data
- coin addresses of SAFEcoins that are to be automatically used for PUT payments when needed
- User’s default preferences for handling of wallet functions. Such things as
- default display format for SAFEcoin/partcoin amounts
- common bitcoin/altcoin addresses for wallet APPs to use.
- default number of SAFEcoins to “preload” to pay for network services.
What is not provided by this datasturcture
- definition of data being held by specific wallet Applications. This is handled by the wallet Applications themselves. But I strongly recommend that a common definition is developed so that the user can replace one of their wallet APPs and use the old APPs data/setup/settings. Note that it is expected that some/many users will have multiple wallet APPs depending on their circumstances
What needs to be worked out
- Best method for securing public/private keys in the common area.
- What ID to be used by the network for any “wallets” held by groups.
How this datastructure fits into the scheme of things.
- SAFEcoins/partcoins are sent to an ID. IDs (eg public/private IDs) are sinply a number, address if you will, and the value in the owner field of a coin. When a user wants to receive coins/payment from another person then they will provide an ID for the coins to be sent to. This ID can be their public/private ID or any other ID they provide.
- “Wallet” IDs are simply an ID. This ID can be the same as a public/private ID the user has or any other generated ID.
- So “wallet” are addressed by using the ID as the address of a master MD object whose tag is a system tag and is owned by the account ID of the user and controlled by the network processes
- An account can have many “wallets” the same as an account can have many public/private IDs
- Wallet APPs maintain their own data structures that are owned by the wallet and it is hoped that all wallet APPs respect the users and never keep centralised data.
Current sizing of various objects/fields used in datastructure sizing calculations
ID 128 bits (16 Bytes)
SAFEcoin Address 32 bits ( 4 Bytes)
partcoin balance 64 bits ( 8 Bytes) Proposed
MD data storage Approx, but less than 1 MByte
Proposed Data Structure
Proposal is to use MD objects to hold the information.
- One MD for the “master Wallet MD” This MD holds the system and user central data & indexes. The tag type is a reserved system tag since it is a requirement that the address is available and cannot be taken by malicious entities.
- Multiple MDs for Wallet APPs to hold their settings/preferences/keys/etc for the user. All owned by the wallet NOTE: It is expected that “good” wallet APPs will not store or send user dasta to any other storage area not owned by the wallet.
- Multiple MDs holding the addresses of SAFEcoins that have the wallet ID as the owner. The current SAFEcoin proposal mentions that a network message is sent to the ID with the address of the coin sent to that ID. It would then be the responsibility of a wallet APP to receive these messages and populate these MDs with those addresses.
WALLET MASTER RECORD (MD)
+-------------------------------------------+
| |
| Account ID signature |
| - Account ID is the owner of the |
| "wallet" and "signs" any API request |
| |
+-------------------------------------------+
| |
| Part-SAFEcoin Balance u64 |
| + security data if required |
| |
+-------------------------------------------+
| |
| Addition fields for Group wallets |
| |
| Part-SAFEcoin Pseduo Balance u64 |
| Part-SAFEcoin Receipt Balance u64 |
| + security data if required |
| |
+-------------------------------------------+
| |
| SAFEcoin Count u32 |
| - Count of SAFEcoins "owned" by ID |
| - Updated when coin received/sent |
| - Total holdings is Count + Balance |
| |
+-------------------------------------------+
| |
| Default wallet Preferences |
| For example |
| - (part)coin display format |
| - array of bit/altboin keys and |
| security/password to unlock the keys |
| for APPs |
| - Etc |
| |
+-------------------------------------------+
| |
| Array of Safecoin addresses for coins |
| that the network can use to pay for |
| network services (eg PUTs) |
| - Last in - First out |
| |
| Each array element |
| - U32 (address of coin) |
| |
+-------------------------------------------+
| |
| Last coin address Index |
| - last valid element in the array |
| |
+-------------------------------------------+
| |
| Array of MD addresses to MDs storing |
| the SAFEcoin addresses "owned" by the |
| (wallet) ID. |
| - Last in - First out |
| |
| Each array element |
| - XorName MD address |
| |
+-------------------------------------------+
| |
| Last "coin address MD" address Index |
| - last valid element in the array |
| |
+-------------------------------------------+
| |
| Array of MD addresses to APP's master |
| Record (MD) |
| |
| Each array element |
| - APP Name (maybe 64 bytes) |
| - XorName+tag MD address |
| |
+-------------------------------------------+
| |
+-------------------------------------------+
| |
+-------------------------------------------+
SAFEcoin addresses records (MDs)
+-------------------------------------------+
| |
| Account ID |
| - Not needed but allows verification |
| |
+-------------------------------------------+
| |
| Wallet ID |
| - Not needed but allows verification |
| |
+-------------------------------------------+
| |
| Last coin address Index |
| - last valid element in the array |
| |
+-------------------------------------------+
| |
| Array of SAFEcoin Addresses |
| - Last in - First out |
| |
| Each Array element |
| - U32 Address of coin |
| |
| |
+-------------------------------------------+
Sizing of data in the MDs
SAFEcoin addresses records (MDs)
There is almost the whole MD data area available (>995K) to store the ‘Array of SAFEcoin addresses’
Number of elements possible = approx 995K/4 = 248750 elements (SAFEcoin addresses)
WALLET MASTER RECORD (MD)
The “wallet” Master MD has 3 large arrays. Initially consider the array of SAFEcoin addresses MDs to allow the wallet to hold the addresses of the whole 4 billion coins, and allow for an extreme amount of “pre-loaded” SAFEcoins array. (say 10,000 coin addresses)
Array of MD addresses to MDs storing the SAFEcoin addresses “owned” by the (wallet) ID.
Max number of elements = 2^32 (4,294,967,296) / 248750 = approx 16,267 elements (MD addresses)
Max Bytes = 16,267 * 16 bytes = 260,272 bytes.
Array of “pre-loaded” SAFEcoin addresses
10,000 coin addresses * 4 = 40 KBytes
Array of MD addresses to APP’s master Record (MD)
Allow 100 KBytes in “wallet” master MD for incidental values (balance, prefs, etc)
Allow 261 Kbytes for coin address index array
Allow 40 KBytes for “pre-load” array
This leaves approx 600 Kbtes available and if allow 100 bytes per APP index then it is possible to have 6000 APPs “registered”
Obviously it is extremely unlikely that anyone could ever use the maximum of the arrays in the “wallet” master MD and it would be safe to have the arrays grow as they are added to and not have a set size for them. They are never going to exceed the available space in the MD.
Requirements for the network core code
There will need to be an API added or modified to provide functionally to create the “Wallet Master MD” which is owned by the Account The address of the MD is the ID value and thus the ID would have to be verified as being owned by the Account. The partcoin balance field of the MD would require its permissions so that it can only be modified by a network manager.
The “pre-load” coin addresses will be used by the APP(s) that upload data and/or network managers to automatically pay for resources when required. This is to allow the user to have an automatic payment for uploads and not be queried every time a coin needs to be “spent”. Spending a coin for resource payments will now be dividing one of the wallet’s coins to add one coin’s worth to the wallet’s partcoin balance.
Coin divisibility topic examines the APIs needed to handle the partcoin balance.