Documentation
¶
Index ¶
- Constants
- func AuthCheck(pk *paillier.PublicKey, query *AuthenticatedEncryptedQuery, ...) bool
- func CheckAudit(auditTokens ...*AuditTokenShare) bool
- func GetOptimalDBDimentions(slotSize int, dbSize int) (int, int)
- func GetOptimalWeightedDBDimentions(slotSize int, dbSize int, weight int) (int, int)
- func GetRequiredSlotSize(data []string) int
- func PadToPowerOf2(data []string) []string
- func PadToSqrt(data []string) []string
- func RandomOracleDigest(values ...*gmp.Int) []byte
- func XorSlots(a, b *Slot)
- type AuditTokenShare
- type AuthQueryPrivateState
- type AuthTokenShare
- type AuthenticatedEncryptedQuery
- type AuthenticatedQueryShare
- type ChalToken
- type DBMetadata
- func (dbmd *DBMetadata) GetDimentionsForDatabase(height int, groupSize int) (int, int)
- func (dbmd *DBMetadata) GetSqrtOfDBSize() int
- func (dbmd *DBMetadata) IndexToCoordinates(index, width, height int) (int, int)
- func (dbmd *DBMetadata) NewAuthenticatedIndexQueryShares(index int, authKey *Slot, groupSize int, numShares uint) []*AuthenticatedQueryShare
- func (dbmd *DBMetadata) NewAuthenticatedQuery(sk *paillier.SecretKey, groupSize, index int, authKey *Slot) (*AuthenticatedEncryptedQuery, *AuthQueryPrivateState)
- func (dbmd *DBMetadata) NewDoublyEncryptedNullQuery(pk *paillier.PublicKey, groupSize int) *DoublyEncryptedQuery
- func (dbmd *DBMetadata) NewDoublyEncryptedQuery(pk *paillier.PublicKey, groupSize, index int) *DoublyEncryptedQuery
- func (dbmd *DBMetadata) NewDoublyEncryptedQueryWithDimentions(pk *paillier.PublicKey, width, height, groupSize, index int) *DoublyEncryptedQuery
- func (dbmd *DBMetadata) NewEncryptedQuery(pk *paillier.PublicKey, groupSize, index int) *EncryptedQuery
- func (dbmd *DBMetadata) NewEncryptedQueryWithDimentions(pk *paillier.PublicKey, width, height, groupSize, index int) *EncryptedQuery
- func (dbmd *DBMetadata) NewIndexQueryShares(index int, groupSize int, numShares uint) []*QueryShare
- func (dbmd *DBMetadata) NewKeywordQueryShares(keyword int, groupSize int, numShares uint) []*QueryShare
- type Database
- func (db *Database) BuildForData(data []string)
- func (db *Database) BuildForDataWithSlotSize(data []string, slotSize int)
- func (db *Database) ExpandSharedQuery(query *QueryShare, nprocs int) []bool
- func (db *Database) PrivateDoublyEncryptedQuery(query *DoublyEncryptedQuery, nprocs int) (*DoublyEncryptedQueryResult, error)
- func (db *Database) PrivateEncryptedQuery(query *EncryptedQuery, nprocs int) (*EncryptedQueryResult, error)
- func (db *Database) PrivateEncryptedQueryOverEncryptedResult(query *EncryptedQuery, result *EncryptedQueryResult, nprocs int) (*DoublyEncryptedQueryResult, error)
- func (db *Database) PrivateSecretSharedQuery(query *QueryShare, nprocs int) (*SecretSharedQueryResult, error)
- func (db *Database) PrivateSecretSharedQueryWithExpandedBits(query *QueryShare, bits []bool, nprocs int) (*SecretSharedQueryResult, error)
- func (db *Database) SetKeywords(keywords []uint)
- type DoublyEncryptedQuery
- type DoublyEncryptedQueryResult
- type DoublyEncryptedSlot
- type EncryptedQuery
- type EncryptedQueryResult
- type EncryptedSlot
- type PrivateSqrtST
- func (sqst *PrivateSqrtST) BuildForData(data []string) error
- func (sqst *PrivateSqrtST) GetSecondLayerMetadata() *DBMetadata
- func (sqst *PrivateSqrtST) PrivateEncryptedQuery(query *EncryptedQuery, nprocs int) (*EncryptedQueryResult, error)
- func (sqst *PrivateSqrtST) PrivateQuery(query *QueryShare, nprocs int) (*SecretSharedQueryResult, error)
- type ProofToken
- type QueryShare
- type ROCommitment
- type SecretSharedQueryResult
- type Slot
- func NewEmptySlot(numBytes int) *Slot
- func NewRandomSlot(numBytes int) *Slot
- func NewSlot(b []byte) *Slot
- func NewSlotFromGmpIntArray(arr []*gmp.Int, numBytes int, numBytesPerInt int) *Slot
- func NewSlotFromString(s string, slotSize int) *Slot
- func Recover(resShares []*SecretSharedQueryResult) []*Slot
- func RecoverDoublyEncrypted(res *DoublyEncryptedQueryResult, sk *paillier.SecretKey) []*Slot
- func RecoverEncrypted(res *EncryptedQueryResult, sk *paillier.SecretKey) []*Slot
Constants ¶
const BenchmarkDBHeight = 1 << 10
const BenchmarkDBSize = 1 << 20
const MaxGroupSize = 5
const MinGroupSize = 1
const NumProcsForQuery = 4 // number of parallel processors
const NumQueries = 50 // number of queries to run
const SlotBytes = 3
const SlotBytesStep = 5
const StatisticalSecurityBytes = 8 // 8 bytes of stat sec
const TestDBHeight = 1 << 5
test configuration parameters
const TestDBSize = 1 << 10
Variables ¶
This section is empty.
Functions ¶
func AuthCheck ¶
func AuthCheck(pk *paillier.PublicKey, query *AuthenticatedEncryptedQuery, chalToken *ChalToken, proofToken *ProofToken) bool
AuthCheck verifies the proof provided by the client and outputs True if and only if the proof is valid
func CheckAudit ¶
func CheckAudit(auditTokens ...*AuditTokenShare) bool
CheckAudit outputs True of all provided audit tokens xor to zero
func GetOptimalDBDimentions ¶
GetOptimalDBDimentions returns the optimal DB dimentions for PIR
func GetOptimalWeightedDBDimentions ¶
GetOptimalWeightedDBDimentions returns the optimal DB dimentions for PIR where the height of the database is weighted by weight (int) >= 1
func GetRequiredSlotSize ¶
GetRequiredSlotSize returns the minimum number of bytes required to represent each data point
func PadToPowerOf2 ¶
PadToPowerOf2 pads the data to a power of 2
func RandomOracleDigest ¶
RandomOracleDigest returns the digest of all the input bytes using SHA 256 to model a random oracle
Types ¶
type AuditTokenShare ¶
type AuditTokenShare struct {
}
AuditTokenShare is a secret share of an audit token used to authenticate two-server PIR queries
func GenerateAuditForSharedQuery ¶
func GenerateAuditForSharedQuery( keyDB *Database, query *AuthenticatedQueryShare, nprocs int) (*AuditTokenShare, error)
GenerateAuditForSharedQuery generates an audit share that is sent to the other server(s)
func GenerateAuditForSharedQueryWithExpandedBits ¶
func GenerateAuditForSharedQueryWithExpandedBits( keyDB *Database, query *AuthenticatedQueryShare, bits []bool, nprocs int) (*AuditTokenShare, error)
GenerateAuditForSharedQueryWithExpandedBits generates an audit share that is sent to the other server(s) using the expanded DPF bits provided to it
type AuthQueryPrivateState ¶
type AuthQueryPrivateState struct {
Sk *paillier.SecretKey
Bit int
AuthToken0 *paillier.Ciphertext
AuthToken1 *paillier.Ciphertext
}
AuthQueryPrivateState the client's private state
type AuthTokenShare ¶
type AuthTokenShare struct {
}
AuthTokenShare is a share of the key associated with the queried item
func NewAuthTokenSharesForKey ¶
func NewAuthTokenSharesForKey(authKey *Slot, numShares uint) []*AuthTokenShare
NewAuthTokenSharesForKey generates auth token shares for a specific AuthKey (encoded as a slot)
type AuthenticatedEncryptedQuery ¶
type AuthenticatedEncryptedQuery struct {
Query0 *DoublyEncryptedQuery
Query1 *DoublyEncryptedQuery
AuthTokenComm0 *ROCommitment
AuthTokenComm1 *ROCommitment
}
AuthenticatedEncryptedQuery is a single-server encrypted query attached with an authentication token that proves knowledge of a secret associated with the retrieved item. Either Query0 or Query1`is a "null" query that doesn't retrieve any value. It is needed to prevent the server from generating a ”tagged” key database in an attempt to learn which item is being retrieved by the client ...
type AuthenticatedQueryShare ¶
type AuthenticatedQueryShare struct {
}
AuthenticatedQueryShare contains a secret share of the auth token it doesn't need an "equivocation" query like AuthenticatedEncryptedQuery does because the verification happens between 2 or more servers
type ChalToken ¶
type ChalToken struct {
Token0 *paillier.Ciphertext
Token1 *paillier.Ciphertext
SecParam int
}
ChalToken is the challenge issued to the client in order to prove knowledge of the key associated with the retrieved item
func GenerateAuthChalForQuery ¶
func GenerateAuthChalForQuery( secparam int, keyDB *Database, query *AuthenticatedEncryptedQuery, nprocs int) (*ChalToken, error)
GenerateAuthChalForQuery generates a challenge token for the provided PIR query
type DBMetadata ¶
DBMetadata contains information on the layout and size information for a slot database type
func (*DBMetadata) GetDimentionsForDatabase ¶
func (dbmd *DBMetadata) GetDimentionsForDatabase(height int, groupSize int) (int, int)
GetDimentionsForDatabase returns the width and height given a height constraint height is the desired height of the database (number of rows) groupSize is the number of *adjacent* slots needed to constitute a "group" (default = 1)
func (*DBMetadata) GetSqrtOfDBSize ¶
func (dbmd *DBMetadata) GetSqrtOfDBSize() int
GetSqrtOfDBSize returns sqrt(DBSize) + 1
func (*DBMetadata) IndexToCoordinates ¶
func (dbmd *DBMetadata) IndexToCoordinates(index, width, height int) (int, int)
IndexToCoordinates returns the 2D coodindates for an index a PIR query should use the first value to recover the row and the second value to recover the column in the response
func (*DBMetadata) NewAuthenticatedIndexQueryShares ¶
func (dbmd *DBMetadata) NewAuthenticatedIndexQueryShares( index int, authKey *Slot, groupSize int, numShares uint) []*AuthenticatedQueryShare
NewAuthenticatedIndexQueryShares generates PIR query shares for the index
func (*DBMetadata) NewAuthenticatedQuery ¶
func (dbmd *DBMetadata) NewAuthenticatedQuery( sk *paillier.SecretKey, groupSize, index int, authKey *Slot) (*AuthenticatedEncryptedQuery, *AuthQueryPrivateState)
NewAuthenticatedQuery generates an authenticated PIR query that can be verified by the server
func (*DBMetadata) NewDoublyEncryptedNullQuery ¶
func (dbmd *DBMetadata) NewDoublyEncryptedNullQuery(pk *paillier.PublicKey, groupSize int) *DoublyEncryptedQuery
NewDoublyEncryptedNullQuery generates a PIR query that does not retrieve any value
func (*DBMetadata) NewDoublyEncryptedQuery ¶
func (dbmd *DBMetadata) NewDoublyEncryptedQuery(pk *paillier.PublicKey, groupSize, index int) *DoublyEncryptedQuery
NewDoublyEncryptedQuery generates two encrypted point function that acts as a PIR query to select the row and column in the database
func (*DBMetadata) NewDoublyEncryptedQueryWithDimentions ¶
func (dbmd *DBMetadata) NewDoublyEncryptedQueryWithDimentions(pk *paillier.PublicKey, width, height, groupSize, index int) *DoublyEncryptedQuery
NewDoublyEncryptedQueryWithDimentions generates two encrypted point function that acts as a PIR query to select the row and column in the database that is viewed as a width x height grid
func (*DBMetadata) NewEncryptedQuery ¶
func (dbmd *DBMetadata) NewEncryptedQuery(pk *paillier.PublicKey, groupSize, index int) *EncryptedQuery
NewEncryptedQuery generates a new encrypted point function that acts as a PIR query defaults to sqrt sized grid database layout
func (*DBMetadata) NewEncryptedQueryWithDimentions ¶
func (dbmd *DBMetadata) NewEncryptedQueryWithDimentions(pk *paillier.PublicKey, width, height, groupSize, index int) *EncryptedQuery
NewEncryptedQueryWithDimentions generates a new encrypted point function that acts as a PIR query where the database is viewed as a width x height grid
func (*DBMetadata) NewIndexQueryShares ¶
func (dbmd *DBMetadata) NewIndexQueryShares(index int, groupSize int, numShares uint) []*QueryShare
NewIndexQueryShares generates PIR query shares for the index
func (*DBMetadata) NewKeywordQueryShares ¶
func (dbmd *DBMetadata) NewKeywordQueryShares(keyword int, groupSize int, numShares uint) []*QueryShare
NewKeywordQueryShares generates keyword-based PIR query shares for keyword
type Database ¶
type Database struct {
DBMetadata
Slots []*Slot
Keywords []uint // set of keywords (optional)
}
Database is a set of slots arranged in a grid of size width x height where each slot has size slotBytes
func GenerateEmptyDB ¶
GenerateEmptyDB generates an empty database
func GenerateRandomDB ¶
GenerateRandomDB generates a database of slots (where each slot is of size NumBytes) the width and height parameter specify the number of rows and columns in the database
func (*Database) BuildForData ¶
BuildForData constrcuts a PIR database of slots where each string gets a slot and automatically finds the bandwidth-optimal width and height for PIR
func (*Database) BuildForDataWithSlotSize ¶
BuildForDataWithSlotSize constrcuts a PIR database of slots where each string gets a slot of the specified size
func (*Database) ExpandSharedQuery ¶
func (db *Database) ExpandSharedQuery(query *QueryShare, nprocs int) []bool
ExpandSharedQuery returns the expands the DPF and returns an array of bits
func (*Database) PrivateDoublyEncryptedQuery ¶
func (db *Database) PrivateDoublyEncryptedQuery(query *DoublyEncryptedQuery, nprocs int) (*DoublyEncryptedQueryResult, error)
PrivateDoublyEncryptedQuery executes a row PIR query and col PIR query by recursively applying PrivateEncryptedQuery
func (*Database) PrivateEncryptedQuery ¶
func (db *Database) PrivateEncryptedQuery(query *EncryptedQuery, nprocs int) (*EncryptedQueryResult, error)
PrivateEncryptedQuery uses the provided PIR query to retreive a slot row (encrypted) the tricky details are in regards to converting slot bytes to ciphertexts, specifically the encryption scheme might not have a message space large enough to accomodate all the bytes in a slot, thus requiring the bytes to be split up into several ciphertexts
func (*Database) PrivateEncryptedQueryOverEncryptedResult ¶
func (db *Database) PrivateEncryptedQueryOverEncryptedResult(query *EncryptedQuery, result *EncryptedQueryResult, nprocs int) (*DoublyEncryptedQueryResult, error)
PrivateEncryptedQueryOverEncryptedResult executes the query over an encrypted query result
func (*Database) PrivateSecretSharedQuery ¶
func (db *Database) PrivateSecretSharedQuery(query *QueryShare, nprocs int) (*SecretSharedQueryResult, error)
PrivateSecretSharedQuery uses the provided PIR query to retreive a slot row
func (*Database) PrivateSecretSharedQueryWithExpandedBits ¶
func (db *Database) PrivateSecretSharedQueryWithExpandedBits(query *QueryShare, bits []bool, nprocs int) (*SecretSharedQueryResult, error)
PrivateSecretSharedQueryWithExpandedBits returns the result without expanding the query DPF
func (*Database) SetKeywords ¶
SetKeywords set the keywords (uints) associated with each row of the database
type DoublyEncryptedQuery ¶
type DoublyEncryptedQuery struct {
Row *EncryptedQuery
Col *EncryptedQuery
}
DoublyEncryptedQuery consists of two encrypted point functions that evaluates to 1 at the desired row and column in the database
type DoublyEncryptedQueryResult ¶
type DoublyEncryptedQueryResult struct {
Slots []*DoublyEncryptedSlot
Pk *paillier.PublicKey
SlotBytes int
NumBytesPerCiphertext int
}
DoublyEncryptedQueryResult is an array of encrypted slots
type DoublyEncryptedSlot ¶
type DoublyEncryptedSlot struct {
Cts []*paillier.Ciphertext // note: level2 ciphertexts (see Paillier)
}
DoublyEncryptedSlot is an array of doubly encrypted ciphertexts which decrypt to a set of ciphertexts that then decrypt to a slot
type EncryptedQuery ¶
type EncryptedQuery struct {
Pk *paillier.PublicKey
EBits []*paillier.Ciphertext
GroupSize int
DBWidth, DBHeight int // if a specific will force these dimentiojs
}
EncryptedQuery is an encryption of a point function that evaluates to 1 at the desired row in the database bits = (0, 0,.., 1, ...0, 0)
type EncryptedQueryResult ¶
type EncryptedQueryResult struct {
Slots []*EncryptedSlot
Pk *paillier.PublicKey
SlotBytes int
NumBytesPerCiphertext int
}
EncryptedQueryResult is an array of encrypted slots
type EncryptedSlot ¶
type EncryptedSlot struct {
Cts []*paillier.Ciphertext
}
EncryptedSlot is an array of ciphertext bytes
type PrivateSqrtST ¶
type PrivateSqrtST struct {
FirstLayer []string
SecondLayer *Database
NumKeys int
SlotBytes int
Width int
Height int
}
PrivateSqrtST is a search tree structure with sqrt nodes per layer. Requires 1 PIR query to get the index First round: get FirstLayer (sqrt N boundries) Second round: PIR query (sqrt N boundries) This is optimal in when the boundries are small but PrivateBST gets better asymptotic bandwidth
func NewPrivateSqrtST ¶
func NewPrivateSqrtST() *PrivateSqrtST
NewPrivateSqrtST returns an empty PrivateBST struct
func (*PrivateSqrtST) BuildForData ¶
func (sqst *PrivateSqrtST) BuildForData(data []string) error
BuildForData first generates a PrivateSqrtST for the data and then converts one layer into a PIR database with optimal width/height
func (*PrivateSqrtST) GetSecondLayerMetadata ¶
func (sqst *PrivateSqrtST) GetSecondLayerMetadata() *DBMetadata
GetSecondLayerMetadata returns the metadata for PIR database of the second layer
func (*PrivateSqrtST) PrivateEncryptedQuery ¶
func (sqst *PrivateSqrtST) PrivateEncryptedQuery( query *EncryptedQuery, nprocs int) (*EncryptedQueryResult, error)
PrivateEncryptedQuery queries the specified layer of the BST using cPIR
func (*PrivateSqrtST) PrivateQuery ¶
func (sqst *PrivateSqrtST) PrivateQuery( query *QueryShare, nprocs int) (*SecretSharedQueryResult, error)
PrivateQuery queries the specified layer of the BST using PIR
type ProofToken ¶
type ProofToken struct {
AuthToken *paillier.Ciphertext
T *paillier.Ciphertext
P *paillier.DDLEQProof
QBit int
R *gmp.Int
S *gmp.Int
}
ProofToken is the response provided by the client to a ChalToken
func AuthProve ¶
func AuthProve(state *AuthQueryPrivateState, chalToken *ChalToken) (*ProofToken, error)
AuthProve proves that challenge token is correct (a nested encryption of zero) bit indicate which query (query0 or query1) is the real query
type QueryShare ¶
type QueryShare struct {
}
QueryShare is a secret share of a query over the database to retrieve a row
type ROCommitment ¶
ROCommitment is a hiding and binding commitment consisting of a random oracle hash of the commited value
func Commit ¶
func Commit(value *gmp.Int) *ROCommitment
Commit uses the random oracle to generate a commitment
type SecretSharedQueryResult ¶
type SecretSharedQueryResult struct {
}
SecretSharedQueryResult contains shares of the resulting slots
type Slot ¶
type Slot struct {
Data []byte
}
Slot is a set of bytes which can be xor'ed and comapred
func NewRandomSlot ¶
NewRandomSlot returns a slot filled with random bytes
func NewSlotFromGmpIntArray ¶
NewSlotFromGmpIntArray parses an array of ints into a slot type numBytes is the final size of the slot numBytesPerInt the the number of bytes to extract from each int
func NewSlotFromString ¶
NewSlotFromString converts a string to a slot type
func Recover ¶
func Recover(resShares []*SecretSharedQueryResult) []*Slot
Recover combines shares of slots to recover the data
func RecoverDoublyEncrypted ¶
func RecoverDoublyEncrypted(res *DoublyEncryptedQueryResult, sk *paillier.SecretKey) []*Slot
RecoverDoublyEncrypted decryptes the encrypted slot and returns slot
func RecoverEncrypted ¶
func RecoverEncrypted(res *EncryptedQueryResult, sk *paillier.SecretKey) []*Slot
RecoverEncrypted decryptes the encrypted slot and returns slot
func (*Slot) Compare ¶
Compare returns the comparison of the two byte arrays 0 if slot == other -1 if slot < other 1 if slot > other
func (*Slot) ToGmpIntArray ¶
ToGmpIntArray converts the slot into an array of gmp.Ints returns array of gmp.Ints, number of bytes per int