extension_utilities.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package extension
  2. import (
  3. "github.com/ethereum/go-ethereum/common"
  4. "github.com/ethereum/go-ethereum/private"
  5. "github.com/ethereum/go-ethereum/private/engine"
  6. )
  7. // generateUuid sends some data to the linked Private Transaction Manager which
  8. // uses a randomly generated key to encrypt the data and then hash it this
  9. // means we get a effectively random hash, whilst also having a reference
  10. // transaction inside the PTM
  11. func generateUuid(contractAddress common.Address, privateFrom string, privateFor []string, ptm private.PrivateTransactionManager) (string, error) {
  12. // to ensure recoverability , the UUID generation logic is as below:
  13. // 1. Call Tessera to encrypt the management contract address
  14. // 2. Send the encrypted payload to all participants on the contract extension
  15. // 3. Use the received hash as the UUID
  16. payloadHash, err := ptm.EncryptPayload(contractAddress.Bytes(), privateFrom, []string{}, &engine.ExtraMetadata{})
  17. if err != nil {
  18. return "", err
  19. }
  20. _, _, hash, err := ptm.Send(payloadHash, privateFrom, privateFor, &engine.ExtraMetadata{})
  21. if err != nil {
  22. return "", err
  23. }
  24. return hash.String(), nil
  25. }
  26. func checkAddressInList(addressToFind common.Address, addressList []common.Address) bool {
  27. for _, addr := range addressList {
  28. if addressToFind == addr {
  29. return true
  30. }
  31. }
  32. return false
  33. }