Research Article

A Multi-Blockchain-Based Cross-Domain Authentication and Authorization Scheme for Energy Internet

Algorithm 4

The chaincode about the lookup algorithm of the cuckoo filter.
1: Procedure func (s SmartContract) Lookup(ctx contractapi.TransactionContextInterface, id string, item string) bool
2: cfJSON, err: = ctx.GetStub().GetState(id)
3: If err! = nil then
4:  Return shim.Error(err.Error())
5: End if
6: var cf CFilter
7: err = json.Unmarshal(cfJSON, &cf)
8: If err! = nil then
9:  Return shim.Error(err.Error())
10: End if
11: f := fprint([]byte(item), cf.FpSize, Hashfn)
12: j := hashfp([]byte(item)) % cf.Size
13: k := (j XOR hashfp(f)) % cf.Size
14: Return cf.Buckets[j].lookup(f) || cf.Buckets[k].lookup(f)
15: End procedure