-
Notifications
You must be signed in to change notification settings - Fork 683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application Crypto and BEEFY Support for paired (ECDSA,BLS) crypto #1815
Merged
Lederstrumpf
merged 32 commits into
paritytech:master
from
w3f:skalman--paired-ecdsa-bls-support-for-beefy-primitives
Oct 24, 2023
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
5d3dce1
First definition for pair public keys
drskalman be890d4
Two example of implementation of pair for demonestration
drskalman fb6a018
- implement paired crypto `Public` as tuple of two `Public`s - unsuce…
drskalman 62ef8b1
keep both public key object and their continous serialization in pair…
drskalman 8d4e523
implement PassBy and From<Pair> for paired_crypto
drskalman eea74e2
implement rest of aux traits for `paired_crypto::Public` implement so…
drskalman f407d87
Attempt to implement trait `Pair` for `pair_cyrpto::Pair`
drskalman 2606cc4
- Implement trait `Pair` for `paired_crypto::Pair` - Implement a pair…
drskalman 00933da
implement sgin and verify for
drskalman e7719ab
Actually implementing `paired_crypto::{Pair, Public, Signatrue}` for …
drskalman 7a9b677
Implement and pass all test for `paired_crypto`
drskalman a01a814
- move to signle seed for both schemes in `primitives/core/src/paired…
drskalman 7c02658
replace `hex!` → `array_bytes::hex2xx`
drskalman 7f8d958
Apply suggestions from `paired_crypto` code review on type nam, hash …
drskalman eef2cec
Do not panic in `paired::Signature::try_from`
drskalman efb215f
Remove `DoublePair` trait.
drskalman 65584bd
Do not empty implement `paired::Pair`
drskalman e047f75
Use `paired_crypto::Seed` instead of `[u8; SECURE_SEED_LEN]`
drskalman c12b82e
use `ecdsa::PUBLIC_KEY_SERIALIZED_SIZE` and `ecdsa::SIGNATURE_SERIALI…
drskalman dba854a
Remove `paired::DoublePair` impl as well
drskalman 5182c86
- Implement `BytesArray` for both ecdsa and bls Signatures
drskalman 17d0077
Implement encode_and_decode_(public_key/signature)_works test for pai…
drskalman a740589
cargo fmt
drskalman 79f25e9
- Implement RuntimeAppCrypto and necessery hostApi for ecdsa_bls377 c…
drskalman 067dece
cargo fmt
drskalman 3cf7594
Merge branch 'master' into skalman--paired-ecdsa-bls-support-for-beef…
drskalman 652990e
`cargo fmt`
drskalman 388ed14
Nitpicks
davxy 9f07bd5
implement ecdsa_bls377 `Keystore` functions for `LocalKeystore`.
drskalman fdd1bdf
nitpick tuple consistency
Lederstrumpf 305a003
reuse `Ord` impl for `PartialOrd` impl of `Public`
Lederstrumpf 3a8c46e
Merge branch 'master' into skalman--paired-ecdsa-bls-support-for-beef…
Lederstrumpf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
substrate/primitives/application-crypto/src/ecdsa_bls377.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//! ECDSA and BLS12-377 paired crypto applications. | ||
|
||
use crate::{KeyTypeId, RuntimePublic}; | ||
|
||
pub use sp_core::paired_crypto::ecdsa_bls377::*; | ||
|
||
mod app { | ||
crate::app_crypto!(super, sp_core::testing::ECDSA_BLS377); | ||
} | ||
|
||
#[cfg(feature = "full_crypto")] | ||
pub use app::Pair as AppPair; | ||
pub use app::{Public as AppPublic, Signature as AppSignature}; | ||
|
||
impl RuntimePublic for Public { | ||
type Signature = Signature; | ||
|
||
/// Dummy implementation. Returns an empty vector. | ||
fn all(_key_type: KeyTypeId) -> Vec<Self> { | ||
Vec::new() | ||
} | ||
|
||
fn generate_pair(key_type: KeyTypeId, seed: Option<Vec<u8>>) -> Self { | ||
sp_io::crypto::ecdsa_bls377_generate(key_type, seed) | ||
} | ||
|
||
/// Dummy implementation. Returns `None`. | ||
fn sign<M: AsRef<[u8]>>(&self, _key_type: KeyTypeId, _msg: &M) -> Option<Self::Signature> { | ||
None | ||
} | ||
|
||
/// Dummy implementation. Returns `false`. | ||
fn verify<M: AsRef<[u8]>>(&self, _msg: &M, _signature: &Self::Signature) -> bool { | ||
false | ||
} | ||
|
||
fn to_raw_vec(&self) -> Vec<u8> { | ||
sp_core::crypto::ByteArray::to_raw_vec(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why here you've not specified BLS12-377?
This will be changed to use 381?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly.
The BLS in the BLS12 curves and BLS in the signature are not the same thing though. (I think only the L in the BLS signature and in the BLS12 curves are the same person). You could do BLS signature with any other BLS friendly curves such as BN or BLS24. Here I just wanted to say that we are generating a BLS type signature without going into the technicality of which curve we are using under the hood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But here we are not defining types which are bounded by a generic pairing fiendly curve to produce BLS signatures. Here we are using a specific curve (which at the moment is bls12-377). And the same applies to
bls_crypto
module.So maybe the question now is: is intentional to not be explicit about the curve in the modules names?
I'm not saying that this is not the right choice. I'm just curious