Material
A Material
represents digital content such as images, audio files, JSON data, and more, stored on the Previous chain.
On universe chains, a material is typically represented by a material hash, which is of type Bytes32
. This hash is used as an element of an object. The actual digital content, referred to as the preimage of the material hash (or simply the material data), can be loaded and processed during the execution of a kind contract.
Representation
The Material
structure is defined as follows:
#![allow(unused)] fn main() { pub struct Material { hasher: u32, content_type: Bytes32, content: Bytes, } }
Field Descriptions
Size (bytes) | Field | Type | Description |
---|---|---|---|
4 | hasher | u32 | Indicates the hashing algorithm used. |
32 | content_type | Bytes32 | A string specifying the content type, right-padded to 32 bytes with zeros. |
Variable | content | Bytes | The actual digital content. |
Hashing
The material hash is computed as follows:
#![allow(unused)] fn main() { material_hash = hash_func(material.content); }
The hasher
field determines the hash function used.
Currently supported options include:
- SHA256:
hasher = 1
,hash_func = sha256
Additional hashing algorithms may be introduced in the future.