-
Notifications
You must be signed in to change notification settings - Fork 271
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
add signing prefix for PruneData
and verify PruneData
with and without signing prefix
#1472
add signing prefix for PruneData
and verify PruneData
with and without signing prefix
#1472
Conversation
…alized data with and without prefix
fn signable_data_without_prefix(&self) -> Cow<[u8]> { | ||
#[derive(Serialize)] | ||
struct SignData<'a> { | ||
pubkey: &'a Pubkey, | ||
prunes: &'a [Pubkey], | ||
destination: &'a Pubkey, | ||
wallclock: u64, | ||
} | ||
let data = SignData { | ||
pubkey: &self.pubkey, | ||
prunes: &self.prunes, | ||
destination: &self.destination, | ||
wallclock: self.wallclock, | ||
}; | ||
Cow::Owned(serialize(&data).expect("should serialize PruneData")) | ||
} |
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.
could just leave this in signable_data()
instead of pulling it out into its own function. But wanted to explicitly show the change and the path we're taking. But open to other thoughts!
gossip/src/cluster_info.rs
Outdated
@@ -129,6 +129,8 @@ pub const MAX_INCREMENTAL_SNAPSHOT_HASHES: usize = 25; | |||
/// Maximum number of origin nodes that a PruneData may contain, such that the | |||
/// serialized size of the PruneMessage stays below PACKET_DATA_SIZE. | |||
const MAX_PRUNE_DATA_NODES: usize = 32; | |||
/// Prune data prefix for PruneMessage | |||
const PRUNE_DATA_PREFIX: &[u8] = "SOLANA_PRUNE_DATA".as_bytes(); |
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.
I suggest we prefix this with 0x7f
.
The first byte of a transaction is the number of signatures. 127 signatures would imply > 8128 byte transaction.
So therefore, an Ed25519 payload starting with 0x7f is guaranteed not a valid transaction.
cc @t-nelson
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.
this would assume we never go to the trouble of extending the MTU. there's a similar treatment specified for off-chain message signing. afaik the associated runtime support hasn't been added yet, but we should probably use the same value for the sake of future proofing
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.
lgtm
updated to prefix |
…thout signing prefix (anza-xyz#1472) * add PruneData serializing with prefix and support verifying both serialized data with and without prefix * prefix PRUNE_DATA_PREFIX with 0xff
First PR to add a signing prefix for
PruneData
.shoutout @ripatel-fd for first identifying this need.
Problem
Need signing domains. Ensure all signed
PruneData
messages are only used forPruneData
and nothing else.Summary of Changes
Once all validators have upgraded, we will
PruneData
with the new signing prefix.PruneData