INNER CODE UNIT · Rust

save_context

GuildOfWeavers/distaff · src/processor/decoder/mod.rs:327

    fn save_context(&mut self) {
        // increment context depth and make sure it doesn't overflow the stack
        self.ctx_depth += 1;
        assert!(self.ctx_depth <= MAX_CONTEXT_DEPTH, "context stack overflow at step {}", self.step);

        // if the depth exceeds current number of registers allocated for the context stack,
        // add a new register trace to the stack
        if self.ctx_depth > self.ctx_stack.len() {
            self.ctx_stack.push(vec![field::ZERO; self.trace_length()]);
        }

        // shift all stack values by one item to the right
        for i in 1..self.ctx_stack.len() {
            self.ctx_stack[i][self.step] = self.ctx_stack[i - 1][self.step - 1];
        }

        // set the top of the stack to the hash of the current program block
        // which is located in the first register of the sponge

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…