Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The signature targets should contain tx's parents #2

Open
heeeeeng opened this issue Feb 13, 2019 · 0 comments
Open

The signature targets should contain tx's parents #2

heeeeeng opened this issue Feb 13, 2019 · 0 comments

Comments

@heeeeeng
Copy link
Contributor

heeeeeng commented Feb 13, 2019

The tx's parents are not contained by signature targets.
A malicious node is able to change a tx's parents and broadcast the tampered tx to the network.
This will lead to a double spending problem, because a natural node can't figgure out which tx is the correct one as these two txs have the same signature.

To solve this, the SignatureTargets() function of each tx type should be changed:

func (t *Sequencer) SignatureTargets() []byte {
	var buf bytes.Buffer

	panicIfError(binary.Write(&buf, binary.BigEndian, t.AccountNonce))
	panicIfError(binary.Write(&buf, binary.BigEndian, t.Issuer.Bytes))
	panicIfError(binary.Write(&buf, binary.BigEndian, t.Height))

	return buf.Bytes()
}

Tx parents information should be added.

Another necessary changing is the order of tx creation. In current version, the tx is been signed first and then been assigned which txs are it's parents. The problem is that this will make it impossible for SignatureTarget() function to get parents information as parents are known only after signing. The solution changing the order: assign parrents first and then sign the tx with parents information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant