Only allow designated participants to send transactions

This commit is contained in:
Luke Parker
2023-04-12 12:42:23 -04:00
parent be947ce152
commit 8c8232516d
6 changed files with 99 additions and 47 deletions

View File

@@ -91,7 +91,7 @@ pub trait Transaction: Send + Sync + Clone + Eq + Debug + ReadWrite {
}
}
// This will only cause mutations when the transaction is valid.
// This will only cause mutations when the transaction is valid
pub(crate) fn verify_transaction<T: Transaction>(
tx: &T,
genesis: [u8; 32],
@@ -108,9 +108,13 @@ pub(crate) fn verify_transaction<T: Transaction>(
}
TransactionKind::Unsigned => {}
TransactionKind::Signed(Signed { signer, nonce, signature }) => {
// TODO: Use presence as a whitelist, erroring on lack of
if next_nonces.get(signer).cloned().unwrap_or(0) != *nonce {
Err(TransactionError::Temporal)?;
if let Some(next_nonce) = next_nonces.get(signer) {
if nonce != next_nonce {
Err(TransactionError::Temporal)?;
}
} else {
// Not a participant
Err(TransactionError::Fatal)?;
}
// TODO: Use Schnorr half-aggregation and a batch verification here