halo2/rustdoc/latest/halo2_gadgets/sha256/trait.Sha256Instructions.html

37 lines
21 KiB
HTML
Raw Normal View History

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The set of circuit instructions required to use the [`Sha256`] gadget."><meta name="keywords" content="rust, rustlang, rust-lang, Sha256Instructions"><title>Sha256Instructions in halo2_gadgets::sha256 - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script src="../../crates.js"></script><script defer src="../../main.js"></script>
<noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js" integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe" crossorigin="anonymous"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body, {
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "\\(", right: "\\)", display: false},
{left: "$", right: "$", display: false},
{left: "\\[", right: "\\]", display: true}
]
});
});
</script>
</head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a class="sidebar-logo" href="../../halo2_gadgets/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div>
</a><h2 class="location"><a href="#">Trait Sha256Instructions</a></h2><div class="sidebar-elems"><div class="block items"><h3 class="sidebar-title"><a href="#associated-types">Associated Types</a></h3><div class="sidebar-links"><a href="#associatedtype.BlockWord">BlockWord</a><a href="#associatedtype.State">State</a></div><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><div class="sidebar-links"><a href="#tymethod.compress">compress</a><a href="#tymethod.digest">digest</a><a href="#tymethod.initialization">initialization</a><a href="#tymethod.initialization_vector">initialization_vector</a></div><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div><h2 class="location">Other items in<br><a href="../index.html">halo2_gadgets</a>::<wbr><a href="index.html">sha256</a></h2><div id="sidebar-vars" data-name="Sha256Instructions" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../halo2_gadgets/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><div>
<input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
<h1 class="fqn"><span class="in-band">Trait <a href="../index.html">halo2_gadgets</a>::<wbr><a href="index.html">sha256</a>::<wbr><a class="trait" href="#">Sha256Instructions</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/halo2_gadgets/sha256.rs.html#25-57" title="goto source code">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait Sha256Instructions&lt;F:&nbsp;FieldExt&gt;: <a class="trait" href="../../halo2_proofs/circuit/trait.Chip.html" title="trait halo2_proofs::circuit::Chip">Chip</a>&lt;F&gt; {
type <a href="#associatedtype.State" class="associatedtype">State</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>;
type <a href="#associatedtype.BlockWord" class="associatedtype">BlockWord</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>;
fn <a href="#tymethod.initialization_vector" class="fnname">initialization_vector</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;layouter: &amp;mut impl <a class="trait" href="../../halo2_proofs/circuit/trait.Layouter.html" title="trait halo2_proofs::circuit::Layouter">Layouter</a>&lt;F&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a>, <a class="enum" href="../../halo2_proofs/plonk/error/enum.Error.html" title="enum halo2_proofs::plonk::error::Error">Error</a>&gt;;
<div class="item-spacer"></div> fn <a href="#tymethod.initialization" class="fnname">initialization</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;layouter: &amp;mut impl <a class="trait" href="../../halo2_proofs/circuit/trait.Layouter.html" title="trait halo2_proofs::circuit::Layouter">Layouter</a>&lt;F&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;init_state: &amp;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a>, <a class="enum" href="../../halo2_proofs/plonk/error/enum.Error.html" title="enum halo2_proofs::plonk::error::Error">Error</a>&gt;;
<div class="item-spacer"></div> fn <a href="#tymethod.compress" class="fnname">compress</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;layouter: &amp;mut impl <a class="trait" href="../../halo2_proofs/circuit/trait.Layouter.html" title="trait halo2_proofs::circuit::Layouter">Layouter</a>&lt;F&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initialized_state: &amp;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a>Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.BlockWord" title="type halo2_gadgets::sha256::Sha256Instructions::BlockWord">BlockWord</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 16]</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a>, <a class="enum" href="../../halo2_proofs/plonk/error/enum.Error.html" title="enum halo2_proofs::plonk::error::Error">Error</a>&gt;;
<div class="item-spacer"></div> fn <a href="#tymethod.digest" class="fnname">digest</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;layouter: &amp;mut impl <a class="trait" href="../../halo2_proofs/circuit/trait.Layouter.html" title="trait halo2_proofs::circuit::Layouter">Layouter</a>&lt;F&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: &amp;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a>Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.BlockWord" title="type halo2_gadgets::sha256::Sha256Instructions::BlockWord">BlockWord</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 8]</a>, <a class="enum" href="../../halo2_proofs/plonk/error/enum.Error.html" title="enum halo2_proofs::plonk::error::Error">Error</a>&gt;;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The set of circuit instructions required to use the <a href="struct.Sha256.html" title="Sha256"><code>Sha256</code></a> gadget.</p>
</div></details><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.State" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/halo2_gadgets/sha256.rs.html#27" title="goto source code">source</a></div><h4 class="code-header">type <a href="#associatedtype.State" class="associatedtype">State</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a></h4></div></summary><div class="docblock"><p>Variable representing the SHA-256 internal state.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.BlockWord" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/halo2_gadgets/sha256.rs.html#30" title="goto source code">source</a></div><h4 class="code-header">type <a href="#associatedtype.BlockWord" class="associatedtype">BlockWord</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a></h4></div></summary><div class="docblock"><p>Variable representing a 32-bit word of the input block to the SHA-256 compression
function.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.initialization_vector" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/halo2_gadgets/sha256.rs.html#33" title="goto source code">source</a></div><h4 class="code-header">fn <a href="#tymethod.initialization_vector" class="fnname">initialization_vector</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;layouter: &amp;mut impl <a class="trait" href="../../halo2_proofs/circuit/trait.Layouter.html" title="trait halo2_proofs::circuit::Layouter">Layouter</a>&lt;F&gt;<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a>, <a class="enum" href="../../halo2_proofs/plonk/error/enum.Error.html" title="enum halo2_proofs::plonk::error::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Places the SHA-256 IV in the circuit, returning the initial state variable.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.initialization" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/halo2_gadgets/sha256.rs.html#36-40" title="goto source code">source</a></div><h4 class="code-header">fn <a href="#tymethod.initialization" class="fnname">initialization</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;layouter: &amp;mut impl <a class="trait" href="../../halo2_proofs/circuit/trait.Layouter.html" title="trait halo2_proofs::circuit::Layouter">Layouter</a>&lt;F&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;init_state: &amp;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a>, <a class="enum" href="../../halo2_proofs/plonk/error/enum.Error.html" title="enum halo2_proofs::plonk::error::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Creates an initial state from the output state of a previous block</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.compress" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/halo2_gadgets/sha256.rs.html#44-49" title="goto source code">source</a></div><h4 class="code-header">fn <a href="#tymethod.compress" class="fnname">compress</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;layouter: &amp;mut impl <a class="trait" href="../../halo2_proofs/circuit/trait.Layouter.html" title="trait halo2_proofs::circuit::Layouter">Layouter</a>&lt;F&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;initialized_state: &amp;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;input: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a>Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.BlockWord" title="type halo2_gadgets::sha256::Sha256Instructions::BlockWord">BlockWord</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 16]</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a>, <a class="enum" href="../../halo2_proofs/plonk/error/enum.Error.html" title="enum halo2_proofs::plonk::error::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Starting from the given initialized state, processes a block of input and returns the
final state.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.digest" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/halo2_gadgets/sha256.rs.html#52-56" title="goto source code">source</a></div><h4 class="code-header">fn <a href="#tymethod.digest" class="fnname">digest</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;layouter: &amp;mut impl <a class="trait" href="../../halo2_proofs/circuit/trait.Layouter.html" title="trait halo2_proofs::circuit::Layouter">Layouter</a>&lt;F&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;state: &amp;Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.State" title="type halo2_gadgets::sha256::Sha256Instructions::State">State</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a>Self::<a class="associatedtype" href="trait.Sha256Instructions.html#associatedtype.BlockWord" title="type halo2_gadgets::sha256::Sha256Instructions::BlockWord">BlockWord</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 8]</a>, <a class="enum" href="../../halo2_proofs/plonk/error/enum.Error.html" title="enum halo2_proofs::plonk::error::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Converts the given state into a message digest.</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><div id="impl-Sha256Instructions%3CFp%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../../src/halo2_gadgets/sha256/table16.rs.html#329-374" title="goto source code">source</a></div><a href="#impl-Sha256Instructions%3CFp%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Sha256Instructions.html" title="trait halo2_gadgets::sha256::Sha256Instructions">Sha256Instructions</a>&lt;Fp&gt; for <a class="struct" href="struct.Table16Chip.html" title="struct halo2_gadgets::sha256::Table16Chip">Table16Chip</a></h3></div></summary><div class="impl-items"><div id="associatedtype.State-1" class="type trait-impl has-srclink"><a href="#associatedtype.State-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.State" class="associatedtype">State</a> = State</h4></div><div id="associatedtype.BlockWord-1" class="type trait-impl has-srclink"><a href="#associatedtype.BlockWord-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.BlockWord" class="associatedtype">BlockWord</a> = <a class="struct" href="struct.BlockWord.html" title="struct halo2_gadgets::sha256::BlockWord">BlockWord</a></h4></div></div></details></div><script type="text/javascript" src="../../implementors/halo2_gadgets/sha256/trait.Sha256Instructions.js" async></script></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="halo2_gadgets" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.60.0-nightly (ee5d8d37b 2022-01-17)" ></div>
</body></html>