Function risc0_binfmt::tagged_list_cons
source ยท pub fn tagged_list_cons<S: Sha256>(
tag: &str,
head: &Digest,
tail: &Digest,
) -> Digest
Expand description
Calculate the hash resulting from adding one element to a tagged_list digest.
This function logically pushes the element head
onto the front of the
list.
use risc0_zkp::core::hash::sha::{cpu::Impl, Sha256};
use risc0_binfmt::{tagged_list, tagged_list_cons};
let [a, b, c] = [
*Impl::hash_bytes(b"a".as_slice()),
*Impl::hash_bytes(b"b".as_slice()),
*Impl::hash_bytes(b"c".as_slice()),
];
assert_eq!(
tagged_list::<Impl>("tag", &[a, b, c]),
tagged_list_cons::<Impl>("tag", &a, &tagged_list::<Impl>("tag", &[b, c])),
);