Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ solana-big-mod-exp = "3.0.0"
solana-bincode = "3.1.0"
solana-blake3-hasher = "3.1.0"
solana-bloom = { path = "bloom", version = "=4.0.0-alpha.0", features = ["agave-unstable-api"] }
solana-bls-signatures = { version = "2.0.0-alpha.1", features = ["serde"] } #TODO: change to 2.0.0 before this gets into 4.0
solana-bls-signatures = { version = "3.0.0", features = ["serde"] }
solana-bn254 = "3.1.2"
solana-borsh = "3.0.0"
solana-bpf-loader-program = { path = "programs/bpf_loader", version = "=4.0.0-alpha.0", features = ["agave-unstable-api"] }
Expand Down
4 changes: 2 additions & 2 deletions clap-utils/src/input_parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ mod tests {

#[test]
fn test_bls_pubkeys_of() {
let bls_pubkey1: BLSPubkey = BLSKeypair::new().public;
let bls_pubkey2: BLSPubkey = BLSKeypair::new().public;
let bls_pubkey1: BLSPubkey = BLSKeypair::new().public.into();
let bls_pubkey2: BLSPubkey = BLSKeypair::new().public.into();
let bls_pubkey1_compressed: BLSPubkeyCompressed = bls_pubkey1.try_into().unwrap();
let bls_pubkey2_compressed: BLSPubkeyCompressed = bls_pubkey2.try_into().unwrap();
let matches = app().get_matches_from(vec![
Expand Down
4 changes: 2 additions & 2 deletions dev-bins/Cargo.lock

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

2 changes: 1 addition & 1 deletion genesis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ mod tests {

let generate_bls_pubkey = || {
if add_bls_pubkey {
let bls_pubkey = BLSKeypair::new().public;
let bls_pubkey: BLSPubkey = BLSKeypair::new().public.into();
if use_compressed_pubkey {
let bls_pubkey_compressed: BLSPubkeyCompressed = bls_pubkey.try_into().unwrap();
Some(bls_pubkey_compressed.to_string())
Expand Down
6 changes: 3 additions & 3 deletions keygen/src/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ fn do_main(matches: &ArgMatches) -> Result<(), Box<dyn error::Error>> {
("bls_pubkey", matches) => {
let keypair = get_keypair_from_matches(matches, config, &mut wallet_manager)?;
let bls_keypair = BLSKeypair::derive_from_signer(&keypair, BLS_KEYPAIR_DERIVE_SEED)?;
let bls_pubkey: BLSPubkey = bls_keypair.public;
let bls_pubkey: BLSPubkey = bls_keypair.public.into();

if matches.try_contains_id("outfile")? {
let outfile = matches.get_one::<String>("outfile").unwrap();
Expand Down Expand Up @@ -1269,7 +1269,7 @@ mod tests {
fn test_read_write_bls_pubkey() -> Result<(), std::boxed::Box<dyn std::error::Error>> {
let filename = "test_bls_pubkey.json";
let bls_keypair = BLSKeypair::new();
let bls_pubkey = bls_keypair.public;
let bls_pubkey: BLSPubkey = bls_keypair.public.into();
write_bls_pubkey_file(filename, bls_pubkey)?;
let read = read_bls_pubkey_file(filename)?;
assert_eq!(read, bls_pubkey);
Expand Down Expand Up @@ -1300,6 +1300,6 @@ mod tests {
let bls_keypair =
BLSKeypair::derive_from_signer(&my_keypair, BLS_KEYPAIR_DERIVE_SEED).unwrap();
let read_bls_pubkey = read_bls_pubkey_file(&outfile_path).unwrap();
assert_eq!(read_bls_pubkey, bls_keypair.public);
assert_eq!(read_bls_pubkey, bls_keypair.public.into());
}
}
4 changes: 2 additions & 2 deletions programs/sbf/Cargo.lock

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

35 changes: 10 additions & 25 deletions programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ use {
handler::{VoteStateHandle, VoteStateHandler, VoteStateTargetVersion},
log::*,
solana_account::{AccountSharedData, WritableAccount},
solana_bls_signatures::{
keypair::Keypair as BLSKeypair, ProofOfPossession as BLSProofOfPossession,
ProofOfPossessionCompressed as BLSProofOfPossessionCompressed, Pubkey as BLSPubkey,
PubkeyCompressed as BLSPubkeyCompressed, VerifiableProofOfPossession,
},
solana_bls_signatures::{keypair::Keypair as BLSKeypair, VerifiableProofOfPossession},
solana_clock::{Clock, Epoch, Slot},
solana_epoch_schedule::EpochSchedule,
solana_hash::Hash,
Expand Down Expand Up @@ -920,26 +916,15 @@ pub(crate) fn generate_pop_message(
message
}

// TODO(sam): use custom payload for PoP once solana-bls-signatures v2.0.0 is published.
pub fn verify_bls_proof_of_possession(
vote_account_pubkey: &Pubkey,
bls_pubkey_compressed_bytes: &[u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE],
bls_proof_of_possession_compressed_bytes: &[u8; BLS_PROOF_OF_POSSESSION_COMPRESSED_SIZE],
) -> Result<(), InstructionError> {
let bls_pubkey_compressed = BLSPubkeyCompressed(*bls_pubkey_compressed_bytes);
let bls_pubkey = BLSPubkey::try_from(bls_pubkey_compressed)
.map_err(|_| InstructionError::InvalidArgument)?;
let bls_proof_of_possession_compressed =
BLSProofOfPossessionCompressed(*bls_proof_of_possession_compressed_bytes);
let bls_proof_of_possession =
BLSProofOfPossession::try_from(bls_proof_of_possession_compressed)
.map_err(|_| InstructionError::InvalidArgument)?;
let message = generate_pop_message(vote_account_pubkey, bls_pubkey_compressed_bytes);
if Ok(true) == bls_proof_of_possession.verify(&bls_pubkey, Some(&message)) {
Ok(())
} else {
Err(InstructionError::InvalidArgument)
}
bls_proof_of_possession_compressed_bytes
.verify(bls_pubkey_compressed_bytes, Some(&message))
.map_err(|_| InstructionError::InvalidArgument)
}

/// Withdraw funds from the vote account
Expand Down Expand Up @@ -1266,13 +1251,13 @@ pub fn create_bls_proof_of_possession(
[u8; BLS_PUBLIC_KEY_COMPRESSED_SIZE],
[u8; BLS_PROOF_OF_POSSESSION_COMPRESSED_SIZE],
) {
let bls_pubkey_compressed: BLSPubkeyCompressed = bls_keypair.public.try_into().unwrap();
let message = generate_pop_message(vote_account_pubkey, &bls_pubkey_compressed.0);
let bls_pubkey_bytes = bls_keypair.public.to_bytes_compressed();
let message = generate_pop_message(vote_account_pubkey, &bls_pubkey_bytes);

let proof_of_possession = bls_keypair.proof_of_possession(Some(&message));
let proof_of_possession: BLSProofOfPossession = proof_of_possession.into();
let proof_of_possession_compressed: BLSProofOfPossessionCompressed =
proof_of_possession.try_into().unwrap();
(bls_pubkey_compressed.0, proof_of_possession_compressed.0)
let proof_of_possession_bytes = proof_of_possession.to_bytes_compressed();

(bls_pubkey_bytes, proof_of_possession_bytes)
}

#[allow(clippy::arithmetic_side_effects)]
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/epoch_stakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ pub(crate) mod tests {
iter::repeat_with(|| {
let authorized_voter = solana_pubkey::new_rand();
let bls_pubkey_compressed: BLSPubkeyCompressed =
BLSKeypair::new().public.try_into().unwrap();
BLSKeypair::new().public.into();
let bls_pubkey_compressed_serialized =
bincode::serialize(&bls_pubkey_compressed)
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/genesis_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn create_genesis_config_with_vote_accounts_and_cluster_type(
BLS_KEYPAIR_DERIVE_SEED,
)
.unwrap();
Some(bls_pubkey_to_compressed_bytes(&bls_keypair.public))
Some(bls_keypair.public.to_bytes_compressed())
} else {
None
};
Expand Down Expand Up @@ -195,7 +195,7 @@ pub fn create_genesis_config_with_vote_accounts_and_cluster_type(
BLS_KEYPAIR_DERIVE_SEED,
)
.unwrap();
Some(bls_pubkey_to_compressed_bytes(&bls_keypair.public))
Some(bls_keypair.public.to_bytes_compressed())
} else {
None
};
Expand Down
2 changes: 1 addition & 1 deletion votor/src/consensus_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,7 @@ mod tests {
let bls_keypair =
BLSKeypair::derive_from_signer(validator_vote_keypair, BLS_KEYPAIR_DERIVE_SEED)
.unwrap();
let bls_pubkey: BLSPubkey = bls_keypair.public;
let bls_pubkey: BLSPubkey = bls_keypair.public.into();

let signed_message = bincode::serialize(&vote).unwrap();

Expand Down
10 changes: 3 additions & 7 deletions votor/src/consensus_pool/certificate_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,9 @@ mod tests {
let aggregate_pubkey = BLSPubkeyProjective::aggregate(keypairs.iter().map(|kp| &kp.public))
.expect("Failed to aggregate public keys");

let verification_result =
aggregate_pubkey.verify_signature(&certificate_message.signature, &serialized_vote);

assert!(
verification_result.unwrap_or(false),
"BLS aggregate signature verification failed for base2 encoded certificate"
);
aggregate_pubkey
.verify_signature(&certificate_message.signature, &serialized_vote)
.expect("BLS aggregate signature verification failed for base2 encoded certificate");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion votor/src/voting_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ fn generate_vote_tx(vote: &Vote, bank: &Bank, context: &mut VotingContext) -> Ge

let bls_keypair = get_bls_keypair(context, &authorized_voter_keypair)
.unwrap_or_else(|e| panic!("Failed to derive my own BLS keypair: {e:?}"));
let my_bls_pubkey: BLSPubkey = bls_keypair.public;
let my_bls_pubkey: BLSPubkey = bls_keypair.public.into();
if my_bls_pubkey != bls_pubkey_in_vote_account {
panic!(
"Vote account bls_pubkey mismatch: {bls_pubkey_in_vote_account:?} (expected: \
Expand Down
Loading