Trait frame_system::offchain::AppCrypto[][src]

pub trait AppCrypto<Public, Signature> {
    type RuntimeAppPublic: RuntimeAppPublic;
    type GenericPublic: From<Self::RuntimeAppPublic> + Into<Self::RuntimeAppPublic> + TryFrom<Public> + Into<Public>;
    type GenericSignature: From<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature> + Into<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature> + TryFrom<Signature> + Into<Signature>;
    fn sign(payload: &[u8], public: Public) -> Option<Signature> { ... }
fn verify(payload: &[u8], public: Public, signature: Signature) -> bool { ... } }
Expand description

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.

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

A application-specific crypto.

A raw crypto public key wrapped by RuntimeAppPublic.

A matching raw crypto Signature type.

Provided methods

Sign payload with the private key to maps to the provided public key.

Verify signature against the provided public key.

Implementors