Skip to content

Commit

Permalink
Merge pull request #878 from multiversx/new-crypto-mandos
Browse files Browse the repository at this point in the history
Mandos tests for new crypto functions
  • Loading branch information
andrei-marinica authored Sep 2, 2024
2 parents da9374f + b2ca609 commit 2cbc542
Show file tree
Hide file tree
Showing 20 changed files with 1,949 additions and 104 deletions.
5 changes: 3 additions & 2 deletions crypto/signing/bls/bls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ func TestBls_VerifyBLSMultiSig(t *testing.T) {
for i := 0; i < len(setupKOSK.pubKeys); i++ {
fmt.Println(hex.EncodeToString(setupKOSK.pubKeys[i]))
}
fmt.Println(setupKOSK.messages[0])
fmt.Println(hex.EncodeToString(setupKOSK.aggSignatures[0]))

for i := 0; i < numMessages; i++ {
fmt.Println(setupKOSK.messages[i])
fmt.Println(hex.EncodeToString(setupKOSK.aggSignatures[i]))

assert.Nil(t, b.VerifyAggregatedSig(setupKOSK.pubKeys, []byte(setupKOSK.messages[i]), setupKOSK.aggSignatures[i]))
changedSig := make([]byte, len(setupKOSK.aggSignatures[i]))
copy(changedSig, setupKOSK.aggSignatures[i])
Expand Down
324 changes: 324 additions & 0 deletions test/features/basic-features/output/basic-features-crypto.mxsc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
{
"buildInfo": {
"rustc": {
"version": "1.80.1",
"commitHash": "3f5fd8dd41153bc5fdca9427e9e05be2c767ba23",
"commitDate": "2024-08-06",
"channel": "Stable",
"short": "rustc 1.80.1 (3f5fd8dd4 2024-08-06)"
},
"contractCrate": {
"name": "basic-features",
"version": "0.0.0"
},
"framework": {
"name": "multiversx-sc",
"version": "0.52.3"
}
},
"abi": {
"name": "BasicFeatures",
"constructor": {
"inputs": [],
"outputs": []
},
"endpoints": [
{
"name": "verify_secp256r1_signature",
"mutability": "mutable",
"inputs": [
{
"name": "key",
"type": "bytes"
},
{
"name": "message",
"type": "bytes"
},
{
"name": "signature",
"type": "bytes"
}
],
"outputs": [],
"labels": [
"crypto-ei-1.4"
]
},
{
"name": "verify_bls_signature_share",
"mutability": "mutable",
"inputs": [
{
"name": "key",
"type": "bytes"
},
{
"name": "message",
"type": "bytes"
},
{
"name": "signature",
"type": "bytes"
}
],
"outputs": [],
"labels": [
"crypto-ei-1.4"
]
},
{
"name": "verify_bls_aggregated_signature",
"mutability": "mutable",
"inputs": [
{
"name": "key",
"type": "List<bytes>"
},
{
"name": "message",
"type": "bytes"
},
{
"name": "signature",
"type": "bytes"
}
],
"outputs": [],
"labels": [
"crypto-ei-1.4"
]
}
],
"events": [
{
"identifier": "event_err_topic",
"inputs": [
{
"name": "err_topic",
"type": "CodecErrorTestType",
"indexed": true
}
]
},
{
"identifier": "event_err_data",
"inputs": [
{
"name": "data",
"type": "CodecErrorTestType"
}
]
},
{
"identifier": "event_a",
"inputs": [
{
"name": "data",
"type": "u32"
}
]
},
{
"identifier": "event_b",
"inputs": [
{
"name": "arg1",
"type": "BigUint",
"indexed": true
},
{
"name": "arg2",
"type": "Address",
"indexed": true
},
{
"name": "data",
"type": "List<bytes>"
}
]
}
],
"esdtAttributes": [],
"hasCallback": false,
"types": {
"CodecErrorTestType": {
"type": "struct",
"docs": [
"Helper type to explore encode/decode errors."
]
},
"EsdtTokenPayment": {
"type": "struct",
"fields": [
{
"name": "token_identifier",
"type": "TokenIdentifier"
},
{
"name": "token_nonce",
"type": "u64"
},
{
"name": "amount",
"type": "BigUint"
}
]
},
"ExampleEnumSimple": {
"type": "enum",
"docs": [
"Copied from multiversx-sc serialization tests."
],
"variants": [
{
"docs": [
"Variant 0 doc comment.",
"This will show up in the ABI."
],
"name": "Variant0",
"discriminant": 0
},
{
"name": "Variant1",
"discriminant": 1
},
{
"docs": [
"One line is enough. The one above doesn't have any."
],
"name": "Variant2",
"discriminant": 2
}
]
},
"ExampleEnumWithFields": {
"type": "enum",
"docs": [
"Copied from multiversx-sc serialization tests."
],
"variants": [
{
"name": "Unit",
"discriminant": 0
},
{
"name": "Newtype",
"discriminant": 1,
"fields": [
{
"name": "0",
"type": "u32"
}
]
},
{
"name": "Tuple",
"discriminant": 2,
"fields": [
{
"name": "0",
"type": "u32"
},
{
"name": "1",
"type": "u32"
}
]
},
{
"name": "Struct",
"discriminant": 3,
"fields": [
{
"name": "a",
"type": "u32"
}
]
}
]
},
"ExampleStructManaged": {
"type": "struct",
"fields": [
{
"name": "big_uint",
"type": "BigUint"
},
{
"name": "int",
"type": "u32"
},
{
"name": "bytes",
"type": "bytes"
}
]
},
"RgbColor": {
"type": "struct",
"fields": [
{
"name": "r",
"type": "u8"
},
{
"name": "g",
"type": "u8"
},
{
"name": "b",
"type": "u8"
}
]
},
"TokenAttributesStruct": {
"type": "struct",
"fields": [
{
"name": "field_biguint",
"type": "BigUint"
},
{
"name": "field_u64",
"type": "u64"
},
{
"name": "field_vec_u32",
"type": "List<u32>"
}
]
}
}
},
"code": "0061736d01000000012b0860000060037f7f7f017f6000017f60047f7f7f7f017f60017f0060017f017f60027f7f0060027f7f017f02e8020e03656e76126d427566666572417070656e644279746573000103656e76126d616e616765645369676e616c4572726f72000403656e760f6d4275666665725365744279746573000103656e76106d4275666665724765744c656e677468000503656e760a6d4275666665724e6577000203656e76146d427566666572436f707942797465536c696365000303656e760f6765744e756d417267756d656e7473000203656e760b7369676e616c4572726f72000603656e76136d42756666657247657442797465536c696365000303656e76126d427566666572476574417267756d656e74000703656e760e636865636b4e6f5061796d656e74000003656e76166d616e61676564566572696679536563703235367231000103656e761e6d616e61676564566572696679424c535369676e61747572655368617265000103656e76236d616e61676564566572696679424c53416767726567617465645369676e61747572650001030c0b000502030400000000000005030100030616037f01418080080b7f0041f0ce080b7f0041f0ce080b07930108066d656d6f7279020004696e697400131a7665726966795f7365637032353672315f7369676e617475726500141a7665726966795f626c735f7369676e61747572655f736861726500151f7665726966795f626c735f616767726567617465645f7369676e617475726500160863616c6c4261636b00170a5f5f646174615f656e6403010b5f5f686561705f6261736503020ad7040b3701017f1010220041808008411710021a200041c28008410310001a200041978008410310001a200041b38008410f10001a20001001000b0d0020001010220010091a20000b1901017f41d4800841d4800828020041016b220036020020000b0f00200020012003200210084100470b1400100620004604400f0b419a800841191007000b0800100a410010120b1700100a410310124100100f4101100f4102100f100b1a0b1700100a410310124100100f4101100f4102100f100c1a0b870301087f100a41031012027f230041106b220224004100100f2103101022064101410010021a2003100321070240024002400340200020074604402001044041e8ce08410036020041ecce0841003a00000b200241106a240020060c050b2002410036020c0240027f0240024020014504402003100322014190ce004b0d0141ecce082d00000d0141e8ce08200136020041ecce0841013a00002003410041d88008200110111a0b200041046a220441e8ce082802004d0d010c070b200320002002410c6a2205410410110d06200041046a21044100210120050c010b2000417b4b0d0120044190ce004b0d0341012101200041d880086a0b2100200320042000280000220041187420004180fe03714108747220004108764180fe03712000411876727222051004220010050d032002200041187420004180fe03714108747220004108764180fe0371200041187672723602082006200241086a410410001a200420056a21000c010b0b1018000b1018000b100e000b100e000b4101100f4102100f100d1a0b02000b0b0041c58008410e1007000b0b660200418080080b53617267756d656e74206465636f6465206572726f722028293a2077726f6e67206e756d626572206f6620617267756d656e7473696e70757420746f6f2073686f72746b657970616e6963206f636375727265640041d480080b0438ffffff",
"report": {
"imports": [
"checkNoPayment",
"getNumArguments",
"mBufferAppendBytes",
"mBufferCopyByteSlice",
"mBufferGetArgument",
"mBufferGetByteSlice",
"mBufferGetLength",
"mBufferNew",
"mBufferSetBytes",
"managedSignalError",
"managedVerifyBLSAggregatedSignature",
"managedVerifyBLSSignatureShare",
"managedVerifySecp256r1",
"signalError"
],
"isMemGrow": false,
"eiCheck": {
"eiVersion": "1.4",
"ok": true
},
"codeReport": {
"path": "../output/basic-features-crypto.wasm",
"size": 1315,
"hasAllocator": false,
"hasPanic": "without message"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"buildInfo": {
"rustc": {
"version": "1.76.0-nightly",
"commitHash": "d86d65bbc19b928387f68427fcc3a0da498d8a19",
"commitDate": "2023-12-10",
"channel": "Nightly",
"short": "rustc 1.76.0-nightly (d86d65bbc 2023-12-10)"
"version": "1.80.1",
"commitHash": "3f5fd8dd41153bc5fdca9427e9e05be2c767ba23",
"commitDate": "2024-08-06",
"channel": "Stable",
"short": "rustc 1.80.1 (3f5fd8dd4 2024-08-06)"
},
"contractCrate": {
"name": "basic-features",
"version": "0.0.0"
},
"framework": {
"name": "multiversx-sc",
"version": "0.47.1"
"version": "0.52.3"
}
},
"abi": {
Expand Down Expand Up @@ -246,6 +246,28 @@
}
}
},
"size": 539,
"code": "0061736d0100000001230760000060027f7f017f6000017f60027f7f0060037f7f7f017f60017f017f60017f0002b4010803656e76126d427566666572476574417267756d656e74000103656e760f6765744e756d417267756d656e7473000203656e760b7369676e616c4572726f72000303656e760f6d4275666665725365744279746573000403656e760e636865636b4e6f5061796d656e74000003656e76126d42756666657253746f726167654c6f6164000103656e760d6d42756666657246696e697368000503656e76136d42756666657253746f7261676553746f72650001030807020602000000000503010003060f027f0041ac80080b7f0041b080080b075207066d656d6f7279020004696e6974000b0a6c6f61645f6279746573000c0b73746f72655f6279746573000d0863616c6c4261636b000e0a5f5f646174615f656e6403000b5f5f686561705f6261736503010a8501071901017f41a8800841a8800828020041016b220036020020000b1400100120004604400f0b4180800841191002000b1301017f1008220041998008410d10031a20000b08001004410010090b1801017f100441001009100a1008220010051a200010061a0b1a01017f10044101100941001008220010001a100a200010071a0b0300010b0b390200418080080b2677726f6e67206e756d626572206f6620617267756d656e747373746f726167655f62797465730041a880080b049cffffff"
"code": "0061736d0100000001230760000060027f7f017f6000017f60027f7f0060037f7f7f017f60017f017f60017f0002b4010803656e76126d427566666572476574417267756d656e74000103656e760f6765744e756d417267756d656e7473000203656e760b7369676e616c4572726f72000303656e760f6d4275666665725365744279746573000403656e760e636865636b4e6f5061796d656e74000003656e76126d42756666657253746f726167654c6f6164000103656e760d6d42756666657246696e697368000503656e76136d42756666657253746f7261676553746f72650001030807020602000000000503010003060f027f0041ac80080b7f0041b080080b075207066d656d6f7279020004696e6974000b0a6c6f61645f6279746573000c0b73746f72655f6279746573000d0863616c6c4261636b000e0a5f5f646174615f656e6403000b5f5f686561705f6261736503010a8401071901017f41a8800841a8800828020041016b220036020020000b1400100120004604400f0b4180800841191002000b1301017f1008220041998008410d10031a20000b08001004410010090b1801017f100441001009100a1008220010051a200010061a0b1a01017f10044101100941001008220010001a100a200010071a0b02000b0b390200418080080b2677726f6e67206e756d626572206f6620617267756d656e747373746f726167655f62797465730041a880080b0438ffffff",
"report": {
"imports": [
"checkNoPayment",
"getNumArguments",
"mBufferFinish",
"mBufferGetArgument",
"mBufferSetBytes",
"mBufferStorageLoad",
"mBufferStorageStore",
"signalError"
],
"isMemGrow": false,
"eiCheck": {
"eiVersion": "1.3",
"ok": true
},
"codeReport": {
"path": "../output/basic-features-storage-bytes.wasm",
"size": 538,
"hasAllocator": false,
"hasPanic": "none"
}
}
}
Loading

0 comments on commit 2cbc542

Please sign in to comment.