Skip to content

Commit

Permalink
[gh-457] resolve repo and add schnorr.move
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Jul 19, 2023
1 parent b9729e3 commit 9921453
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ enum_dispatch = "^0.3"
ethereum-types = "0.14.1"
ethers = { version = "2.0.7", features = ["legacy"] }
eyre = "0.6.8"
fastcrypto = { git = "https://github.com/feliciss/fastcrypto", branch = "schnorr" }
fastcrypto = { git = "https://github.com/rooch-network/fastcrypto", branch = "main" }
futures = "0.3"
hex = "0.4.3"
rustc-hex = "1.0"
Expand Down
1 change: 1 addition & 0 deletions crates/rooch-framework/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This is the reference documentation of the Rooch Framework.
- [`0x3::genesis`](genesis.md#0x3_genesis)
- [`0x3::hash`](hash.md#0x3_hash)
- [`0x3::multi_ed25519_validator`](multi_ed25519_validator.md#0x3_multi_ed25519_validator)
- [`0x3::schnorr`](schnorr.md#0x3_schnorr)
- [`0x3::transaction_validator`](transaction_validator.md#0x3_transaction_validator)


Expand Down
44 changes: 44 additions & 0 deletions crates/rooch-framework/doc/schnorr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

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

# Module `0x3::schnorr`



- [Function `verify`](#0x3_schnorr_verify)


<pre><code></code></pre>



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

## Function `verify`

@param signature: A 65-bytes signature that is signed using Schnorr over Secpk256k1 key pairs.
@param msg: The message that the signature is signed against.
@param hash: The hash function used to hash the message when signing.

If the signature is valid to the pubkey and hashed message, return true. Else false.


<pre><code><b>public</b> <b>fun</b> <a href="schnorr.md#0x3_schnorr_verify">verify</a>(signature: &<a href="">vector</a>&lt;u8&gt;, msg: &<a href="">vector</a>&lt;u8&gt;, <a href="../doc/hash.md#0x1_hash">hash</a>: u8): bool
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="schnorr.md#0x3_schnorr_verify">verify</a>(
signature: &<a href="">vector</a>&lt;u8&gt;,
msg: &<a href="">vector</a>&lt;u8&gt;,
<a href="../doc/hash.md#0x1_hash">hash</a>: u8
): bool;
</code></pre>



</details>
30 changes: 30 additions & 0 deletions crates/rooch-framework/sources/crypto/schnorr.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module rooch_framework::schnorr {
/// @param signature: A 65-bytes signature that is signed using Schnorr over Secpk256k1 key pairs.
/// @param msg: The message that the signature is signed against.
/// @param hash: The hash function used to hash the message when signing.
///
/// If the signature is valid to the pubkey and hashed message, return true. Else false.
public native fun verify(
signature: &vector<u8>,
msg: &vector<u8>,
hash: u8
): bool;

// TODO add tests following ecdsa_k1

#[test]
public fun test_schnorr_valid_sig() {
}

#[test]
public fun test_schnorr_invalid_sig() {
}

#[test]
public fun test_schnorr_valid_message() {
}

#[test]
public fun test_schnorr_invalid_message() {
}
}
Binary file modified crates/rooch-genesis/genesis/genesis
Binary file not shown.

0 comments on commit 9921453

Please sign in to comment.