Sign the owner's public key

Without this, the accountant will reject transfers from different
entities if they are for the same amount and to the same entity.
This commit is contained in:
Greg Fitzgerald 2018-03-02 11:56:40 -07:00
parent 9f12cd0c09
commit c998fbe2ae
1 changed files with 6 additions and 3 deletions

View File

@ -75,12 +75,15 @@ pub fn sign_transaction_data<T: Serialize>(
keypair: &Ed25519KeyPair,
to: &PublicKey,
) -> Signature {
sign_serialized(&(data, to), keypair)
let from = &Some(get_pubkey(keypair));
sign_serialized(&(from, to, data), keypair)
}
/// Return a signature for the given data using the private key from the given keypair.
pub fn sign_claim_data<T: Serialize>(data: &T, keypair: &Ed25519KeyPair) -> Signature {
sign_transaction_data(data, keypair, &get_pubkey(keypair))
let to = get_pubkey(keypair);
let from: Option<PublicKey> = None;
sign_serialized(&(&from, &to, data), keypair)
}
/// Verify a signed message with the given public key.
@ -109,7 +112,7 @@ pub fn verify_event<T: Serialize>(event: &Event<T>) -> bool {
sig,
} = *event
{
let sign_data = serialize(&(&data, &to)).unwrap();
let sign_data = serialize(&(&from, &to, &data)).unwrap();
if !verify_signature(&from.unwrap_or(to), &sign_data, &sig) {
return false;
}