Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:paritytech/substrate into a-fix-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar committed Nov 10, 2019
2 parents 7e1ec28 + a86bb37 commit f28e192
Show file tree
Hide file tree
Showing 118 changed files with 4,860 additions and 2,788 deletions.
95 changes: 80 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ members = [
"core/rpc",
"core/rpc/primitives",
"core/rpc-servers",
"core/runtime-interface",
"core/runtime-interface/proc-macro",
"core/runtime-interface/test-wasm",
"core/serializer",
"core/service",
"core/service/test",
Expand Down
15 changes: 8 additions & 7 deletions core/application-crypto/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

use crate::{RuntimePublic, KeyTypeId};

use rstd::vec::Vec;

pub use primitives::ed25519::*;

mod app {
Expand All @@ -29,28 +31,27 @@ mod app {
}
}

pub use app::Public as AppPublic;
pub use app::Signature as AppSignature;
pub use app::{Public as AppPublic, Signature as AppSignature};
#[cfg(feature = "full_crypto")]
pub use app::Pair as AppPair;

impl RuntimePublic for Public {
type Signature = Signature;

fn all(key_type: KeyTypeId) -> crate::Vec<Self> {
runtime_io::ed25519_public_keys(key_type)
runtime_io::crypto::ed25519_public_keys(key_type)
}

fn generate_pair(key_type: KeyTypeId, seed: Option<&str>) -> Self {
runtime_io::ed25519_generate(key_type, seed)
fn generate_pair(key_type: KeyTypeId, seed: Option<Vec<u8>>) -> Self {
runtime_io::crypto::ed25519_generate(key_type, seed)
}

fn sign<M: AsRef<[u8]>>(&self, key_type: KeyTypeId, msg: &M) -> Option<Self::Signature> {
runtime_io::ed25519_sign(key_type, self, msg.as_ref())
runtime_io::crypto::ed25519_sign(key_type, self, msg.as_ref())
}

fn verify<M: AsRef<[u8]>>(&self, msg: &M, signature: &Self::Signature) -> bool {
runtime_io::ed25519_verify(&signature, msg.as_ref(), self)
runtime_io::crypto::ed25519_verify(&signature, msg.as_ref(), self)
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/application-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ macro_rules! app_crypto_public_common {
<$public as $crate::RuntimePublic>::all($key_type).into_iter().map(Self).collect()
}

fn generate_pair(seed: Option<&str>) -> Self {
fn generate_pair(seed: Option<$crate::Vec<u8>>) -> Self {
Self(<$public as $crate::RuntimePublic>::generate_pair($key_type, seed))
}

Expand Down
15 changes: 8 additions & 7 deletions core/application-crypto/src/sr25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

use crate::{RuntimePublic, KeyTypeId};

use rstd::vec::Vec;

pub use primitives::sr25519::*;

mod app {
Expand All @@ -29,28 +31,27 @@ mod app {
}
}

pub use app::Public as AppPublic;
pub use app::Signature as AppSignature;
pub use app::{Public as AppPublic, Signature as AppSignature};
#[cfg(feature = "full_crypto")]
pub use app::Pair as AppPair;

impl RuntimePublic for Public {
type Signature = Signature;

fn all(key_type: KeyTypeId) -> crate::Vec<Self> {
runtime_io::sr25519_public_keys(key_type)
runtime_io::crypto::sr25519_public_keys(key_type)
}

fn generate_pair(key_type: KeyTypeId, seed: Option<&str>) -> Self {
runtime_io::sr25519_generate(key_type, seed)
fn generate_pair(key_type: KeyTypeId, seed: Option<Vec<u8>>) -> Self {
runtime_io::crypto::sr25519_generate(key_type, seed)
}

fn sign<M: AsRef<[u8]>>(&self, key_type: KeyTypeId, msg: &M) -> Option<Self::Signature> {
runtime_io::sr25519_sign(key_type, self, msg.as_ref())
runtime_io::crypto::sr25519_sign(key_type, self, msg.as_ref())
}

fn verify<M: AsRef<[u8]>>(&self, msg: &M, signature: &Self::Signature) -> bool {
runtime_io::sr25519_verify(&signature, msg.as_ref(), self)
runtime_io::crypto::sr25519_verify(&signature, msg.as_ref(), self)
}
}

Expand Down
Loading

0 comments on commit f28e192

Please sign in to comment.