mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 19:02:42 +00:00
* Add basic block processing benches * Start reviving state processing benches * Fix old block builders * Add optimization for faster pubkey add * Tidy benches, add another * Add extra block processing bench * Start working on faster BLS scheme * Add partially complete sig verify optimization * Add .gitignore to state processing * Add progress on faster signature verification * Fix SignatureSet for fake_crypto * Tidy attester slashings sig set * Tidy bulk signature verifier * Refactor signature sets to be cleaner * Start threading SignatureStrategy through code * Add (empty) test dir * Move BenchingBlockBuilder * Add initial block signature verification tests * Add tests for bulk signature verification * Start threading SignatureStrategy in block proc. * Refactor per_block_processing errors * Use sig set tuples instead of lists of two * Remove dead code * Thread VerifySignatures through per_block_processing * Add bulk signature verification * Introduce parallel bulk signature verification * Expand state processing benches * Fix additional compile errors * Fix issue where par iter chunks is 0 * Update milagro_bls dep * Remove debugs, code fragment in beacon chain * Tidy, add comments to block sig verifier * Fix various PR comments * Add block_root option to per_block_processing * Fix comment in block signature verifier * Fix comments from PR review * Remove old comment * Fix comment
82 lines
2.3 KiB
Rust
82 lines
2.3 KiB
Rust
extern crate milagro_bls;
|
|
extern crate ssz;
|
|
|
|
#[macro_use]
|
|
mod macros;
|
|
mod keypair;
|
|
mod public_key_bytes;
|
|
mod secret_key;
|
|
mod signature_bytes;
|
|
mod signature_set;
|
|
|
|
pub use crate::keypair::Keypair;
|
|
pub use crate::public_key_bytes::PublicKeyBytes;
|
|
pub use crate::secret_key::SecretKey;
|
|
pub use crate::signature_bytes::SignatureBytes;
|
|
pub use milagro_bls::{compress_g2, hash_on_g2, G1Point};
|
|
pub use signature_set::{verify_signature_sets, SignatureSet, SignedMessage};
|
|
|
|
#[cfg(feature = "fake_crypto")]
|
|
mod fake_aggregate_public_key;
|
|
#[cfg(feature = "fake_crypto")]
|
|
mod fake_aggregate_signature;
|
|
#[cfg(feature = "fake_crypto")]
|
|
mod fake_public_key;
|
|
#[cfg(feature = "fake_crypto")]
|
|
mod fake_signature;
|
|
|
|
#[cfg(not(feature = "fake_crypto"))]
|
|
mod aggregate_public_key;
|
|
#[cfg(not(feature = "fake_crypto"))]
|
|
mod aggregate_signature;
|
|
#[cfg(not(feature = "fake_crypto"))]
|
|
mod public_key;
|
|
#[cfg(not(feature = "fake_crypto"))]
|
|
mod signature;
|
|
|
|
#[cfg(feature = "fake_crypto")]
|
|
pub use fakes::*;
|
|
#[cfg(feature = "fake_crypto")]
|
|
mod fakes {
|
|
pub use crate::fake_aggregate_public_key::FakeAggregatePublicKey as AggregatePublicKey;
|
|
pub use crate::fake_aggregate_signature::FakeAggregateSignature as AggregateSignature;
|
|
pub use crate::fake_public_key::FakePublicKey as PublicKey;
|
|
pub use crate::fake_signature::FakeSignature as Signature;
|
|
}
|
|
|
|
#[cfg(not(feature = "fake_crypto"))]
|
|
pub use reals::*;
|
|
#[cfg(not(feature = "fake_crypto"))]
|
|
mod reals {
|
|
pub use crate::aggregate_public_key::AggregatePublicKey;
|
|
pub use crate::aggregate_signature::AggregateSignature;
|
|
pub use crate::public_key::PublicKey;
|
|
pub use crate::signature::Signature;
|
|
}
|
|
|
|
pub const BLS_AGG_SIG_BYTE_SIZE: usize = 96;
|
|
pub const BLS_SIG_BYTE_SIZE: usize = 96;
|
|
pub const BLS_SECRET_KEY_BYTE_SIZE: usize = 48;
|
|
pub const BLS_PUBLIC_KEY_BYTE_SIZE: usize = 48;
|
|
|
|
use eth2_hashing::hash;
|
|
use ssz::ssz_encode;
|
|
|
|
/// Returns the withdrawal credentials for a given public key.
|
|
pub fn get_withdrawal_credentials(pubkey: &PublicKey, prefix_byte: u8) -> Vec<u8> {
|
|
let hashed = hash(&ssz_encode(pubkey));
|
|
let mut prefixed = vec![prefix_byte];
|
|
prefixed.extend_from_slice(&hashed[1..]);
|
|
|
|
prefixed
|
|
}
|
|
|
|
pub fn bls_verify_aggregate(
|
|
pubkey: &AggregatePublicKey,
|
|
message: &[u8],
|
|
signature: &AggregateSignature,
|
|
domain: u64,
|
|
) -> bool {
|
|
signature.verify(message, domain, pubkey)
|
|
}
|