-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add secp256r1 sig verify, split crypto interface into "safe" (using `…
…Hash` type) and "hazmat"
- Loading branch information
Showing
8 changed files
with
210 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use crate::{bytesn, crypto::Hash, Env}; | ||
|
||
#[test] | ||
fn test_verify_sig_ecdsa_secp256r1() { | ||
let env = Env::default(); | ||
|
||
// Test vector copied and adapted from | ||
// https://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3ecdsatestvectors.zip | ||
// `SigVer.rsp` section [P-256,SHA-256] | ||
let message_digest = Hash::from_bytes(bytesn!( | ||
&env, | ||
0xd1b8ef21eb4182ee270638061063a3f3c16c114e33937f69fb232cc833965a94 | ||
)); | ||
let signature = bytesn!( | ||
&env, | ||
0xbf96b99aa49c705c910be33142017c642ff540c76349b9dab72f981fd9347f4f17c55095819089c2e03b9cd415abdf12444e323075d98f31920b9e0f57ec871c | ||
); | ||
let public_key = bytesn!( | ||
&env, | ||
0x04e424dc61d4bb3cb7ef4344a7f8957a0c5134e16f7a67c074f82e6e12f49abf3c970eed7aa2bc48651545949de1dddaf0127e5965ac85d1243d6f60e7dfaee927 | ||
); | ||
|
||
env.crypto() | ||
.secp256r1_verify(&public_key, &message_digest, &signature) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
soroban-sdk/test_snapshots/tests/crypto_secp256r1/test_verify_sig_ecdsa_secp256r1.1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"generators": { | ||
"address": 0, | ||
"nonce": 0 | ||
}, | ||
"auth": [], | ||
"ledger": { | ||
"protocol_version": 21, | ||
"sequence_number": 0, | ||
"timestamp": 0, | ||
"network_id": "0000000000000000000000000000000000000000000000000000000000000000", | ||
"base_reserve": 0, | ||
"min_persistent_entry_ttl": 4096, | ||
"min_temp_entry_ttl": 16, | ||
"max_entry_ttl": 6312000, | ||
"ledger_entries": [] | ||
}, | ||
"events": [ | ||
{ | ||
"event": { | ||
"ext": "v0", | ||
"contract_id": null, | ||
"type_": "diagnostic", | ||
"body": { | ||
"v0": { | ||
"topics": [ | ||
{ | ||
"symbol": "error" | ||
}, | ||
{ | ||
"error": { | ||
"context": "index_bounds" | ||
} | ||
} | ||
], | ||
"data": { | ||
"vec": [ | ||
{ | ||
"string": "ledger protocol {} is less than specified lower bound {}" | ||
}, | ||
{ | ||
"u32": 20 | ||
}, | ||
{ | ||
"u32": 21 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"failed_call": false | ||
}, | ||
{ | ||
"event": { | ||
"ext": "v0", | ||
"contract_id": null, | ||
"type_": "diagnostic", | ||
"body": { | ||
"v0": { | ||
"topics": [ | ||
{ | ||
"symbol": "error" | ||
}, | ||
{ | ||
"error": { | ||
"context": "index_bounds" | ||
} | ||
} | ||
], | ||
"data": { | ||
"string": "escalating error to panic" | ||
} | ||
} | ||
} | ||
}, | ||
"failed_call": false | ||
} | ||
] | ||
} |