An ncasn.Zone object represents a single name in the d/ namespace, containing a slice of ncasn.Records as well as WHOIS data. Zones can then be serialized into ASN.1 UPER, APER, or a custom mixed radix encoding through ncasn.MarshalRecords(). For encoding efficiency, some records make some reasonable assumptions (mainly involving restricting certain insecure record data), which are documented through comments.
Storage usage was benchmarked against proposed Tor CAA and IETF CBOR DNS standards as well as the JSON-based Namecoin format, based on a sample of private DNS zones and (in much larger numbers) the Namecoin blockchain, the blockchain dumping and benchmarking code can be found in the benchmark module.
Some (hopefully reasonable) assumptions had to be made in order to achieve good coverage of the data, specifically, some record types had to be encoded in unspecified ways in some formats. For example, IPNS records are encoded as the raw key bytes in CBOR, and textual representations were used in the Tor format. Some record types were still excluded entirely (e.g., Namecoin imports), but did not meaningfully affect the results (see below). Additionally, 1 byte is added to the length calculation of our data when comparing it to JSON/CBOR, but not when comparing it to the Tor format.
These numbers are subject to change (hopefully improve!) as the format is updated and the benchmark may have to be tweaked, but the following comparisons to different formats can currently be made (as a ratio with our storage usage as the denominator):
Blockchain data were obtained with a minimum block height of 0 and maximum of 840795. Zone/blockchain coverage ratios refer to the exclusion of records based on the aforementioned assumptions.
Zone file coverage: 0.29
Blockchain coverage: 1.00
APER benchmark results:
Format: Size ratio | Record coverage | Record count
JSON: 4.19016 | 1.00 | 200997
Tor: 1.90128 | 0.87 | 174526
CBOR: 1.48771 | 1.00 | 200997
UPER benchmark results:
Format: Size ratio | Record coverage | Record count
JSON: 4.32819 | 1.00 | 200997
Tor: 1.98423 | 0.87 | 174526
CBOR: 1.53589 | 1.00 | 200997
APER: 1.02638 | 1.00 | 200997
Mixed radix benchmark results:
Format: Size ratio | Record coverage | Record count
JSON: 4.93311 | 1.00 | 200997
Tor: 2.23073 | 0.87 | 174526
CBOR: 1.76370 | 1.00 | 200997
APER: 1.21173 | 1.00 | 200997
UPER: 1.18059 | 1.00 | 200997
Results binned based on the record types in a given zone are available in doc/Binned.txt.
Copyright (C) Namecoin developers
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.