diff --git a/src/accountant.rs b/src/accountant.rs index 2120650d31..0c03ae17ee 100644 --- a/src/accountant.rs +++ b/src/accountant.rs @@ -92,7 +92,7 @@ impl Accountant { } let event = Event::Transaction { - from, + from: Some(from), to, data, sig, diff --git a/src/event.rs b/src/event.rs index 8597394c54..2daf04b89d 100644 --- a/src/event.rs +++ b/src/event.rs @@ -35,7 +35,7 @@ pub enum Event { sig: Signature, }, Transaction { - from: PublicKey, + from: Option, to: PublicKey, data: T, sig: Signature, @@ -106,7 +106,7 @@ pub fn verify_event(event: &Event) -> bool { } = *event { let sign_data = serialize(&(&data, &to)).unwrap(); - if !verify_signature(&from, &sign_data, &sig) { + if !verify_signature(&from.unwrap_or(to), &sign_data, &sig) { return false; } } diff --git a/src/log.rs b/src/log.rs index 56d930b523..2f24dc2b45 100644 --- a/src/log.rs +++ b/src/log.rs @@ -268,7 +268,7 @@ mod tests { let pubkey1 = get_pubkey(&keypair1); let data = hash(b"hello, world"); let event0 = Event::Transaction { - from: get_pubkey(&keypair0), + from: Some(get_pubkey(&keypair0)), to: pubkey1, data, sig: sign_transaction_data(&data, &keypair0, &pubkey1), @@ -285,7 +285,7 @@ mod tests { let pubkey1 = get_pubkey(&keypair1); let data = hash(b"hello, world"); let event0 = Event::Transaction { - from: get_pubkey(&keypair0), + from: Some(get_pubkey(&keypair0)), to: pubkey1, data: hash(b"goodbye cruel world"), // <-- attack! sig: sign_transaction_data(&data, &keypair0, &pubkey1), @@ -303,7 +303,7 @@ mod tests { let pubkey1 = get_pubkey(&keypair1); let data = hash(b"hello, world"); let event0 = Event::Transaction { - from: get_pubkey(&keypair0), + from: Some(get_pubkey(&keypair0)), to: get_pubkey(&thief_keypair), // <-- attack! data: hash(b"goodbye cruel world"), sig: sign_transaction_data(&data, &keypair0, &pubkey1),