Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncompressed G1 group elements #19684

Merged
merged 37 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f56a9a7
G1 uncompressed points, first draft
jonas-lj Oct 2, 2024
d1d5ac4
clean up
jonas-lj Oct 3, 2024
4735f5a
Clean up + tests
jonas-lj Oct 3, 2024
eb8a511
Remove unused function
jonas-lj Oct 3, 2024
099f64c
clean up
jonas-lj Oct 3, 2024
5296dd3
Use existing Element type
jonas-lj Oct 4, 2024
dc7bf7c
visibility
jonas-lj Oct 4, 2024
7d3c86e
simplify
jonas-lj Oct 4, 2024
4b8a571
review
jonas-lj Oct 7, 2024
4e6ea9c
docs
jonas-lj Oct 7, 2024
957ac6a
Update crates/sui-framework/packages/sui-framework/sources/crypto/bls…
jonas-lj Oct 7, 2024
0696831
name
jonas-lj Oct 10, 2024
a30feb9
random tests
jonas-lj Oct 10, 2024
5924ba7
Set max terms
jonas-lj Oct 10, 2024
3bccb00
namd
jonas-lj Oct 10, 2024
c9e8353
typo
jonas-lj Oct 10, 2024
cf1fa69
set const in newest protocol version
jonas-lj Oct 10, 2024
c6af5c8
openrpc
jonas-lj Oct 10, 2024
fa63a78
rename enum + baseline
jonas-lj Oct 10, 2024
a3923b6
typo
jonas-lj Oct 10, 2024
44c05fc
snapshot
jonas-lj Oct 16, 2024
bbb463c
snapshots
jonas-lj Oct 16, 2024
cd20856
more snapshots
jonas-lj Oct 16, 2024
bf84cea
new snapshots
jonas-lj Oct 16, 2024
03cd7f9
snapshots
jonas-lj Oct 16, 2024
59154f4
remove
jonas-lj Oct 16, 2024
237217f
set gas price only for devnet
jonas-lj Oct 17, 2024
997b9b1
Revert "set gas price only for devnet"
jonas-lj Oct 17, 2024
feb55d7
new snapshots after rebase
jonas-lj Oct 18, 2024
7763b61
Update snapshots...
jonas-lj Oct 18, 2024
8e5ffc5
more snapshots...
jonas-lj Oct 18, 2024
af3049e
remove newline
jonas-lj Oct 18, 2024
188ff71
remove newline
jonas-lj Oct 18, 2024
56ba80b
version 66
jonas-lj Oct 19, 2024
134f8f6
fresh schema
jonas-lj Oct 21, 2024
4537d5c
use u64 as max terms type
jonas-lj Oct 21, 2024
40496db
fix type
jonas-lj Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,10 @@ move-abstract-interpreter = { path = "external-crates/move/crates/move-abstract-
move-abstract-stack = { path = "external-crates/move/crates/move-abstract-stack" }
move-analyzer = { path = "external-crates/move/crates/move-analyzer" }

fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "c050ffc78b93739328af5d59b05f90e0e26b1b7e" }
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "c050ffc78b93739328af5d59b05f90e0e26b1b7e" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "c050ffc78b93739328af5d59b05f90e0e26b1b7e", package = "fastcrypto-zkp" }
fastcrypto-vdf = { git = "https://github.com/MystenLabs/fastcrypto", rev = "c050ffc78b93739328af5d59b05f90e0e26b1b7e", features = [
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "2f502fd8570fe4e9cff36eea5bbd6fef22002898" }
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "2f502fd8570fe4e9cff36eea5bbd6fef22002898" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "2f502fd8570fe4e9cff36eea5bbd6fef22002898", package = "fastcrypto-zkp" }
fastcrypto-vdf = { git = "https://github.com/MystenLabs/fastcrypto", rev = "2f502fd8570fe4e9cff36eea5bbd6fef22002898", features = [
"experimental",
] }
passkey-types = { version = "0.2.0" }
Expand Down
117 changes: 117 additions & 0 deletions crates/sui-framework/docs/sui-framework/bls12381.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Group operations of BLS12-381.
- [Struct `G1`](#0x2_bls12381_G1)
- [Struct `G2`](#0x2_bls12381_G2)
- [Struct `GT`](#0x2_bls12381_GT)
- [Struct `UncompressedG1`](#0x2_bls12381_UncompressedG1)
- [Constants](#@Constants_0)
- [Function `bls12381_min_sig_verify`](#0x2_bls12381_bls12381_min_sig_verify)
- [Function `bls12381_min_pk_verify`](#0x2_bls12381_bls12381_min_pk_verify)
Expand All @@ -32,6 +33,7 @@ Group operations of BLS12-381.
- [Function `g1_neg`](#0x2_bls12381_g1_neg)
- [Function `hash_to_g1`](#0x2_bls12381_hash_to_g1)
- [Function `g1_multi_scalar_multiplication`](#0x2_bls12381_g1_multi_scalar_multiplication)
- [Function `g1_to_uncompressed_g1`](#0x2_bls12381_g1_to_uncompressed_g1)
- [Function `g2_from_bytes`](#0x2_bls12381_g2_from_bytes)
- [Function `g2_identity`](#0x2_bls12381_g2_identity)
- [Function `g2_generator`](#0x2_bls12381_g2_generator)
Expand All @@ -50,6 +52,8 @@ Group operations of BLS12-381.
- [Function `gt_div`](#0x2_bls12381_gt_div)
- [Function `gt_neg`](#0x2_bls12381_gt_neg)
- [Function `pairing`](#0x2_bls12381_pairing)
- [Function `uncompressed_g1_to_g1`](#0x2_bls12381_uncompressed_g1_to_g1)
- [Function `uncompressed_g1_sum`](#0x2_bls12381_uncompressed_g1_sum)


<pre><code><b>use</b> <a href="group_ops.md#0x2_group_ops">0x2::group_ops</a>;
Expand Down Expand Up @@ -149,6 +153,33 @@ Group operations of BLS12-381.



<details>
<summary>Fields</summary>


<dl>
<dt>
<code>dummy_field: bool</code>
</dt>
<dd>

</dd>
</dl>


</details>

<a name="0x2_bls12381_UncompressedG1"></a>

## Struct `UncompressedG1`



<pre><code><b>struct</b> <a href="bls12381.md#0x2_bls12381_UncompressedG1">UncompressedG1</a>
</code></pre>



<details>
<summary>Fields</summary>

Expand Down Expand Up @@ -278,6 +309,15 @@ Group operations of BLS12-381.



<a name="0x2_bls12381_UNCOMPRESSED_G1_TYPE"></a>



<pre><code><b>const</b> <a href="bls12381.md#0x2_bls12381_UNCOMPRESSED_G1_TYPE">UNCOMPRESSED_G1_TYPE</a>: u8 = 4;
</code></pre>



<a name="0x2_bls12381_bls12381_min_sig_verify"></a>

## Function `bls12381_min_sig_verify`
Expand Down Expand Up @@ -835,6 +875,31 @@ Aborts with <code>EInputTooLong</code> if the vectors are larger than 32 (may in



</details>

<a name="0x2_bls12381_g1_to_uncompressed_g1"></a>

## Function `g1_to_uncompressed_g1`

Convert an <code>Element&lt;<a href="bls12381.md#0x2_bls12381_G1">G1</a>&gt;</code> to uncompressed form.


<pre><code><b>public</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_g1_to_uncompressed_g1">g1_to_uncompressed_g1</a>(e: &<a href="group_ops.md#0x2_group_ops_Element">group_ops::Element</a>&lt;<a href="bls12381.md#0x2_bls12381_G1">bls12381::G1</a>&gt;): <a href="group_ops.md#0x2_group_ops_Element">group_ops::Element</a>&lt;<a href="bls12381.md#0x2_bls12381_UncompressedG1">bls12381::UncompressedG1</a>&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_g1_to_uncompressed_g1">g1_to_uncompressed_g1</a>(e: &Element&lt;<a href="bls12381.md#0x2_bls12381_G1">G1</a>&gt;): Element&lt;<a href="bls12381.md#0x2_bls12381_UncompressedG1">UncompressedG1</a>&gt; {
<a href="group_ops.md#0x2_group_ops_convert">group_ops::convert</a>(<a href="bls12381.md#0x2_bls12381_G1_TYPE">G1_TYPE</a>, <a href="bls12381.md#0x2_bls12381_UNCOMPRESSED_G1_TYPE">UNCOMPRESSED_G1_TYPE</a>, e)
}
</code></pre>



</details>

<a name="0x2_bls12381_g2_from_bytes"></a>
Expand Down Expand Up @@ -1280,4 +1345,56 @@ Returns e2 / e1, fails if scalar is zero.



</details>

<a name="0x2_bls12381_uncompressed_g1_to_g1"></a>

## Function `uncompressed_g1_to_g1`

UncompressedG1 group operations ///
Create a <code>Element&lt;<a href="bls12381.md#0x2_bls12381_G1">G1</a>&gt;</code> from its uncompressed form.


<pre><code><b>public</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_uncompressed_g1_to_g1">uncompressed_g1_to_g1</a>(e: &<a href="group_ops.md#0x2_group_ops_Element">group_ops::Element</a>&lt;<a href="bls12381.md#0x2_bls12381_UncompressedG1">bls12381::UncompressedG1</a>&gt;): <a href="group_ops.md#0x2_group_ops_Element">group_ops::Element</a>&lt;<a href="bls12381.md#0x2_bls12381_G1">bls12381::G1</a>&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_uncompressed_g1_to_g1">uncompressed_g1_to_g1</a>(e: &Element&lt;<a href="bls12381.md#0x2_bls12381_UncompressedG1">UncompressedG1</a>&gt;): Element&lt;<a href="bls12381.md#0x2_bls12381_G1">G1</a>&gt; {
<a href="group_ops.md#0x2_group_ops_convert">group_ops::convert</a>(<a href="bls12381.md#0x2_bls12381_UNCOMPRESSED_G1_TYPE">UNCOMPRESSED_G1_TYPE</a>, <a href="bls12381.md#0x2_bls12381_G1_TYPE">G1_TYPE</a>, e)
}
</code></pre>



</details>

<a name="0x2_bls12381_uncompressed_g1_sum"></a>

## Function `uncompressed_g1_sum`

Compute the sum of a list of uncompressed elements.
This is significantly faster and cheaper than summing the elements.


<pre><code><b>public</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_uncompressed_g1_sum">uncompressed_g1_sum</a>(terms: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;<a href="group_ops.md#0x2_group_ops_Element">group_ops::Element</a>&lt;<a href="bls12381.md#0x2_bls12381_UncompressedG1">bls12381::UncompressedG1</a>&gt;&gt;): <a href="group_ops.md#0x2_group_ops_Element">group_ops::Element</a>&lt;<a href="bls12381.md#0x2_bls12381_UncompressedG1">bls12381::UncompressedG1</a>&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_uncompressed_g1_sum">uncompressed_g1_sum</a>(terms: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Element&lt;<a href="bls12381.md#0x2_bls12381_UncompressedG1">UncompressedG1</a>&gt;&gt;): Element&lt;<a href="bls12381.md#0x2_bls12381_UncompressedG1">UncompressedG1</a>&gt; {
<a href="group_ops.md#0x2_group_ops_sum">group_ops::sum</a>(<a href="bls12381.md#0x2_bls12381_UNCOMPRESSED_G1_TYPE">UNCOMPRESSED_G1_TYPE</a>, terms)
}
</code></pre>



</details>
96 changes: 96 additions & 0 deletions crates/sui-framework/docs/sui-framework/group_ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Generic Move and native functions for group operations.
- [Function `hash_to`](#0x2_group_ops_hash_to)
- [Function `multi_scalar_multiplication`](#0x2_group_ops_multi_scalar_multiplication)
- [Function `pairing`](#0x2_group_ops_pairing)
- [Function `convert`](#0x2_group_ops_convert)
- [Function `sum`](#0x2_group_ops_sum)
- [Function `internal_validate`](#0x2_group_ops_internal_validate)
- [Function `internal_add`](#0x2_group_ops_internal_add)
- [Function `internal_sub`](#0x2_group_ops_internal_sub)
Expand All @@ -25,6 +27,8 @@ Generic Move and native functions for group operations.
- [Function `internal_hash_to`](#0x2_group_ops_internal_hash_to)
- [Function `internal_multi_scalar_mul`](#0x2_group_ops_internal_multi_scalar_mul)
- [Function `internal_pairing`](#0x2_group_ops_internal_pairing)
- [Function `internal_convert`](#0x2_group_ops_internal_convert)
- [Function `internal_sum`](#0x2_group_ops_internal_sum)
- [Function `set_as_prefix`](#0x2_group_ops_set_as_prefix)


Expand Down Expand Up @@ -364,6 +368,54 @@ Aborts with <code><a href="group_ops.md#0x2_group_ops_EInputTooLong">EInputTooLo



</details>

<a name="0x2_group_ops_convert"></a>

## Function `convert`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="group_ops.md#0x2_group_ops_convert">convert</a>&lt;From, To&gt;(from_type_: u8, to_type_: u8, e: &<a href="group_ops.md#0x2_group_ops_Element">group_ops::Element</a>&lt;From&gt;): <a href="group_ops.md#0x2_group_ops_Element">group_ops::Element</a>&lt;To&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b>(<a href="package.md#0x2_package">package</a>) <b>fun</b> <a href="group_ops.md#0x2_group_ops_convert">convert</a>&lt;From, To&gt;(from_type_: u8, to_type_: u8, e: &<a href="group_ops.md#0x2_group_ops_Element">Element</a>&lt;From&gt;): <a href="group_ops.md#0x2_group_ops_Element">Element</a>&lt;To&gt; {
<a href="group_ops.md#0x2_group_ops_Element">Element</a>&lt;To&gt; { bytes: <a href="group_ops.md#0x2_group_ops_internal_convert">internal_convert</a>(from_type_, to_type_, &e.bytes) }
}
</code></pre>



</details>

<a name="0x2_group_ops_sum"></a>

## Function `sum`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="group_ops.md#0x2_group_ops_sum">sum</a>&lt;G&gt;(type_: u8, terms: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;<a href="group_ops.md#0x2_group_ops_Element">group_ops::Element</a>&lt;G&gt;&gt;): <a href="group_ops.md#0x2_group_ops_Element">group_ops::Element</a>&lt;G&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b>(<a href="package.md#0x2_package">package</a>) <b>fun</b> <a href="group_ops.md#0x2_group_ops_sum">sum</a>&lt;G&gt;(type_: u8, terms: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;<a href="group_ops.md#0x2_group_ops_Element">Element</a>&lt;G&gt;&gt;): <a href="group_ops.md#0x2_group_ops_Element">Element</a>&lt;G&gt; {
<a href="group_ops.md#0x2_group_ops_Element">Element</a>&lt;G&gt; { bytes: <a href="group_ops.md#0x2_group_ops_internal_sum">internal_sum</a>(type_, &(*terms).map!(|x| x.bytes)) }
}
</code></pre>



</details>

<a name="0x2_group_ops_internal_validate"></a>
Expand Down Expand Up @@ -544,6 +596,50 @@ Aborts with <code><a href="group_ops.md#0x2_group_ops_EInputTooLong">EInputTooLo



</details>

<a name="0x2_group_ops_internal_convert"></a>

## Function `internal_convert`



<pre><code><b>fun</b> <a href="group_ops.md#0x2_group_ops_internal_convert">internal_convert</a>(from_type_: u8, to_type_: u8, e: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="group_ops.md#0x2_group_ops_internal_convert">internal_convert</a>(from_type_: u8, to_type_: u8, e: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;;
</code></pre>



</details>

<a name="0x2_group_ops_internal_sum"></a>

## Function `internal_sum`



<pre><code><b>fun</b> <a href="group_ops.md#0x2_group_ops_internal_sum">internal_sum</a>(type_: u8, e: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;&gt;): <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="group_ops.md#0x2_group_ops_internal_sum">internal_sum</a>(type_: u8, e: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;&gt;): <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;;
</code></pre>



</details>

<a name="0x2_group_ops_set_as_prefix"></a>
Expand Down
Loading
Loading