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

TypeFieldDescription
u32hasherThe identifier for the hashing algorithm.
Bytes32content_typeA string specifying the content type, right-padded to 32 bytes with zeros.
BytescontentThe 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:

HasherDescriptionHash FunctionImplementation Status
1SHA256sha256Done
2IPFS Content IDipfs_cidPlanned
3Arweave Transaction IDarweave_txnidPlanned

Additional hashers may be introduced in the future.


1

This structure is expressed in Rust syntax, as defined and utilized on the Previous chain.