Minor work on the transaction signing task

This commit is contained in:
Luke Parker
2024-09-05 14:42:06 -04:00
parent 8380653855
commit b62fc3a1fa
14 changed files with 169 additions and 2 deletions

View File

@@ -10,11 +10,26 @@ use group::GroupEncoding;
use serai_db::DbTxn;
/// A signable transaction.
pub trait SignableTransaction: 'static + Sized + Send + Sync {
pub trait SignableTransaction: 'static + Sized + Send + Sync + Clone {
/// The ciphersuite used to sign this transaction.
type Ciphersuite: Cuphersuite;
/// The preprocess machine for the signing protocol for this transaction.
type PreprocessMachine: PreprocessMachine;
/// Read a `SignableTransaction`.
fn read(reader: &mut impl io::Read) -> io::Result<Self>;
/// Write a `SignableTransaction`.
fn write(&self, writer: &mut impl io::Write) -> io::Result<()>;
/// The ID for this transaction.
///
/// This is an internal ID arbitrarily definable so long as it's unique.
///
/// This same ID MUST be returned by the Eventuality for this transaction.
fn id(&self) -> [u8; 32];
/// Sign this transaction.
fn sign(self, keys: ThresholdKeys<Self::Ciphersuite>) -> Self::PreprocessMachine;
}
mod db {

View File

@@ -309,6 +309,8 @@ impl<S: ScannerFeed, P: TransactionPlanner<S, ()>> Scheduler<S, P> {
}
impl<S: ScannerFeed, P: TransactionPlanner<S, ()>> SchedulerTrait<S> for Scheduler<S, P> {
type SignableTransaction = P::SignableTransaction;
fn activate_key(txn: &mut impl DbTxn, key: KeyFor<S>) {
for coin in S::NETWORK.coins() {
assert!(Db::<S>::outputs(txn, key, *coin).is_none());

View File

@@ -368,6 +368,8 @@ impl<S: ScannerFeed, P: TransactionPlanner<S, EffectedReceivedOutputs<S>>> Sched
impl<S: ScannerFeed, P: TransactionPlanner<S, EffectedReceivedOutputs<S>>> SchedulerTrait<S>
for Scheduler<S, P>
{
type SignableTransaction = P::SignableTransaction;
fn activate_key(txn: &mut impl DbTxn, key: KeyFor<S>) {
for coin in S::NETWORK.coins() {
assert!(Db::<S>::outputs(txn, key, *coin).is_none());