-
Notifications
You must be signed in to change notification settings - Fork 2.6k
contracts: add sr25519_verify #13724
contracts: add sr25519_verify #13724
Conversation
485f0aa
to
83c8198
Compare
bot bench $ pallet dev pallet_contracts |
@pgherveou https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2614559 was started for your command Comment |
@athei quick questions, before I take a second pass at this:
/// Ext defines a generic
fn sig_verify(&self, payload: SigVerifierPayload) -> bool;
// each variant define the message, signature, and public key with the appropriate types
pub enum SigVerifierPayload {
Sr25519 { ... },
Ed25519 { ... },
Ecdsa { ... },
} vs what I started the other day fn sr25519_verify(&self, signature: &[u8; 64], message: &[u8], pub_key: &[u8; 32]) -> bool; and in this option here I am not sure if we want the message to be a fixed sized hash or just plain &[u8] as defined here |
@pgherveou Command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we implement a generic verify function as demonstrated here
https://github.com/AstarNetwork/astar-frame/pull/141/files#diff-16c73d79bacd21e8243b65478b218afa791cb812008c4f8055a549d03cd4862a
I would say we opt for individual host functions. We don't have precedence for multiplexed functions. Reason is that it makes benchmarking harder when we multiplex: The weight will depend on the argument which decides which algorithm to depley. Hence this PR should a function for sr25519 and one for ed25519.
Not too sure what are the exact use cases here, but do we want the message payload to be hashed so it's constant size or
should it just be an arbitrary payload
The message will be an arbitrary payload as demonstrated in this PR. Reason is that this is what the functions in sp_io::crypto
expect. Weight needs to be linear over its length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only nitpicks
Co-authored-by: Sasha Gryaznov <[email protected]>
Co-authored-by: Sasha Gryaznov <[email protected]>
Co-authored-by: Sasha Gryaznov <[email protected]>
bot merge |
Waiting for commit status. |
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/april-updates-for-substrate-and-polkadot-devs/2764/1 |
* wip * fix * wip * fix lint * rm fixture fix * missing comment * fix lint * add comment to the wsm file * fix comment * Apply suggestions from code review Co-authored-by: Sasha Gryaznov <[email protected]> * wip * wip weights * wip weights * PR comment: test with return code * wip * PR review add mock test * remove * lint * Update frame/contracts/fixtures/sr25519_verify.wat * fix comments * Update frame/contracts/src/benchmarking/mod.rs * Update frame/contracts/src/wasm/runtime.rs * Update frame/contracts/fixtures/sr25519_verify.wat * Update frame/contracts/src/benchmarking/mod.rs * fix lint * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * Update frame/contracts/src/wasm/runtime.rs Co-authored-by: Alexander Theißen <[email protected]> * PR: review use unstable + remove arbitrary index 4 * Add benchmark for calculating overhead of calling sr25519_verify * fix message length encoding * fix weights * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * Apply suggestions from code review * Update frame/contracts/src/wasm/runtime.rs * Update frame/contracts/src/wasm/runtime.rs * Update frame/contracts/src/benchmarking/mod.rs * Update frame/contracts/src/benchmarking/mod.rs * Update frame/contracts/src/schedule.rs Co-authored-by: Sasha Gryaznov <[email protected]> * Update frame/contracts/src/schedule.rs Co-authored-by: Sasha Gryaznov <[email protected]> * Update frame/contracts/src/wasm/runtime.rs * Update frame/contracts/src/wasm/runtime.rs Co-authored-by: Sasha Gryaznov <[email protected]> * PR review --------- Co-authored-by: Sasha Gryaznov <[email protected]> Co-authored-by: command-bot <> Co-authored-by: Alexander Theißen <[email protected]>
fix #13703