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::{
23	pass_by::{PassFatPointerAndRead, PassPointerAndRead},
24	runtime_interface,
25};
26
27#[runtime_interface]
28trait Crypto {
29	fn ecdsa_verify(
30		_sig: PassPointerAndRead<&ecdsa::Signature, 65>,
31		_msg: PassFatPointerAndRead<&[u8]>,
32		_pub_key: PassPointerAndRead<&ecdsa::Public, 33>,
33	) -> bool {
34		true
35	}
36
37	#[version(2)]
38	fn ecdsa_verify(
39		_sig: PassPointerAndRead<&ecdsa::Signature, 65>,
40		_msg: PassFatPointerAndRead<&[u8]>,
41		_pub_key: PassPointerAndRead<&ecdsa::Public, 33>,
42	) -> bool {
43		true
44	}
45
46	fn ed25519_verify(
47		_sig: PassPointerAndRead<&ed25519::Signature, 64>,
48		_msg: PassFatPointerAndRead<&[u8]>,
49		_pub_key: PassPointerAndRead<&ed25519::Public, 32>,
50	) -> bool {
51		true
52	}
53
54	fn sr25519_verify(
55		_sig: PassPointerAndRead<&sr25519::Signature, 64>,
56		_msg: PassFatPointerAndRead<&[u8]>,
57		_pub_key: PassPointerAndRead<&sr25519::Public, 32>,
58	) -> bool {
59		true
60	}
61
62	#[version(2)]
63	fn sr25519_verify(
64		_sig: PassPointerAndRead<&sr25519::Signature, 64>,
65		_msg: PassFatPointerAndRead<&[u8]>,
66		_pub_key: PassPointerAndRead<&sr25519::Public, 32>,
67	) -> bool {
68		true
69	}
70}
71
72/// Provides host functions that overrides runtime signature verification
73/// to always return true.
74pub type SignatureVerificationOverride = crypto::HostFunctions;
75
76// This is here to get rid of the warnings.
77#[allow(unused_imports, dead_code)]
78use self::crypto::{ecdsa_verify, ed25519_verify, sr25519_verify};