Trait frame_system::offchain::AppCrypto [−][src]
A type binding runtime-level Public/Signature
pair with crypto wrapped by RuntimeAppPublic
.
Implementations of this trait should specify the app-specific public/signature types.
This is merely a wrapper around an existing RuntimeAppPublic
type, but with
extra non-application-specific crypto type that is being wrapped (e.g. sr25519
, ed25519
).
This is needed to later on convert into runtime-specific Public
key, which might support
multiple different crypto.
The point of this trait is to be able to easily convert between RuntimeAppPublic
, the wrapped
(generic = non application-specific) crypto types and the Public
type required by the runtime.
TODO [#5662] Potentially use IsWrappedBy
types, or find some other way to make it easy to
obtain unwrapped crypto (and wrap it back).
Example (pseudo-)implementation:
// im-online specific crypto type RuntimeAppPublic = ImOnline(sr25519::Public); // wrapped "raw" crypto type GenericPublic = sr25519::Public; type GenericSignature = sr25519::Signature; // runtime-specific public key type Public = MultiSigner: From<sr25519::Public>; type Signature = MulitSignature: From<sr25519::Signature>;
Associated Types
type RuntimeAppPublic: RuntimeAppPublic
[src]
A application-specific crypto.
type GenericPublic: From<Self::RuntimeAppPublic> + Into<Self::RuntimeAppPublic> + TryFrom<Public> + Into<Public>
[src]
A raw crypto public key wrapped by RuntimeAppPublic
.
type GenericSignature: From<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature> + Into<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature> + TryFrom<Signature> + Into<Signature>
[src]
A matching raw crypto Signature
type.
Provided methods
fn sign(payload: &[u8], public: Public) -> Option<Signature>
[src]
Sign payload with the private key to maps to the provided public key.
fn verify(payload: &[u8], public: Public, signature: Signature) -> bool
[src]
Verify signature against the provided public key.