Skip to content

Commit

Permalink
[framework] Formatting: crypto, test, kiosk 3/N (#19496)
Browse files Browse the repository at this point in the history
## Description 

Formats 3 parts of the Sui Framework: `crypto`, `kiosk` and `test`

Previous PRs:
- #19461 
- #19463 

## Test plan 

All existing tests pass.

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
damirka authored Sep 23, 2024
1 parent d2a5f44 commit 29e6347
Show file tree
Hide file tree
Showing 32 changed files with 2,426 additions and 2,318 deletions.
22 changes: 18 additions & 4 deletions crates/sui-framework/docs/sui-framework/bls12381.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_, return true. Otherwise, return fals
<summary>Implementation</summary>


<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_bls12381_min_sig_verify">bls12381_min_sig_verify</a>(signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): bool;
<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_bls12381_min_sig_verify">bls12381_min_sig_verify</a>(
signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
): bool;
</code></pre>


Expand Down Expand Up @@ -327,7 +331,11 @@ BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_, return true. Otherwise, return fals
<summary>Implementation</summary>


<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_bls12381_min_pk_verify">bls12381_min_pk_verify</a>(signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): bool;
<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_bls12381_min_pk_verify">bls12381_min_pk_verify</a>(
signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
): bool;
</code></pre>


Expand Down Expand Up @@ -817,7 +825,10 @@ Aborts with <code>EInputTooLong</code> if the vectors are larger than 32 (may in
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_g1_multi_scalar_multiplication">g1_multi_scalar_multiplication</a>(scalars: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Element&lt;<a href="bls12381.md#0x2_bls12381_Scalar">Scalar</a>&gt;&gt;, elements: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Element&lt;<a href="bls12381.md#0x2_bls12381_G1">G1</a>&gt;&gt;): Element&lt;<a href="bls12381.md#0x2_bls12381_G1">G1</a>&gt; {
<pre><code><b>public</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_g1_multi_scalar_multiplication">g1_multi_scalar_multiplication</a>(
scalars: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Element&lt;<a href="bls12381.md#0x2_bls12381_Scalar">Scalar</a>&gt;&gt;,
elements: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Element&lt;<a href="bls12381.md#0x2_bls12381_G1">G1</a>&gt;&gt;,
): Element&lt;<a href="bls12381.md#0x2_bls12381_G1">G1</a>&gt; {
<a href="group_ops.md#0x2_group_ops_multi_scalar_multiplication">group_ops::multi_scalar_multiplication</a>(<a href="bls12381.md#0x2_bls12381_G1_TYPE">G1_TYPE</a>, scalars, elements)
}
</code></pre>
Expand Down Expand Up @@ -1064,7 +1075,10 @@ Aborts with <code>EInputTooLong</code> if the vectors are larger than 32 (may in
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_g2_multi_scalar_multiplication">g2_multi_scalar_multiplication</a>(scalars: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Element&lt;<a href="bls12381.md#0x2_bls12381_Scalar">Scalar</a>&gt;&gt;, elements: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Element&lt;<a href="bls12381.md#0x2_bls12381_G2">G2</a>&gt;&gt;): Element&lt;<a href="bls12381.md#0x2_bls12381_G2">G2</a>&gt; {
<pre><code><b>public</b> <b>fun</b> <a href="bls12381.md#0x2_bls12381_g2_multi_scalar_multiplication">g2_multi_scalar_multiplication</a>(
scalars: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Element&lt;<a href="bls12381.md#0x2_bls12381_Scalar">Scalar</a>&gt;&gt;,
elements: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;Element&lt;<a href="bls12381.md#0x2_bls12381_G2">G2</a>&gt;&gt;,
): Element&lt;<a href="bls12381.md#0x2_bls12381_G2">G2</a>&gt; {
<a href="group_ops.md#0x2_group_ops_multi_scalar_multiplication">group_ops::multi_scalar_multiplication</a>(<a href="bls12381.md#0x2_bls12381_G2_TYPE">G2_TYPE</a>, scalars, elements)
}
</code></pre>
Expand Down
13 changes: 11 additions & 2 deletions crates/sui-framework/docs/sui-framework/ecdsa_k1.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ applied to Secp256k1 signatures. May abort with <code><a href="ecdsa_k1.md#0x2_e
<summary>Implementation</summary>


<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ecdsa_k1.md#0x2_ecdsa_k1_secp256k1_ecrecover">secp256k1_ecrecover</a>(signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, <a href="hash.md#0x2_hash">hash</a>: u8): <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;;
<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ecdsa_k1.md#0x2_ecdsa_k1_secp256k1_ecrecover">secp256k1_ecrecover</a>(
signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
<a href="hash.md#0x2_hash">hash</a>: u8,
): <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;;
</code></pre>


