Skip to content

Commit 4060b2c

Browse files
authored
Merge pull request #2058 from CosmWasm/unimplemented-api
Add default implementations for secp256r1_verify/secp256r1_recover_pubkey
2 parents 5aad41e + a28d679 commit 4060b2c

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ and this project adheres to
99
### Added
1010

1111
- cosmwasm-vm: Add `secp256r1_verify` and `secp256r1_recover_pubkey` imports for
12-
ECDSA signature verification over secp256r1. ([#1983], [#2057])
12+
ECDSA signature verification over secp256r1. ([#1983], [#2057], [#2058])
1313

1414
[#1983]: https://github.com/CosmWasm/cosmwasm/pull/1983
1515
[#2057]: https://github.com/CosmWasm/cosmwasm/pull/2057
16+
[#2058]: https://github.com/CosmWasm/cosmwasm/pull/2058
1617

1718
### Changed
1819

packages/std/src/traits.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,33 @@ pub trait Api {
165165
recovery_param: u8,
166166
) -> Result<Vec<u8>, RecoverPubkeyError>;
167167

168+
#[allow(unused_variables)]
168169
fn secp256r1_verify(
169170
&self,
170171
message_hash: &[u8],
171172
signature: &[u8],
172173
public_key: &[u8],
173-
) -> Result<bool, VerificationError>;
174+
) -> Result<bool, VerificationError> {
175+
// Support for secp256r1 is added in 2.1, i.e. we can't add a compile time requirement for new function.
176+
// Any implementation of the Api trait which does not implement this function but tries to call it will
177+
// panic at runtime. We don't assume such cases exist.
178+
// See also https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-default-item
179+
unimplemented!()
180+
}
174181

182+
#[allow(unused_variables)]
175183
fn secp256r1_recover_pubkey(
176184
&self,
177185
message_hash: &[u8],
178186
signature: &[u8],
179187
recovery_param: u8,
180-
) -> Result<Vec<u8>, RecoverPubkeyError>;
188+
) -> Result<Vec<u8>, RecoverPubkeyError> {
189+
// Support for secp256r1 was added in 2.1, i.e. we can't add a compile time requirement for new function.
190+
// Any implementation of the Api trait which does not implement this function but tries to call it will
191+
// panic at runtime. We don't assume such cases exist.
192+
// See also https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-default-item
193+
unimplemented!()
194+
}
181195

182196
fn ed25519_verify(
183197
&self,

0 commit comments

Comments
 (0)