[offchain] Support for sign & verify for crypto keys (#3023)

* Implement sign & verify.

* Use phrases and password.

* Sign & verify with authority keys.

* Fix tests.

* WiP

* WiP

* Allow the caller to decide on 'CryptoKind'.

* Remove TODO.

* Make seed private back.

* Fix non-std build and bump version.

* Use Into<u32> instead of asses.

* Add missing typedef.
This commit is contained in:
Tomasz Drwięga
2019-07-09 17:09:14 +02:00
committed by Gavin Wood
parent ed630e5eda
commit e729dbabbe
22 changed files with 647 additions and 178 deletions
+9 -1
View File
@@ -250,6 +250,7 @@ impl offchain::Externalities for NeverOffchainExt {
fn encrypt(
&mut self,
_key: Option<offchain::CryptoKeyId>,
_kind: offchain::CryptoKind,
_data: &[u8],
) -> Result<Vec<u8>, ()> {
unreachable!()
@@ -258,18 +259,25 @@ impl offchain::Externalities for NeverOffchainExt {
fn decrypt(
&mut self,
_key: Option<offchain::CryptoKeyId>,
_kind: offchain::CryptoKind,
_data: &[u8],
) -> Result<Vec<u8>, ()> {
unreachable!()
}
fn sign(&mut self, _key: Option<offchain::CryptoKeyId>, _data: &[u8]) -> Result<Vec<u8>, ()> {
fn sign(
&mut self,
_key: Option<offchain::CryptoKeyId>,
_kind: offchain::CryptoKind,
_data: &[u8],
) -> Result<Vec<u8>, ()> {
unreachable!()
}
fn verify(
&mut self,
_key: Option<offchain::CryptoKeyId>,
_kind: offchain::CryptoKind,
_msg: &[u8],
_signature: &[u8],
) -> Result<bool, ()> {