microsoft / SealPIR

Example implementation of the SealPIR protocol
MIT License
139 stars 54 forks source link

About the type of the retrieved item #17

Closed Nakamotto closed 2 years ago

Nakamotto commented 2 years ago

Is it possible to retrieve the matrix instead of the number? :) Thanks for your time in advance!

sga001 commented 2 years ago

What do you mean by "return the matrix"?

Suppose we have 4 elements: A, B, C, D. By elements I mean BFV plaintexts. You can pack many small data types (e.g., 32-bit integers) into a single BFV plaintext.

When d = 1, the database is structured as:

A
B
C
D

When you issue a query for index 0, you'll get A. For index 1, you'll get B.

When d = 2, the database is structured as:

A    B
C    D

When you query for 0, you'll get A. For index 1, you'll get B (if I recall correctly).

Alternatively, if you have very large data types (e.g., a giant file) then you'll need to break up your giant file into multiple elements. File A becomes A1, A2, A3, A4. File B becomes B1, B2, B3, B4, etc.

So you might want a database that for d = 1 looks like:

A1 A2 A3 B4
B1 B2 B3 B4
C1 C2 C3 C4
D1 D2 D3 D4

Are you asking how to get all of row 0, for example?

I'll need to check if we implemented this nicely. If not, then one simple trick is to create 4 databases: one for the 1 chunk, another for the 2 chunks, another for the 3 chunks, and another for the 4 chunks.

Then you reuse the same query on all 4 databases.

If you don't mind getting your hands dirty with some code you can even reuse the same expanded query so that each database is not expanding the query (saving some work). You can also run all 4 queries in parallel.

Nakamotto commented 2 years ago

Thanks, I acctually get your point. I am curious if sealpir can be used to retrieve an (gray) image from a collection of different-size (gray) images, the database is structed as follows (M1, M2, M3, M4) whose element is not a number but a large interger-matrix(maybe inpractical to creat chunks), namely an image. That's why i ask if pir can be used to retrieve a matrix. :)