Skip to content

Commit f214b92

Browse files
authored
Merge pull request #1983 from CosmWasm/secp256r1-support
Secp256r1 support
2 parents 80ef9f7 + d1cb111 commit f214b92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+35758
-79
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ workflows:
8484
- main
8585
- /^[0-9]+\.[0-9]+$/
8686
# Add your branch here if benchmarking matters to your work
87-
- add-noop
87+
- secp256r1-support
8888
- coverage
8989
deploy:
9090
jobs:

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- cosmwasm-vm: Add `secp256r1_verify` and `secp256r1_recover_pubkey` imports for
12+
ECDSA signature verification over secp256r1. ([#1983])
13+
14+
[#1983]: https://github.com/CosmWasm/cosmwasm/pull/1983
15+
916
### Changed
1017

1118
- cosmwasm-std: Enable `add_event` and `add_events` functions to process types

Cargo.lock

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ extern "C" {
227227
recovery_param: u32,
228228
) -> u64;
229229

230+
/// Verifies message hashes against a signature with a public key, using the
231+
/// secp256r1 ECDSA parametrization.
232+
/// Returns 0 on verification success, 1 on verification failure, and values
233+
/// greater than 1 in case of error.
234+
fn secp256r1_verify(message_hash_ptr: u32, signature_ptr: u32, public_key_ptr: u32) -> u32;
235+
236+
fn secp256r1_recover_pubkey(
237+
message_hash_ptr: u32,
238+
signature_ptr: u32,
239+
recovery_param: u32,
240+
) -> u64;
241+
230242
/// Verifies a message against a signature with a public key, using the
231243
/// ed25519 EdDSA scheme.
232244
/// Returns 0 on verification success, 1 on verification failure, and values

contracts/burner/Cargo.lock

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/crypto-verify/Cargo.lock

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/crypto-verify/schema/crypto-verify.json

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,52 @@
5959
"additionalProperties": false
6060
},
6161
{
62-
"description": "Ethereum text verification (compatible to the eth_sign RPC/web3 enpoint). This cannot be used to verify transaction.\n\nSee https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#sign",
62+
"description": "Cosmos format (secp256r1 verification scheme).",
63+
"type": "object",
64+
"required": [
65+
"verify_secp256_r1_signature"
66+
],
67+
"properties": {
68+
"verify_secp256_r1_signature": {
69+
"type": "object",
70+
"required": [
71+
"message",
72+
"public_key",
73+
"signature"
74+
],
75+
"properties": {
76+
"message": {
77+
"description": "Message to verify.",
78+
"allOf": [
79+
{
80+
"$ref": "#/definitions/Binary"
81+
}
82+
]
83+
},
84+
"public_key": {
85+
"description": "Serialized compressed (33 bytes) or uncompressed (65 bytes) public key.",
86+
"allOf": [
87+
{
88+
"$ref": "#/definitions/Binary"
89+
}
90+
]
91+
},
92+
"signature": {
93+
"description": "Serialized signature. Cosmos format (64 bytes).",
94+
"allOf": [
95+
{
96+
"$ref": "#/definitions/Binary"
97+
}
98+
]
99+
}
100+
},
101+
"additionalProperties": false
102+
}
103+
},
104+
"additionalProperties": false
105+
},
106+
{
107+
"description": "Ethereum text verification (compatible to the eth_sign RPC/web3 endpoint). This cannot be used to verify transaction.\n\nSee https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#sign",
63108
"type": "object",
64109
"required": [
65110
"verify_ethereum_text"
@@ -86,7 +131,7 @@
86131
]
87132
},
88133
"signer_address": {
89-
"description": "Signer address. This is matched case insensitive, so you can provide checksummed and non-checksummed addresses. Checksums are not validated.",
134+
"description": "Signer address. This is matched case insensitive, so you can provide check-summed and non-check-summed addresses. Checksums are not validated.",
90135
"type": "string"
91136
}
92137
},
@@ -339,6 +384,20 @@
339384
},
340385
"additionalProperties": false
341386
},
387+
"verify_secp256_r1_signature": {
388+
"$schema": "http://json-schema.org/draft-07/schema#",
389+
"title": "VerifyResponse",
390+
"type": "object",
391+
"required": [
392+
"verifies"
393+
],
394+
"properties": {
395+
"verifies": {
396+
"type": "boolean"
397+
}
398+
},
399+
"additionalProperties": false
400+
},
342401
"verify_tendermint_batch": {
343402
"$schema": "http://json-schema.org/draft-07/schema#",
344403
"title": "VerifyResponse",

0 commit comments

Comments
 (0)