sc_simnode/
overrides.rs

1// Copyright (C) 2023 Polytope Labs (Caymans) Ltd.
2// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
3
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17//! Host function overrides for signature verification.
18
19use polkadot_sdk::*;
20
21use sp_core::{ecdsa, ed25519, sr25519};
22use sp_runtime_interface::runtime_interface;
23
24#[runtime_interface]
25trait Crypto {
26	fn ecdsa_verify(_sig: &ecdsa::Signature, _msg: &[u8], _pub_key: &ecdsa::Public) -> bool {
27		true
28	}
29
30	#[version(2)]
31	fn ecdsa_verify(_sig: &ecdsa::Signature, _msg: &[u8], _pub_key: &ecdsa::Public) -> bool {
32		true
33	}
34
35	fn ed25519_verify(_sig: &ed25519::Signature, _msg: &[u8], _pub_key: &ed25519::Public) -> bool {
36		true
37	}
38
39	fn sr25519_verify(_sig: &sr25519::Signature, _msg: &[u8], _pub_key: &sr25519::Public) -> bool {
40		true
41	}
42
43	#[version(2)]
44	fn sr25519_verify(_sig: &sr25519::Signature, _msg: &[u8], _pub_key: &sr25519::Public) -> bool {
45		true
46	}
47}
48
49/// Provides host functions that overrides runtime signature verification
50/// to always return true.
51pub type SignatureVerificationOverride = crypto::HostFunctions;
52
53// This is here to get rid of the warnings.
54#[allow(unused_imports, dead_code)]
55use self::crypto::{ecdsa_verify, ed25519_verify, sr25519_verify};