Skip to content
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

refactor!: don't send public key with signature #4518

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mversic
Copy link
Contributor

@mversic mversic commented Apr 26, 2024

Description

Linked issue

Closes #4393

Benefits

Checklist

  • I've read CONTRIBUTING.md
  • I've used the standard signed-off commit format (or will squash just before merging)
  • All applicable CI checks pass (or I promised to make them pass later)
  • (optional) I've written unit tests for the code changes
  • I replied to all comments after code review, marking all implemented changes with thumbs up

@github-actions github-actions bot added iroha2-dev The re-implementation of a BFT hyperledger in RUST Refactor Improvement to overall code quality labels Apr 26, 2024
@mversic mversic force-pushed the remove_public_key branch 2 times, most recently from cee8760 to df420c1 Compare April 26, 2024 14:02
@github-actions github-actions bot added the api-changes Changes in the API for client libraries label Apr 26, 2024
@mversic mversic changed the title [refactor] #4393: don't send public key with signature (refactor): don't send public key with signature May 1, 2024
@mversic mversic changed the title (refactor): don't send public key with signature refactor!: don't send public key with signature May 1, 2024
@mversic mversic force-pushed the remove_public_key branch 2 times, most recently from dc4d7d7 to 3701fc5 Compare May 2, 2024 07:52
@mversic mversic removed the iroha2-dev The re-implementation of a BFT hyperledger in RUST label May 2, 2024
data_model/src/block.rs Outdated Show resolved Hide resolved
data_model/src/block.rs Outdated Show resolved Hide resolved
signatures
.into_iter()
.filter(|signature| public_keys.contains(signature.public_key()))
.filter(|signature| filtered.contains(&(signature.0 as usize)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like check that signature actually match peer's public key should be checked here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh, good point. This will take me some time to fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fixed now, but the change propagated

pub fn sign(self, key_pair: &KeyPair, topology: &Topology) -> ValidBlock {
let node_pos = topology
.position(key_pair.public_key())
.expect("BUG: Node is not in topology");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you decided to panic here? Maybe allow downstream users to handle error condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that it indicates a bug in consensus. The node that is signing must be present in the topology. This must never happen, I consider it the same as accessing array out of bounds.

I will reconsider

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encountering this panic means that Role::Undefined is trying to sign a block. This mustn't happen in a correct consensus so panic is appropriate

@mversic mversic force-pushed the remove_public_key branch 5 times, most recently from bdb903e to fb852e9 Compare May 8, 2024 10:42
@mversic mversic force-pushed the remove_public_key branch 2 times, most recently from 399deac to 5fc6223 Compare May 8, 2024 11:07
Signed-off-by: Marin Veršić <marin.versic101@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-changes Changes in the API for client libraries Refactor Improvement to overall code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should we pack public keys with signatures?
2 participants