Skip to main content
. 2022 Apr 27;11(9):1269. doi: 10.3390/foods11091269
Algorithm A1: Collect cross-chain smart contract A(CCSC-A)
Input: H(user); D; Dn; DATA; Ds; T; AD; CCSC-B; pkp; Y; F;
1: func Certification(H(user)) (D) // Data acquisition module
{
For t in range (m)
If H(user) permissions match
  Matching collection information:{Hazardous Material Information or corporate information or consumer information or regulatory agency information or transaction records or cost information or data interaction records or health records or other information}
If Data validation after data standardization
Return Step 2
}
2: func Hash lock(D)// Data encryption module
{
For t in range (m)
If D standards compliant
  Get data summaries Ds
DNH(N)// D takes a random number N and generates the corresponding hash value H(N)
DnEncrypt H(N)(D)// Encrypt D using H(N) to generate ciphertext Dn
DATAEncryptpkp(Dn, H(N), Ds)// Use the user’s public key to integrate and encrypt Dn, H(N), and Ds to generate data packets DATA
If Ds, H (N), Dn, DATA generate
Return true
Return false
}
3:func Slice(DATA)// Data Fragmentation Module{
 For t in range (m)
If Step 2 returns true
Slice(DATA)//DATA Fragmentation
Send(DATA)Relay chain (node)// Data shards are stored in each node of the relay chain
Return true
     Return false
}
4:func Game(Relay chain (node))// Game module
{
For t in range (m)
If Step 3 returns true
Game(node)// The game of each node of the relay chain obtains the right of reorganization
Return Relay chain (node)DATA// Data normalization
     Each node encrypts data shards and returns H(DATA) to the contract
     If Judgment complete:
Set(T)// Set time lock T
Verify(H(DATA)>51%)// The amount of H (DATA) returned within T time is greater than 50%
Return true
Return exit
}
5: func Get(AD)// storage module
{
If Step 4 returns true
Transfer(CCSC-B)
Return CCSC-AN; ADCCSC-A// N and AD exchange to obtain
Store AD to the blockchain
If   Store successfully verified:
Verify(Decrypt (D)) Y/F// Verification of CCSC-B decryption result notification Y/F
Return Storage(AD) and true
Return Exit and false
//main chain, exit is interrupt cross-chain transmission in time
}