Skip to content

Commit

Permalink
Merge pull request #3276 from input-output-hk/update-lints-chain-libs
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-babichenko authored May 6, 2021
2 parents 1a63724 + fc40aee commit fb0dc3b
Show file tree
Hide file tree
Showing 30 changed files with 73 additions and 76 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions jcli/src/jcli_lib/certificate/new_stake_pool_registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::jcli_lib::{
certificate::{write_cert, Error},
utils::key_parser::parse_pub_key,
};
use chain_crypto::{Curve25519_2HashDH, Ed25519, PublicKey, SumEd25519_12};
use chain_crypto::{Curve25519_2HashDh, Ed25519, PublicKey, SumEd25519_12};
use chain_impl_mockchain::{
certificate::{Certificate, PoolPermissions, PoolRegistration},
key::GenesisPraosLeader,
Expand Down Expand Up @@ -87,7 +87,7 @@ pub struct StakePoolRegistration {
name = "VRF_KEY",
parse(try_from_str = parse_pub_key)
)]
pub vrf_key: PublicKey<Curve25519_2HashDH>,
pub vrf_key: PublicKey<Curve25519_2HashDh>,

/// set the fixed value tax the stake pool will reserve from the reward
///
Expand Down
2 changes: 1 addition & 1 deletion jcli/src/jcli_lib/certificate/new_vote_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl PrivateVoteCast {
chain_vote::EncryptingVoteKey::from_bytes(&key_bin).ok_or(Error::VoteEncryptingKey)?;

let vote = chain_vote::Vote::new(self.options, self.choice as usize);
let crs = chain_vote::CRS::from_hash(self.vote_plan_id.as_ref());
let crs = chain_vote::Crs::from_hash(self.vote_plan_id.as_ref());
let (encrypted_vote, proof) =
chain_impl_mockchain::vote::encrypt_vote(&mut rng, &crs, &key, vote);

Expand Down
12 changes: 6 additions & 6 deletions jcli/src/jcli_lib/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::jcli_lib::utils::io;
use crate::jcli_lib::utils::output_file::{self, OutputFile};
use bech32::{self, u5, FromBase32, ToBase32};
use chain_crypto::{
bech32::Bech32 as _, AsymmetricKey, AsymmetricPublicKey, Curve25519_2HashDH, Ed25519,
bech32::Bech32 as _, AsymmetricKey, AsymmetricPublicKey, Curve25519_2HashDh, Ed25519,
Ed25519Bip32, Ed25519Extended, SecretKey, SigningAlgorithm, SumEd25519_12, Verification,
VerificationAlgorithm,
};
Expand Down Expand Up @@ -216,7 +216,7 @@ impl Generate {
GenPrivKeyType::Ed25519Bip32 => gen_priv_key::<Ed25519Bip32>(self.seed)?,
GenPrivKeyType::Ed25519Extended => gen_priv_key::<Ed25519Extended>(self.seed)?,
GenPrivKeyType::SumEd25519_12 => gen_priv_key::<SumEd25519_12>(self.seed)?,
GenPrivKeyType::Curve25519_2HashDh => gen_priv_key::<Curve25519_2HashDH>(self.seed)?,
GenPrivKeyType::Curve25519_2HashDh => gen_priv_key::<Curve25519_2HashDh>(self.seed)?,
};
let mut output = self.output_file.open()?;
writeln!(output, "{}", priv_key_bech32)?;
Expand All @@ -232,7 +232,7 @@ impl ToPublic {
Ed25519Bip32::SECRET_BECH32_HRP => gen_pub_key::<Ed25519Bip32>(&data),
Ed25519Extended::SECRET_BECH32_HRP => gen_pub_key::<Ed25519Extended>(&data),
SumEd25519_12::SECRET_BECH32_HRP => gen_pub_key::<SumEd25519_12>(&data),
Curve25519_2HashDH::SECRET_BECH32_HRP => gen_pub_key::<Curve25519_2HashDH>(&data),
Curve25519_2HashDh::SECRET_BECH32_HRP => gen_pub_key::<Curve25519_2HashDh>(&data),
_ => Err(Error::UnknownBech32PrivKeyHrp { hrp }),
}?;
let mut output = self.output_file.open()?;
Expand All @@ -249,12 +249,12 @@ impl ToBytes {
Ed25519::PUBLIC_BECH32_HRP
| Ed25519Bip32::PUBLIC_BECH32_HRP
| SumEd25519_12::PUBLIC_BECH32_HRP
| Curve25519_2HashDH::PUBLIC_BECH32_HRP
| Curve25519_2HashDh::PUBLIC_BECH32_HRP
| Ed25519::SECRET_BECH32_HRP
| Ed25519Bip32::SECRET_BECH32_HRP
| Ed25519Extended::SECRET_BECH32_HRP
| SumEd25519_12::SECRET_BECH32_HRP
| Curve25519_2HashDH::SECRET_BECH32_HRP => Ok(()),
| Curve25519_2HashDh::SECRET_BECH32_HRP => Ok(()),
_ => Err(Error::UnknownBech32PrivKeyHrp { hrp }),
}?;
let bytes = Vec::<u8>::from_base32(&data)?;
Expand All @@ -273,7 +273,7 @@ impl FromBytes {
GenPrivKeyType::Ed25519Bip32 => bytes_to_priv_key::<Ed25519Bip32>(&bytes)?,
GenPrivKeyType::Ed25519Extended => bytes_to_priv_key::<Ed25519Extended>(&bytes)?,
GenPrivKeyType::SumEd25519_12 => bytes_to_priv_key::<SumEd25519_12>(&bytes)?,
GenPrivKeyType::Curve25519_2HashDh => bytes_to_priv_key::<Curve25519_2HashDH>(&bytes)?,
GenPrivKeyType::Curve25519_2HashDh => bytes_to_priv_key::<Curve25519_2HashDh>(&bytes)?,
};
let mut output = self.output_file.open()?;
writeln!(output, "{}", priv_key_bech32)?;
Expand Down
4 changes: 2 additions & 2 deletions jcli/src/jcli_lib/vote/committee/communication_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ impl ToPublic {
return Err(Error::InvalidSecretKey);
}

let key = chain_vote::gargamel::SecretKey::from_bytes(
let key = chain_vote::encryption::SecretKey::from_bytes(
&Vec::<u8>::from_base32(&bytes).map_err(|_| Error::InvalidSecretKey)?,
)
.ok_or(Error::InvalidSecretKey)?;

let kp = chain_vote::gargamel::Keypair::from_secretkey(key);
let kp = chain_vote::encryption::Keypair::from_secretkey(key);

let mut output = self.output_file.open()?;
writeln!(
Expand Down
10 changes: 5 additions & 5 deletions jcli/src/jcli_lib/vote/committee/member_key.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::jcli_lib::vote::{Error, OutputFile, Seed};
use bech32::{FromBase32, ToBase32};
use chain_vote::gargamel::PublicKey;
use chain_vote::encryption::PublicKey;
use chain_vote::{MemberCommunicationPublicKey, MemberState};
use rand::rngs::OsRng;
use rand_chacha::rand_core::SeedableRng;
Expand All @@ -16,7 +16,7 @@ pub struct Generate {
threshold: usize,

/// the common reference string
#[structopt(long, name = "CRS")]
#[structopt(long, name = "Crs")]
crs: String,

/// communication keys of all committee members
Expand Down Expand Up @@ -82,7 +82,7 @@ impl Generate {
return Err(Error::InvalidCommitteMemberIndex);
}

let crs = chain_vote::CRS::from_hash(self.crs.as_bytes());
let crs = chain_vote::Crs::from_hash(self.crs.as_bytes());

let ms = MemberState::new(
&mut rng,
Expand Down Expand Up @@ -117,12 +117,12 @@ impl ToPublic {
return Err(Error::InvalidSecretKey);
}

let key = chain_vote::gargamel::SecretKey::from_bytes(
let key = chain_vote::encryption::SecretKey::from_bytes(
&Vec::<u8>::from_base32(&key).map_err(|_| Error::InvalidSecretKey)?,
)
.ok_or(Error::InvalidSecretKey)?;

let pk = chain_vote::gargamel::Keypair::from_secretkey(key).public_key;
let pk = chain_vote::encryption::Keypair::from_secretkey(key).public_key;

let mut output = self.output_file.open()?;
let key = bech32::encode(
Expand Down
2 changes: 1 addition & 1 deletion jcli/src/jcli_lib/vote/encrypting_vote_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn parse_member_key(key: &str) -> Result<chain_vote::committee::MemberPublicKey,
if hrp != crate::jcli_lib::vote::bech32_constants::MEMBER_PK_HRP {
return Err(Error::InvalidPublicKey);
}
chain_vote::gargamel::PublicKey::from_bytes(
chain_vote::encryption::PublicKey::from_bytes(
&Vec::<u8>::from_base32(&raw_key).map_err(|_| Error::InvalidPublicKey)?,
)
.ok_or(Error::InvalidPublicKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl BlockchainConfiguration {
.map(|_| "consensus_genesis_praos_active_slot_coeff")
}
ConfigParam::LinearFee(param) => linear_fees.replace(param).map(|_| "linear_fees"),
cp @ ConfigParam::KESUpdateSpeed(_) => kes_update_speed
cp @ ConfigParam::KesUpdateSpeed(_) => kes_update_speed
.replace(KesUpdateSpeed::try_from(cp)?)
.map(|_| "kes_update_speed"),
cp @ ConfigParam::FeesInTreasury(_) => fees_go_to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl TryFrom<ConfigParam> for KesUpdateSpeed {
type Error = TryFromKesUpdateSpeedError;
fn try_from(config_param: ConfigParam) -> Result<Self, Self::Error> {
match config_param {
ConfigParam::KESUpdateSpeed(speed) => {
ConfigParam::KesUpdateSpeed(speed) => {
KesUpdateSpeed::new(speed).ok_or(TryFromKesUpdateSpeedError::Invalid { speed })
}
_ => Err(TryFromKesUpdateSpeedError::Incompatible),
Expand All @@ -65,7 +65,7 @@ impl TryFrom<ConfigParam> for KesUpdateSpeed {

impl From<KesUpdateSpeed> for ConfigParam {
fn from(kes_update_speed: KesUpdateSpeed) -> Self {
ConfigParam::KESUpdateSpeed(kes_update_speed.0)
ConfigParam::KesUpdateSpeed(kes_update_speed.0)
}
}

Expand Down
4 changes: 2 additions & 2 deletions jormungandr-lib/src/interfaces/config/secret.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::crypto::{hash::Hash, key::SigningKey};
use chain_crypto::{Curve25519_2HashDH, Ed25519, SumEd25519_12};
use chain_crypto::{Curve25519_2HashDh, Ed25519, SumEd25519_12};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize)]
Expand All @@ -22,5 +22,5 @@ pub struct Bft {
pub struct GenesisPraos {
pub node_id: Hash,
pub sig_key: SigningKey<SumEd25519_12>,
pub vrf_key: SigningKey<Curve25519_2HashDH>,
pub vrf_key: SigningKey<Curve25519_2HashDh>,
}
4 changes: 2 additions & 2 deletions jormungandr-lib/src/interfaces/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ mod test {
#[test]
fn test_deserialize_member_public_keys() {
let mut rng = rand_chacha::ChaChaRng::from_entropy();
let crs = chain_vote::CRS::from_hash("Dummy shared string".as_bytes());
let crs = chain_vote::Crs::from_hash("Dummy shared string".as_bytes());
let comm_key = chain_vote::MemberCommunicationKey::new(&mut rng);

let member_key =
Expand All @@ -761,7 +761,7 @@ mod test {
struct Helper(#[serde(with = "VotePlanDef")] VotePlan);

let mut rng = rand_chacha::ChaChaRng::from_entropy();
let crs = chain_vote::CRS::from_hash("Dummy shared string".as_bytes());
let crs = chain_vote::Crs::from_hash("Dummy shared string".as_bytes());
let comm_key = chain_vote::MemberCommunicationKey::new(&mut rng);

let member_key =
Expand Down
4 changes: 2 additions & 2 deletions jormungandr/src/blockchain/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,10 @@ impl Blockchain {
header,
epoch_leadership_schedule,
epoch_ledger_parameters,
epoch_rewards_info,
parent_ledger_state,
time_frame,
previous_epoch_state,
epoch_rewards_info,
})
}

Expand Down Expand Up @@ -613,10 +613,10 @@ impl Blockchain {
header,
epoch_leadership_schedule,
epoch_ledger_parameters,
epoch_rewards_info,
parent_ledger_state,
time_frame,
previous_epoch_state,
epoch_rewards_info,
};

self.apply_block_check_rewards(&post_checked_header, &new_ledger)?;
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/src/explorer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ impl ExplorerDb {
let initial_state = State {
transactions,
blocks,
addresses,
epochs,
chain_lengths,
addresses,
stake_pool_data,
stake_pool_blocks,
vote_plans,
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ fn bootstrap(initialized_node: InitializedNode) -> Result<BootstrappedNode, star

Ok(BootstrappedNode {
settings,
block0_hash,
blockchain,
blockchain_tip,
block0_hash,
explorer_db,
rest_context,
services,
Expand Down
2 changes: 1 addition & 1 deletion jormungandr/src/network/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ impl NodeService {
let span = span!(parent: global_state.span(), Level::TRACE, "sub_task", kind = "server");
NodeService {
channels,
span,
global_state,
span,
}
}

Expand Down
Loading

0 comments on commit fb0dc3b

Please sign in to comment.