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