Data Structures
Twine data structures
Twine uses IPLD to encode its data. There are two data structures: Pulses, and Chain metadata.
Pulses are logically grouped as chains, which act as proxies for ownership. Generally, a chain is produced for a single purpose or use case by a single process and owner. Every pulse of every chain is also linked (via hash-linking) to pulses of other chains, thus forming the larger Tapestry. Chain metadata stores meta information about the construction of the chain, including the public key for provenance verification.
Hash-linking of the data structures is facilitated by the process of content addressing and CIDs. With content addressing, data is referenced by its hash instead of its location using a special identifier called a Content ID (CID). A CID is constructed using the hash of serialized data, meta-information about the serialization method, hash algorithm, format, and version of the CID itself. This self-descriptive CID is used as both an identifier for retrieval of the original data, as well as a checksum to verify its integrity. Since CIDs contain a hash of the data, they can be used for the purposes of hash-linking.
Both Pulses and Chain metadata follow a similar outer structure. What distinguishes them is the type of their `content` property.
type TwinePulse struct {
content PulseContent
signature String
} representation map
type TwineChain struct {
content ChainContent
signature String
} representation map
Signatures
Signatures are represented as a string type which encodes a Compact Javascript Web Signature JWS.
"eyJhbGciOiJFUzI1NiJ9.FECjYMLfBcaarQShFsVVcV3h12vG9Aw2JN5yNptUodLAQV3mfxSgwqdO-VQStLeTRdZDon4YXVGtcgZ_aLzbEqw1.3xZ-2BxejyxinNugtmmm5bo4LuuymNk0KRILsNMluYXjgKWLJRI9EO_MbUnBGiLjAOg16PV6CGrjYDNwAzzbkQ"
Mixins
Twine structures make use of a Mixin
type which is used to store connections between chains.
type Mixin struct {
chain Link
value Link
} representation map
Pulses
Pulses are the data structures that chain together to create the tapestry. They are the structures that carry payloads and are used to append updates.
type PulseContent struct {
specification String
chain Link
index Integer
links [Link]
mixins [Mixin]
source String
} representation map
Chain Metadata
Chain Metadata structures store information about the chain as a whole. They must be retrieved in order to verify the signatures of Twine data structures.
type ChainContent struct {
specification String
key JWK # https://www.rfc-editor.org/rfc/rfc7517
links_radix Integer
meta Map
mixins [Mixin]
source String
} representation map
Last updated