Skip to content

problem with signature verification #1

Description

@Theog75

in wallet:

func (t *Transaction) GenerateSignature() *utils.Signature {
    m, _ := json.Marshal(t)
    fmt.Println("Sign: ", m, t)
    h := sha256.Sum256([]byte(m))
    // fmt.Println(h)
    r, s, _ := ecdsa.Sign(rand.Reader, t.senderPrivateKey, h[:])
    return &utils.Signature{R: r, S: s}
}

in blockchain

func (bc *BlockChain) VerifyTransactionSignature(senderPublicKey *ecdsa.PublicKey, s *utils.Signature, t *Transaction) bool {
	m, _ := json.Marshal(t)
	fmt.Println("Verify:", m, t)
	h := sha256.Sum256([]byte(m))
	// fmt.Println(h)
	return ecdsa.Verify(senderPublicKey, h[:], s.R, s.S)
}

the output of m is same although the transaction in the wallet is different from the transaction in the blockchain

Sign: [123 125] &{0x140001140f0 0x140001140f0 112wEP4zjRf6dqXr7U3VUr4cs4x7egVEwn 18nGYwaj2JC15Ry2zkyzUCZZpv1j3SVEYk 23}

Verify: [123 125] &{112wEP4zjRf6dqXr7U3VUr4cs4x7egVEwn 112wEP4zjRf6dqXr7U3VUr4cs4x7egVEwn 1223}

LC
Add reply

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions