Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicalinluca committed Aug 22, 2024
1 parent 9543e03 commit 3fc082a
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,56 @@
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "4",
"tx": {
"from": "address:an_account",
"to": "sc:basic-features",
"function": "verify_bls_signature_share",
"arguments": [
"0xb5823f6e564251cc03ce7bad3da83e72576e92795d3500bba1acb30ec9a94dce87bb8aa794d67b2d61d15c33f28f6c0c23ba1dfcbf21e8f8b46286ff871afabac925303ddcaddce6254fcff6d3155797db40b3d3b5865e8fc0bd770b3d79b381",
"0x6d65737361676520746f206265207369676e6564",
"0xaf32a2ddf341c08d1eb7232f05dc34e4454155e676b58c40fddf9a036562ac2c01533d2d557cb49d73aa9d7a89744696"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"0x01"
],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "5",
"tx": {
"from": "address:an_account",
"to": "sc:basic-features",
"function": "verify_bls_aggregated_signature",
"arguments": [
"0xb5823f6e564251cc03ce7bad3da83e72576e92795d3500bba1acb30ec9a94dce87bb8aa794d67b2d61d15c33f28f6c0c23ba1dfcbf21e8f8b46286ff871afabac925303ddcaddce6254fcff6d3155797db40b3d3b5865e8fc0bd770b3d79b381",
"0x6d65737361676520746f206265207369676e6564",
"0xaf32a2ddf341c08d1eb7232f05dc34e4454155e676b58c40fddf9a036562ac2c01533d2d557cb49d73aa9d7a89744696"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"0x01"
],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"name": "crypto",
"comment": "",
"gasSchedule": "v3",
"steps": [
{
"step": "setState",
"accounts": {
"sc:basic-features": {
"nonce": "0",
"balance": "0",
"code": "mxsc:../output/basic-features.mxsc.json"
},
"address:an_account": {
"nonce": "0",
"balance": "0"
}
}
},
{
"step": "scCall",
"id": "5 - compressed key",
"tx": {
"from": "address:an_account",
"to": "sc:basic-features",
"function": "verify_secp256r1_signature",
"arguments": [
"0x02a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5",
"0x6d65737361676520746f207369676e",
"0x3045022100fab29dbcb623e7e96f44665f312b89ffdb9e4d2e2f53353236fbbcf57b2f49bf02203d6f9c63df8be43121042970a549a2d3baeca093fd37b726ddcc0924638409f5"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"0x01"
],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "6 - uncompressed key",
"tx": {
"from": "address:an_account",
"to": "sc:basic-features",
"function": "verify_secp256r1_signature",
"arguments": [
"0x04a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5ca1d22fe57c6103dbaac10cf15d15c0791cab8bb9a04f800e4d215276cb3e008",
"0x6d65737361676520746f207369676e",
"0x3045022100fab29dbcb623e7e96f44665f312b89ffdb9e4d2e2f53353236fbbcf57b2f49bf02203d6f9c63df8be43121042970a549a2d3baeca093fd37b726ddcc0924638409f5"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"0x01"
],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "7 - encode key from r and s",
"tx": {
"from": "address:an_account",
"to": "sc:basic-features",
"function": "compute_secp256k1_der_signature",
"arguments": [
"0x90f27b8b488db00b00606796d2987f6a5f59ae62ea05effe84fef5b8b0e54998",
"0x4a691139ad57a3f0b906637673aa2f63d1f55cb1a69199d4009eea23ceaddc93"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"0x304502210090f27b8b488db00b00606796d2987f6a5f59ae62ea05effe84fef5b8b0e5499802204a691139ad57a3f0b906637673aa2f63d1f55cb1a69199d4009eea23ceaddc93"
],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "8 - verify custom secp256k1",
"tx": {
"from": "address:an_account",
"to": "sc:basic-features",
"function": "verify_custom_secp256k1_signature",
"arguments": [
"0x04e32df42865e97135acfb65f3bae71bdc86f4d49150ad6a440b6f15878109880a0a2b2667f7e725ceea70c673093bf67663e0312623c8e091b13cf2c0f11ef652",
"0xce0677bb30baa8cf067c88db9811f4333d131bf8bcf12fe7065d211dce971008",
"0x304502210090f27b8b488db00b00606796d2987f6a5f59ae62ea05effe84fef5b8b0e5499802204a691139ad57a3f0b906637673aa2f63d1f55cb1a69199d4009eea23ceaddc93",
"0"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"0x01"
],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
}
]
}
6 changes: 4 additions & 2 deletions contracts/feature-tests/basic-features/src/crypto_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ pub trait CryptoFeatures {
) -> bool {
self.crypto().verify_secp256r1(&key, &message, &signature)
}

#[endpoint]
fn verify_bls_signature_share_managed(
fn verify_bls_signature_share(
&self,
key: ManagedBuffer,
message: ManagedBuffer,
Expand All @@ -84,8 +85,9 @@ pub trait CryptoFeatures {
self.crypto()
.verify_bls_signature_share(&key, &message, &signature)
}

#[endpoint]
fn verify_bls_aggregated_signature_managed(
fn verify_bls_aggregated_signature(
&self,
key: ManagedBuffer,
message: ManagedBuffer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ fn crypto_verify_secp_256_k_1_go() {
world().run("scenarios/crypto_verify_secp256k1.scen.json");
}

#[test]
fn crypto_verify_secp_256_r_1_go() {
world().run("scenarios/crypto_verify_secp256r1.scen.json");
}

#[test]
fn echo_array_u_8_go() {
world().run("scenarios/echo_array_u8.scen.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ fn crypto_verify_secp_256_k_1_rs() {
world().run("scenarios/crypto_verify_secp256k1.scen.json");
}

#[test]
#[ignore]
fn crypto_verify_secp_256_r_1_rs() {
world().run("scenarios/crypto_verify_secp256r1.scen.json");
}

#[test]
fn echo_array_u_8_rs() {
world().run("scenarios/echo_array_u8.scen.json");
Expand Down
4 changes: 2 additions & 2 deletions contracts/feature-tests/basic-features/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ multiversx_sc_wasm_adapter::endpoints! {
verify_custom_secp256k1_signature => verify_custom_secp256k1_signature
compute_secp256k1_der_signature => compute_secp256k1_der_signature
verify_secp256r1_signature => verify_secp256r1_signature
verify_bls_signature_share_managed => verify_bls_signature_share_managed
verify_bls_aggregated_signature_managed => verify_bls_aggregated_signature_managed
verify_bls_signature_share => verify_bls_signature_share
verify_bls_aggregated_signature => verify_bls_aggregated_signature
echo_u64 => echo_u64
echo_i64 => echo_i64
echo_i32 => echo_i32
Expand Down

0 comments on commit 3fc082a

Please sign in to comment.