Material
A Material represents digital content in various forms, such as images, audio files, JSON data, and other media types.
A 32-byte hash, known as the material hash, is generated from the content using a specific hashing algorithm. The original content from which this hash is derived is referred to as the preimage or the content of the material.
On universe chains, material hashes are typically used as elements within objects. On the Previous chain, the actual material content can be retrieved and processed to compute object assets.
Representation
The material structure1 is defined as follows:
#![allow(unused)] fn main() { pub struct Material { hasher: u32, content_type: Bytes32, // alias of [u8; 32] content: Bytes, // alias of Vec<u8> } }
Fields
Type | Field | Description |
---|---|---|
u32 | hasher | The identifier for the hashing algorithm. |
Bytes32 | content_type | A string specifying the content type, right-padded to 32 bytes with zeros. |
Bytes | content | The actual digital content. |
Hashing
The material hash is computed as follows:
#![allow(unused)] fn main() { let hash_func = ...; // get hash function by material.hasher let hash = hash_func(material.content); }
Hashers
The following table lists the currently supported hashing algorithms:
Hasher | Description | Hash Function | Implementation Status |
---|---|---|---|
1 | SHA256 | sha256 | Done |
2 | IPFS Content ID | ipfs_cid | Planned |
3 | Arweave Transaction ID | arweave_txnid | Planned |
Additional hashers may be introduced in the future.
This structure is expressed in Rust syntax, as defined and utilized on the Previous chain.