Memory procedures

Module std::mem contains a set of utility procedures for working with random access memory.

Procedure Description
memcopy Copies n words from read_ptr to write_ptr.

Stack transition looks as follows:

[n, read_ptr, write_ptr, …] -> […]

Cycles: 15 + 16n
pipe_double_words_to_memory Moves an even number of words from the advice stack to memory.

Input: [C, B, A, write_ptr, end_ptr, …]
Output: [C, B, A, write_ptr, …]

Where:
- The words C, B, and A are the RPO hasher state
- A is the capacity
- C, B are the rate portion of the state
- The value num_words = end_ptr - write_ptr must be positive and even

Cycles: 10 + 9 * num_words / 2
pipe_words_to_memory Moves an arbitrary number of words from the advice stack to memory.

Input: [num_words, write_ptr, …]
Output: [HASH, write_ptr’, …]

Where HASH is the sequential RPO hash of all copied words.

Cycles:
- Even num_words: 48 + 9 * num_words / 2
- Odd num_words: 65 + 9 * round_down(num_words / 2)
pipe_preimage_to_memory Moves an arbitrary number of words from the advice stack to memory and asserts it matches the commitment.

Input: [num_words, write_ptr, COM, …]
Output: [write_ptr’, …]

Cycles:
- Even num_words: 58 + 9 * num_words / 2
- Odd num_words: 75 + 9 * round_down(num_words / 2)

Last update: December 21, 2023
Authors: kmurphypolygon