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>;
// Provided methods
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 = MultiSignature: From<sr25519::Signature>;
Required Associated Types§
Sourcetype RuntimeAppPublic: RuntimeAppPublic
type RuntimeAppPublic: RuntimeAppPublic
A application-specific crypto.
Sourcetype GenericPublic: From<Self::RuntimeAppPublic> + Into<Self::RuntimeAppPublic> + TryFrom<Public> + Into<Public>
type GenericPublic: From<Self::RuntimeAppPublic> + Into<Self::RuntimeAppPublic> + TryFrom<Public> + Into<Public>
A raw crypto public key wrapped by RuntimeAppPublic
.
Sourcetype GenericSignature: From<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature> + Into<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature> + TryFrom<Signature> + Into<Signature>
type GenericSignature: From<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature> + Into<<Self::RuntimeAppPublic as RuntimeAppPublic>::Signature> + TryFrom<Signature> + Into<Signature>
A matching raw crypto Signature
type.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.