Skip to content

Commit

Permalink
Adding or updating preview build for PR: 1478
Browse files Browse the repository at this point in the history
  • Loading branch information
Hodor The Master committed Feb 13, 2025
1 parent dcd4c09 commit 6ae9872
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1388,36 +1388,44 @@ <h3 id="example_5" class="discrete">Example</h3>
</div>
</div>
<div class="sect1">
<h2 id="secp256k1"><a class="anchor" href="#secp256k1"></a>Secp256k1 system calls</h2>
<h2 id="secp256k1"><a class="anchor" href="#secp256k1"></a>secp256k1</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The secp256k1 curve is commonly used in cryptographic applications such as Bitcoin and Ethereum.</p>
</div>
<div class="paragraph">
<p>Note that instead of using these syscalls directly, it is recommended to use the traits and implementations provided in the <a href="https://github.com/starkware-libs/cairo/blob/67c6eff9c276d11bd1cc903d7a3981d8d0eb2fa2/corelib/src/starknet/secp256_trait.cairo" target="_blank" rel="noopener"><code>secp256_trait</code></a> module which provide a more convenient interface and handle the syscalls under the hood.</p>
</div>
<div id="secp256k1_new_syscall" class="paragraph">
<p><code>secp256k1_new_syscall</code></p>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
Note that instead of using these syscalls directly, it is recommended to use the traits and implementations provided in the <a href="https://docs.swmansion.com/scarb/corelib/core-starknet-secp256k1.html" target="_blank" rel="noopener"><code>secp256-module</code></a> which provide a more convenient interface and handle the syscalls under the hood.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Function signature</p>
<p><code>secp256k1_new_syscall</code></p>
</div>
<div class="sect3">
<h4 id="function_signature_12"><a class="anchor" href="#function_signature_12"></a>Function signature</h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cairo hljs" data-lang="cairo">extern fn secp256k1_new_syscall(
x: u256, y: u256
) -&gt; SyscallResult&lt;Option&lt;Secp256k1Point&gt;&gt; implicits(GasBuiltin, System) nopanic;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Description</p>
</div>
<div class="sect3">
<h4 id="description_12"><a class="anchor" href="#description_12"></a>Description</h4>
<div class="paragraph">
<p>Creates a new point on the secp256k1 curve from its x and y coordinates.</p>
</div>
<div class="paragraph">
<p>Arguments</p>
</div>
<div class="sect3">
<h4 id="arguments_12"><a class="anchor" href="#arguments_12"></a>Arguments</h4>
<div class="hdlist">
<table>
<colgroup>
Expand All @@ -1442,21 +1450,21 @@ <h2 id="secp256k1"><a class="anchor" href="#secp256k1"></a>Secp256k1 system call
</tr>
</table>
</div>
<div class="paragraph">
<p>Return values</p>
</div>
<div class="sect3">
<h4 id="return_values_12"><a class="anchor" href="#return_values_12"></a>Return values</h4>
<div class="paragraph">
<p>Returns <code>Some(point)</code> if the coordinates represent a valid point on the curve, <code>None</code> otherwise.</p>
</div>
<div class="paragraph">
<p>Common library</p>
</div>
<div class="sect3">
<h4 id="common_library_11"><a class="anchor" href="#common_library_11"></a>Common library</h4>
<div class="paragraph">
<p><a href="https://github.com/starkware-libs/cairo/blob/main/corelib/src/starknet/secp256k1.cairo#74" target="_blank" rel="noopener"><code>secp256k1.cairo</code></a></p>
</div>
<div class="paragraph">
<p>Example</p>
</div>
<div class="sect3">
<h4 id="example_6"><a class="anchor" href="#example_6"></a>Example</h4>
<div class="paragraph">
<p>The following example demonstrates how to create a new point on the secp256k1 curve:</p>
</div>
Expand Down Expand Up @@ -1484,28 +1492,28 @@ <h2 id="secp256k1"><a class="anchor" href="#secp256k1"></a>Secp256k1 system call
}</code></pre>
</div>
</div>
<div id="secp256k1_add_syscall" class="paragraph">
<div class="paragraph">
<p><code>secp256k1_add_syscall</code></p>
</div>
<div class="paragraph">
<p>Function signature</p>
</div>
<div class="sect3">
<h4 id="function_signature_13"><a class="anchor" href="#function_signature_13"></a>Function signature</h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cairo hljs" data-lang="cairo">extern fn secp256k1_add_syscall(
p0: Secp256k1Point, p1: Secp256k1Point,
) -&gt; SyscallResult&lt;Secp256k1Point&gt; implicits(GasBuiltin, System) nopanic;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Description</p>
</div>
<div class="sect3">
<h4 id="description_13"><a class="anchor" href="#description_13"></a>Description</h4>
<div class="paragraph">
<p>Adds two points on the secp256k1 curve.</p>
</div>
<div class="paragraph">
<p>Arguments</p>
</div>
<div class="sect3">
<h4 id="arguments_13"><a class="anchor" href="#arguments_13"></a>Arguments</h4>
<div class="hdlist">
<table>
<colgroup>
Expand All @@ -1530,21 +1538,21 @@ <h2 id="secp256k1"><a class="anchor" href="#secp256k1"></a>Secp256k1 system call
</tr>
</table>
</div>
<div class="paragraph">
<p>Return values</p>
</div>
<div class="sect3">
<h4 id="return_values_13"><a class="anchor" href="#return_values_13"></a>Return values</h4>
<div class="paragraph">
<p>The resulting point from adding <code>p0</code> and <code>p1</code>.</p>
</div>
<div class="paragraph">
<p>Common library</p>
</div>
<div class="sect3">
<h4 id="common_library_12"><a class="anchor" href="#common_library_12"></a>Common library</h4>
<div class="paragraph">
<p><a href="https://github.com/starkware-libs/cairo/blob/main/corelib/src/starknet/secp256k1.cairo#L79" target="_blank" rel="noopener"><code>secp256k1.cairo</code></a></p>
</div>
<div class="paragraph">
<p>Example</p>
</div>
<div class="sect3">
<h4 id="example_7"><a class="anchor" href="#example_7"></a>Example</h4>
<div class="paragraph">
<p>The following example demonstrates how to add two points on the secp256k1 curve:</p>
</div>
Expand All @@ -1568,27 +1576,27 @@ <h2 id="secp256k1"><a class="anchor" href="#secp256k1"></a>Secp256k1 system call
let (sum_x, sum_y) = secp256k1_get_xy_syscall(sum).unwrap_syscall();</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="secp256k1_mul_syscall"><a class="anchor" href="#secp256k1_mul_syscall"></a><code>secp256k1_mul_syscall</code></h3>
<div class="paragraph">
<p>Function signature</p>
</div>
<div class="sect3">
<h4 id="function_signature_14"><a class="anchor" href="#function_signature_14"></a>Function signature</h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cairo hljs" data-lang="cairo">extern fn secp256k1_mul_syscall(
p: Secp256k1Point, scalar: u256,
) -&gt; SyscallResult&lt;Secp256k1Point&gt; implicits(GasBuiltin, System) nopanic;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Description</p>
</div>
<div class="sect3">
<h4 id="description_14"><a class="anchor" href="#description_14"></a>Description</h4>
<div class="paragraph">
<p>Multiplies a point on the secp256k1 curve by a <code>scalar</code> value.</p>
</div>
<div class="paragraph">
<p>Arguments</p>
</div>
<div class="sect3">
<h4 id="arguments_14"><a class="anchor" href="#arguments_14"></a>Arguments</h4>
<div class="hdlist">
<table>
<colgroup>
Expand All @@ -1613,21 +1621,21 @@ <h3 id="secp256k1_mul_syscall"><a class="anchor" href="#secp256k1_mul_syscall"><
</tr>
</table>
</div>
<div class="paragraph">
<p>Return values</p>
</div>
<div class="sect3">
<h4 id="return_values_14"><a class="anchor" href="#return_values_14"></a>Return values</h4>
<div class="paragraph">
<p>The resulting point from the <code>scalar</code> multiplication.</p>
</div>
<div class="paragraph">
<p>Common library</p>
</div>
<div class="sect3">
<h4 id="common_library_13"><a class="anchor" href="#common_library_13"></a>Common library</h4>
<div class="paragraph">
<p><a href="https://github.com/starkware-libs/cairo/blob/main/corelib/src/starknet/secp256k1.cairo#L84" target="_blank" rel="noopener"><code>secp256k1.cairo</code></a></p>
</div>
<div class="paragraph">
<p>Example</p>
</div>
<div class="sect3">
<h4 id="example_8"><a class="anchor" href="#example_8"></a>Example</h4>
<div class="paragraph">
<p>The following example demonstrates how to multiply a point by a scalar on the secp256k1 curve:</p>
</div>
Expand All @@ -1648,28 +1656,28 @@ <h3 id="secp256k1_mul_syscall"><a class="anchor" href="#secp256k1_mul_syscall"><
let (product_x, product_y) = secp256k1_get_xy_syscall(product).unwrap_syscall();</code></pre>
</div>
</div>
<div id="secp256k1_get_point_from_x_syscall" class="paragraph">
<div class="paragraph">
<p><code>secp256k1_get_point_from_x_syscall</code></p>
</div>
<div class="paragraph">
<p>Function signature</p>
</div>
<div class="sect3">
<h4 id="function_signature_15"><a class="anchor" href="#function_signature_15"></a>Function signature</h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cairo hljs" data-lang="cairo">extern fn secp256k1_get_point_from_x_syscall(
x: u256, y_parity: bool,
) -&gt; SyscallResult&lt;Option&lt;Secp256k1Point&gt;&gt; implicits(GasBuiltin, System) nopanic;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Description</p>
</div>
<div class="sect3">
<h4 id="description_15"><a class="anchor" href="#description_15"></a>Description</h4>
<div class="paragraph">
<p>Recovers a point on the curve given its x-coordinate and y-parity. Since the secp256k1 curve has an even and an odd solution for y given x, the y_parity parameter determines which y value to use.</p>
</div>
<div class="paragraph">
<p>Arguments</p>
</div>
<div class="sect3">
<h4 id="arguments_15"><a class="anchor" href="#arguments_15"></a>Arguments</h4>
<div class="hdlist">
<table>
<colgroup>
Expand All @@ -1694,21 +1702,21 @@ <h3 id="secp256k1_mul_syscall"><a class="anchor" href="#secp256k1_mul_syscall"><
</tr>
</table>
</div>
<div class="paragraph">
<p>Return values</p>
</div>
<div class="sect3">
<h4 id="return_values_15"><a class="anchor" href="#return_values_15"></a>Return values</h4>
<div class="paragraph">
<p>Returns <code>Some(point)</code> if a point exists with the given <code>x</code> coordinate, <code>None</code> otherwise.</p>
</div>
<div class="paragraph">
<p>Common library</p>
</div>
<div class="sect3">
<h4 id="common_library_14"><a class="anchor" href="#common_library_14"></a>Common library</h4>
<div class="paragraph">
<p><a href="https://github.com/starkware-libs/cairo/blob/main/corelib/src/starknet/secp256k1.cairo#L102" target="_blank" rel="noopener"><code>secp256k1.cairo</code></a></p>
</div>
<div class="paragraph">
<p>Example</p>
</div>
<div class="sect3">
<h4 id="example_9"><a class="anchor" href="#example_9"></a>Example</h4>
<div class="paragraph">
<p>The following example demonstrates how to recover a point from its x-coordinate and y-parity:</p>
</div>
Expand All @@ -1735,28 +1743,28 @@ <h3 id="secp256k1_mul_syscall"><a class="anchor" href="#secp256k1_mul_syscall"><
}</code></pre>
</div>
</div>
<div id="secp256k1_get_xy_syscall" class="paragraph">
<div class="paragraph">
<p><code>secp256k1_get_xy_syscall</code></p>
</div>
<div class="paragraph">
<p>Function signature</p>
</div>
<div class="sect3">
<h4 id="function_signature_16"><a class="anchor" href="#function_signature_16"></a>Function signature</h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cairo hljs" data-lang="cairo">extern fn secp256k1_get_xy_syscall(
p: Secp256k1Point,
) -&gt; SyscallResult&lt;(u256, u256)&gt; implicits(GasBuiltin, System) nopanic;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Description</p>
</div>
<div class="sect3">
<h4 id="description_16"><a class="anchor" href="#description_16"></a>Description</h4>
<div class="paragraph">
<p>Returns the coordinates of a point on the secp256k1 curve.</p>
</div>
<div class="paragraph">
<p>Arguments</p>
</div>
<div class="sect3">
<h4 id="arguments_16"><a class="anchor" href="#arguments_16"></a>Arguments</h4>
<div class="hdlist">
<table>
<colgroup>
Expand All @@ -1773,21 +1781,21 @@ <h3 id="secp256k1_mul_syscall"><a class="anchor" href="#secp256k1_mul_syscall"><
</tr>
</table>
</div>
<div class="paragraph">
<p>Return values</p>
</div>
<div class="sect3">
<h4 id="return_values_16"><a class="anchor" href="#return_values_16"></a>Return values</h4>
<div class="paragraph">
<p>A tuple containing the <code>x</code> and <code>y</code> coordinates of the point.</p>
</div>
<div class="paragraph">
<p>Common library</p>
</div>
<div class="sect3">
<h4 id="common_library_15"><a class="anchor" href="#common_library_15"></a>Common library</h4>
<div class="paragraph">
<p><a href="https://github.com/starkware-libs/cairo/blob/main/corelib/src/starknet/secp256k1.cairo#L107" target="_blank" rel="noopener"><code>secp256k1.cairo</code></a></p>
</div>
<div class="paragraph">
<p>Example</p>
</div>
<div class="sect3">
<h4 id="example_10"><a class="anchor" href="#example_10"></a>Example</h4>
<div class="paragraph">
<p>The following example demonstrates how to get the coordinates of a point on the secp256k1 curve:</p>
</div>
Expand All @@ -1811,6 +1819,7 @@ <h3 id="secp256k1_mul_syscall"><a class="anchor" href="#secp256k1_mul_syscall"><
</div>
</div>
</div>
</div>
<nav class="pagination">
<span class="prev"><a href="../serialization-of-cairo-types/">Serialization of Cairo types</a></span>
<span class="next"><a href="../execution-info/">Execution information for the current block</a></span>
Expand Down
2 changes: 1 addition & 1 deletion pr-1478/search-index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 6ae9872

Please sign in to comment.