You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.4 KiB

  1. package ringct
  2. import "fmt"
  3. import "github.com/deroproject/derosuite/crypto"
  4. /* This file implements MLSAG signatures for the transactions */
  5. // get the hash of the transaction which is used to create the mlsag later on, this hash is input to MLSAG
  6. // the hash is = hash( message + hash(basehash) + hash(pederson and borromean data))
  7. func Get_pre_mlsag_hash(sig *RctSig) (crypto.Hash) {
  8. message_hash := sig.Message
  9. base_hash := crypto.Keccak256(sig.SerializeBase())
  10. fmt.Printf("Message hash %x\n", message_hash)
  11. fmt.Printf("Base hash %x\n", base_hash)
  12. // now join the borromean signature and extract a sig
  13. var other_data []byte
  14. for i := range sig.rangeSigs {
  15. other_data = append(other_data,sig.rangeSigs[i].asig.s0.Serialize()...)
  16. other_data = append(other_data,sig.rangeSigs[i].asig.s1.Serialize()...)
  17. other_data = append(other_data, sig.rangeSigs[i].ci.Serialize()...)
  18. }
  19. other_data_hash := crypto.Keccak256(other_data)
  20. fmt.Printf("other hash %x\n", other_data_hash)
  21. // join all 3 hashes and hash them again to get the data
  22. final_data := append(message_hash[:], base_hash[:]...)
  23. final_data = append(final_data, other_data_hash[:]...)
  24. final_data_hash := crypto.Keccak256(final_data)
  25. fmt.Printf("final_data_hash hash %x\n", other_data_hash)
  26. return final_data_hash
  27. }