Expand Down Expand Up @@ -150,7 +154,12 @@ If the signature is valid to the pubkey and hashed message, return true. Else fa
<summary>Implementation</summary>


<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ecdsa_k1.md#0x2_ecdsa_k1_secp256k1_verify">secp256k1_verify</a>(signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, <a href="hash.md#0x2_hash">hash</a>: u8): bool;
<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ecdsa_k1.md#0x2_ecdsa_k1_secp256k1_verify">secp256k1_verify</a>(
signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
<a href="hash.md#0x2_hash">hash</a>: u8,
): bool;
</code></pre>


Expand Down
13 changes: 11 additions & 2 deletions crates/sui-framework/docs/sui-framework/ecdsa_r1.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ applied to Secp256r1 signatures. May fail with <code><a href="ecdsa_r1.md#0x2_ec
<summary>Implementation</summary>


<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ecdsa_r1.md#0x2_ecdsa_r1_secp256r1_ecrecover">secp256r1_ecrecover</a>(signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, <a href="hash.md#0x2_hash">hash</a>: u8): <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;;
<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ecdsa_r1.md#0x2_ecdsa_r1_secp256r1_ecrecover">secp256r1_ecrecover</a>(
signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
<a href="hash.md#0x2_hash">hash</a>: u8,
): <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;;
</code></pre>


Expand Down Expand Up @@ -113,7 +117,12 @@ If the signature is valid to the pubkey and hashed message, return true. Else fa
<summary>Implementation</summary>


<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ecdsa_r1.md#0x2_ecdsa_r1_secp256r1_verify">secp256r1_verify</a>(signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, <a href="hash.md#0x2_hash">hash</a>: u8): bool;
<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ecdsa_r1.md#0x2_ecdsa_r1_secp256r1_verify">secp256r1_verify</a>(
signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
<a href="hash.md#0x2_hash">hash</a>: u8,
): bool;
</code></pre>


Expand Down
7 changes: 6 additions & 1 deletion crates/sui-framework/docs/sui-framework/ecvrf.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ Verify a proof for a Ristretto ECVRF. Returns true if the proof is valid and cor
<summary>Implementation</summary>


<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ecvrf.md#0x2_ecvrf_ecvrf_verify">ecvrf_verify</a>(<a href="hash.md#0x2_hash">hash</a>: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, alpha_string: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, proof: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): bool;
<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ecvrf.md#0x2_ecvrf_ecvrf_verify">ecvrf_verify</a>(
<a href="hash.md#0x2_hash">hash</a>: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
alpha_string: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
proof: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
): bool;
</code></pre>


Expand Down
6 changes: 5 additions & 1 deletion crates/sui-framework/docs/sui-framework/ed25519.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ Otherwise, return false.
<summary>Implementation</summary>


<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ed25519.md#0x2_ed25519_ed25519_verify">ed25519_verify</a>(signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): bool;
<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="ed25519.md#0x2_ed25519_ed25519_verify">ed25519_verify</a>(
signature: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
public_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
msg: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
): bool;
</code></pre>


Expand Down
33 changes: 27 additions & 6 deletions crates/sui-framework/docs/sui-framework/groth16.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,17 @@ Creates a <code><a href="groth16.md#0x2_groth16_PreparedVerifyingKey">PreparedVe
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="groth16.md#0x2_groth16_pvk_from_bytes">pvk_from_bytes</a>(vk_gamma_abc_g1_bytes: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, alpha_g1_beta_g2_bytes: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, gamma_g2_neg_pc_bytes: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, delta_g2_neg_pc_bytes: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): <a href="groth16.md#0x2_groth16_PreparedVerifyingKey">PreparedVerifyingKey</a> {
<pre><code><b>public</b> <b>fun</b> <a href="groth16.md#0x2_groth16_pvk_from_bytes">pvk_from_bytes</a>(
vk_gamma_abc_g1_bytes: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
alpha_g1_beta_g2_bytes: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
gamma_g2_neg_pc_bytes: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
delta_g2_neg_pc_bytes: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
): <a href="groth16.md#0x2_groth16_PreparedVerifyingKey">PreparedVerifyingKey</a> {
<a href="groth16.md#0x2_groth16_PreparedVerifyingKey">PreparedVerifyingKey</a> {
vk_gamma_abc_g1_bytes,
alpha_g1_beta_g2_bytes,
gamma_g2_neg_pc_bytes,
delta_g2_neg_pc_bytes
delta_g2_neg_pc_bytes,
}
}
</code></pre>
Expand Down Expand Up @@ -411,7 +416,10 @@ Native functions that flattens the inputs into an array and passes to the Rust n
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="groth16.md#0x2_groth16_prepare_verifying_key_internal">prepare_verifying_key_internal</a>(curve: u8, verifying_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): <a href="groth16.md#0x2_groth16_PreparedVerifyingKey">PreparedVerifyingKey</a>;
<pre><code><b>native</b> <b>fun</b> <a href="groth16.md#0x2_groth16_prepare_verifying_key_internal">prepare_verifying_key_internal</a>(
curve: u8,
verifying_key: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
): <a href="groth16.md#0x2_groth16_PreparedVerifyingKey">PreparedVerifyingKey</a>;
</code></pre>


Expand Down Expand Up @@ -439,15 +447,20 @@ Returns a boolean indicating whether the proof is valid.
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="groth16.md#0x2_groth16_verify_groth16_proof">verify_groth16_proof</a>(curve: &<a href="groth16.md#0x2_groth16_Curve">Curve</a>, prepared_verifying_key: &<a href="groth16.md#0x2_groth16_PreparedVerifyingKey">PreparedVerifyingKey</a>, public_proof_inputs: &<a href="groth16.md#0x2_groth16_PublicProofInputs">PublicProofInputs</a>, proof_points: &<a href="groth16.md#0x2_groth16_ProofPoints">ProofPoints</a>): bool {
<pre><code><b>public</b> <b>fun</b> <a href="groth16.md#0x2_groth16_verify_groth16_proof">verify_groth16_proof</a>(
curve: &<a href="groth16.md#0x2_groth16_Curve">Curve</a>,
prepared_verifying_key: &<a href="groth16.md#0x2_groth16_PreparedVerifyingKey">PreparedVerifyingKey</a>,
public_proof_inputs: &<a href="groth16.md#0x2_groth16_PublicProofInputs">PublicProofInputs</a>,
proof_points: &<a href="groth16.md#0x2_groth16_ProofPoints">ProofPoints</a>,
): bool {
<a href="groth16.md#0x2_groth16_verify_groth16_proof_internal">verify_groth16_proof_internal</a>(
curve.id,
&prepared_verifying_key.vk_gamma_abc_g1_bytes,
&prepared_verifying_key.alpha_g1_beta_g2_bytes,
&prepared_verifying_key.gamma_g2_neg_pc_bytes,
&prepared_verifying_key.delta_g2_neg_pc_bytes,
&public_proof_inputs.bytes,
&proof_points.bytes
&proof_points.bytes,
)
}
</code></pre>
Expand All @@ -472,7 +485,15 @@ Native functions that flattens the inputs into arrays of vectors and passed to t
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="groth16.md#0x2_groth16_verify_groth16_proof_internal">verify_groth16_proof_internal</a>(curve: u8, vk_gamma_abc_g1_bytes: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, alpha_g1_beta_g2_bytes: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, gamma_g2_neg_pc_bytes: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, delta_g2_neg_pc_bytes: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, public_proof_inputs: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, proof_points: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): bool;
<pre><code><b>native</b> <b>fun</b> <a href="groth16.md#0x2_groth16_verify_groth16_proof_internal">verify_groth16_proof_internal</a>(
curve: u8,
vk_gamma_abc_g1_bytes: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
alpha_g1_beta_g2_bytes: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
gamma_g2_neg_pc_bytes: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
delta_g2_neg_pc_bytes: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
public_proof_inputs: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
proof_points: &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
): bool;
</code></pre>


Expand Down
Loading

0 comments on commit 29e6347

Please sign in to comment.