Use multiple nonces in the Tributary

This commit is contained in:
Luke Parker
2023-12-01 12:09:22 -05:00
parent c82d1283af
commit 1ca66b846a
11 changed files with 221 additions and 200 deletions

View File

@@ -1,5 +1,5 @@
use core::ops::Deref;
use std::{sync::Arc, io, collections::HashMap};
use std::{sync::Arc, io};
use zeroize::Zeroizing;
use rand::{RngCore, CryptoRng, rngs::OsRng};
@@ -114,7 +114,7 @@ impl ReadWrite for SignedTransaction {
impl Transaction for SignedTransaction {
fn kind(&self) -> TransactionKind<'_> {
TransactionKind::Signed(&self.1)
TransactionKind::Signed(vec![], &self.1)
}
fn hash(&self) -> [u8; 32] {
@@ -145,9 +145,7 @@ pub fn signed_transaction<R: RngCore + CryptoRng>(
tx.1.signature.R = Ristretto::generator() * sig_nonce.deref();
tx.1.signature = SchnorrSignature::sign(key, sig_nonce, tx.sig_hash(genesis));
let mut nonces = HashMap::from([(signer, nonce)]);
verify_transaction(&tx, genesis, &mut nonces).unwrap();
assert_eq!(nonces, HashMap::from([(tx.1.signer, tx.1.nonce.wrapping_add(1))]));
verify_transaction(&tx, genesis, &mut |_, _| Some(tx.1.nonce)).unwrap();
tx
}