Documentation
¶
Overview ¶
Package mppj implements implements the MPPJ protocol, as proposed in the paper "Multi-party Private Join" by by Anja Lehmann, Christian Mouchet and Andrey Sidorenko, PETS 2026.
Index ¶
- Constants
- func GenTestTables(sourceIDs []PartyID, nRows, intersectionSize int) map[PartyID]TablePlain
- func GetTestKeys(seed []byte) (SecretKey, PublicKey)
- func KeyGen() (SecretKey, PublicKey)
- func SourceIDToOutgoingContext(ctx context.Context, id PartyID) context.Context
- type Ciphertext
- type ConvertRowTask
- type DataSource
- type EncRow
- type EncRowWithHint
- type EncTable
- type EncTableWithHint
- type Helper
- func (h *Helper) Convert(tables map[PartyID]EncTable) (EncTableWithHint, error)
- func (h *Helper) ConvertRow(rpk PublicKey, r *EncRow, sourceID PartyID) (*EncRowWithHint, error)
- func (h *Helper) ConvertStream(rpk PublicKey, encRowsTasks chan ConvertRowTask, goroutines ...int) (EncTableWithHint, error)
- type JoinTable
- type PartyID
- type PublicKey
- type Receiver
- type SecretKey
- type Session
- type SessionID
- type SourceList
- type SymmetricCiphertext
- type TablePlain
- type TableRow
Constants ¶
const KeySize = 16
KeySize is the size of symmetric keys in bytes.
const MaxValueSize = 30
MaxValueSize is the maximum size of the input tables' values in bytes.
Variables ¶
This section is empty.
Functions ¶
func GenTestTables ¶
func GenTestTables(sourceIDs []PartyID, nRows, intersectionSize int) map[PartyID]TablePlain
GenTestTables generates test tables for the given source IDs with specified number of rows and intersection size.
func GetTestKeys ¶
Generates keys *deterministically* from a seed
Types ¶
type Ciphertext ¶
type Ciphertext struct {
// contains filtered or unexported fields
}
Ciphertext represents an ElGamal ciphertext. c0 = g^r, c1 = m * pk^r
func DeserializeCiphertext ¶
func DeserializeCiphertext(data []byte) (*Ciphertext, error)
DeserializeCiphertext deserializes a byte slice into a Ciphertext.
func (*Ciphertext) Equals ¶
func (ct *Ciphertext) Equals(other *Ciphertext) bool
Equals checks if two Ciphertexts are equal.
func (*Ciphertext) Serialize ¶
func (ct *Ciphertext) Serialize() ([]byte, error)
Serialize serializes a Ciphertext into a byte slice.
type ConvertRowTask ¶
ConvertRowTask represents a task to convert a single encrypted row from a data source.
type DataSource ¶
type DataSource struct {
// contains filtered or unexported fields
}
DataSource represents a data source party in the MPPJ protocol, for a given session. Its main method is Prepare, which prepares a plaintext table for joining.
func NewDataSource ¶
func NewDataSource(sess *Session) *DataSource
NewDataSource creates a new DataSource for the given session.
func (*DataSource) Prepare ¶
func (s *DataSource) Prepare(table TablePlain) (EncTable, error)
Prepare prepares a table for joining by adding hashing the UIDs and encrypting its contents towards the receiver.
func (*DataSource) PrepareStream ¶
func (s *DataSource) PrepareStream(table TablePlain, goroutines ...int) (encRows <-chan EncRow, err error)
PrepareStream is the streaming version of [Prepare]. It sends encrypted rows through the encRows channel, as they are processed. It is optionally possible to specify the number of goroutines workers to use.
func (*DataSource) ProcessRow ¶
func (s *DataSource) ProcessRow(uid, val string) (cuid *Ciphertext, cval []*Ciphertext, err error)
ProcessRow processes a single row, returning the encrypted UID and encrypted value.
type EncRow ¶
type EncRow struct {
Cuid *Ciphertext
Cval []*Ciphertext
}
EncRow represents a single encrypted row with encrypted UID and encrypted value(s).
func (EncRow) MarshalBinary ¶
MarshalBinary serializes an EncRow into a byte slice.
type EncRowWithHint ¶
type EncRowWithHint struct {
Cnyme Ciphertext
CVal SymmetricCiphertext
CValKey Ciphertext
CHint Ciphertext
}
EncRowWithHint represents a single encrypted row after processing by the helper.
type EncTable ¶
type EncTable []EncRow
EncTable represents an encrypted table as a slice of encrypted rows. It is the output type for the data source and the input type for the helper.
type EncTableWithHint ¶
type EncTableWithHint []EncRowWithHint
EncTableWithHint represents an encrypted table after processing by the helper. It is the output type for the helper and the input type for the receiver.
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper represents a helper party in the MPPJ protocol, for a given session. Its main method is Convert, which converts encrypted tables from data sources into a format suitable for joining by the receiver.
func (*Helper) Convert ¶
func (h *Helper) Convert(tables map[PartyID]EncTable) (EncTableWithHint, error)
Convert converts the encrypted tables from data sources into a format suitable for joining by the receiver.
func (*Helper) ConvertRow ¶
ConvertRow converts a single row `r` received from datasource sourceID.
func (*Helper) ConvertStream ¶
func (h *Helper) ConvertStream(rpk PublicKey, encRowsTasks chan ConvertRowTask, goroutines ...int) (EncTableWithHint, error)
ConvertStream is the streaming version of [Convert]. It reads encrypted rows from the encRowsTasks channel, processes them, and returns the converted table when all the rows have been processed. It is optionally possible to specify the number of goroutines workers to use.
type JoinTable ¶
type JoinTable struct {
// contains filtered or unexported fields
}
JoinTable represents the final joined table produced by the receiver. It is the output type for the receiver.
func IntersectPlain ¶
func IntersectPlain(tables map[PartyID]TablePlain, sources []PartyID) JoinTable
IntersectPlain performs a join on plain tables
func NewJoinTable ¶
NewJoinTable creates a new empty JoinTable for the given source IDs.
func (*JoinTable) EqualContents ¶
EqualContents checks only the contents of the joined tables, ignoring the order of rows.
func (*JoinTable) Insert ¶
Insert adds a new row to the joined table with the given values mapped by source ID.
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver represents the receiver party in the MPPJ protocol, for a given session. Its main method is JoinTables, which joins the converted encrypted tables from the helper.
func NewReceiver ¶
NewReceiver creates a new receiver for the given session.
func (*Receiver) JoinTables ¶
func (r *Receiver) JoinTables(joinedTables EncTableWithHint) (JoinTable, error)
JoinTables extracts the intersection from the joined tables received from the helper.
func (*Receiver) JoinTablesStream ¶
func (r *Receiver) JoinTablesStream(in chan EncRowWithHint, goroutines ...int) (JoinTable, error)
JoinTablesStream is the streaming version of [JoinTables]. It reads encrypted rows from the in channel, processes them, and returns the joined table when all the rows have been processed. It is optionally possible to specify the number of goroutines workers to use.
type Session ¶
type SessionID ¶
type SessionID []byte
func NewSessionID ¶
NewSessionID generates a new session ID based on session participants and randomness.
type SourceList ¶
type SourceList []PartyID
func (*SourceList) Set ¶
func (s *SourceList) Set(value string) error
func (*SourceList) String ¶
func (s *SourceList) String() string
type SymmetricCiphertext ¶
type SymmetricCiphertext []byte
type TablePlain ¶
TablePlain represents a plain table with UID as key and value as string. It is the protocol input type for data sources.
func GenTestTable ¶
func GenTestTable(sourceId PartyID, nRows int, intersection []string) TablePlain
GenTestTable generates a test table for a given source ID with specified number of rows and intersection UIDs.
func NewTablePlain ¶
func NewTablePlain(uids []string, values []string) TablePlain
NewTablePlain creates a new Table from a UID list and optional values.
func (*TablePlain) Equal ¶
func (t1 *TablePlain) Equal(t2 *TablePlain) bool
Equal checks both the keys and the values for plain tables.
func (TablePlain) String ¶
func (t TablePlain) String() string
String returns the plain table as a formatted string.