Why can’t I query the encrypted fields of my OmniIndex blockchain?

66 views Asked by At

I am expecting to be able to query my blockchain, using the published omniindex runanalyticquery endpoint.

First I ran getblockschematic, so that I could see the fields I want to run the query against…

In my blockchain schematic I have two fields I want to run some analytics on, job (which is not encrypted) I am expecting to be able to query my blockchain, using the published omniindex runanalyticquery endpoint.

First I ran getblockschematic, so that I could see the fields I want to run the query against…

In my blockchain schematic I have two fields I want to run some analytics on, job (which is not encrypted) and info (which is homomorphically encrypted) = infosearchableowners

Response extract: { "13": { "column_name": "infoglobal", "data_type": "text" }, "14": { "column_name": "infosearchableglobal", "data_type": "text" }, "15": { "column_name": "ipv4global", "data_type": "text" }, "16": { "column_name": "ipv4searchableglobal", "data_type": "text" }, "17": { "column_name": "job", "data_type": "text" },

Here is my API call from Postman (I have obfuscated the private keys with the postman environment variables in {{ }} ). { "analyticQuery": "SELECT job, infoowners FROM WHERE infosearchableowners LIKE '{%dignissimos%}' LIMIT
3", "unitName": "{{unitName}}", "server": "{{seedNode}}", "Type": "Owners", "user": "{{user}}", "password":"{{password}}" , "showProtected" : "false" } But I get an empty result response:

 {
"results": []
 }

I have checked checked that ‘dignissimos’ is in the encrypted field My understanding of the documentation is that I can query encrypted fields (without them being decrypted) - I used the “showProtected” : “false” key here. I’ve used the ‘Owner’ type with correct username / password pairing

2

There are 2 answers

0
Simon Bain On

This is because you have a misplaced '{' curly brace. These tell the OmniIndex API that the text it surrounds is a FHE block and needs to be treated as such. You can see more details on this in the API docs Swagger By replacing

LIKE '{%dignissimos%}' LIMIT 3",

with

LIKE '%{dignissimos}%' LIMIT 3",

All should be good

0
James Stanbridge On

Looks to me like a simple typo around the cipher:

LIKE '%{dignissimos}%' LIMIT 3

It's a mistake I've made several times and while I am certain others will be able to explain better, the curly brackets are inside the percent symbols in order to search encrypted fields for ciphered contents.

Anyway, try this and you should get a result like this:

{
        "info": "Data has been redacted.",
        "job": "Dynamic Research Technician"
    },
    {
        "info": "Data has been redacted.",
        "job": "Investor Usability Facilitator"
    }

or whatever is in your data set. I note you want to do some analytics, so some script like this would return you a count of all the matches for your query (really useful against an encrypted field!)

{
"analyticQuery": "SELECT COUNT (*) FROM WHERE infosearchableowners LIKE '%{dignissimos}%' ",
"unitName": "{{unitName}}",
"server": "{{seedNode}}",
"Type": "Owners",
"user": "{{user}}",
"password":"{{password}}" ,
"showProtected" : "false"

}