pair

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

Publisher Advertiser Identity Reconciliation (PAIR)

Overview

Publisher Advertiser Identity Reconciliation (PAIR) [1] is a privacy-centric protocol that leverages commutative encryptions like the Diffie-Hellman PSI to reconcile the first party identitfiers of the publisher and the advertiser, and allows a secure programmatic activation for the advertiser following a PAIR match.

This package provides a reference implementation of core utility functions required to run the PAIR protocol.

Protocol

The PAIR protocol in the dual clean room scenario involves two clean room operators, one responsible for the publisher and the other for the advertiser. The protocol consists of the following steps:

Key generation and management
  1. the publisher clean room operator Pub and the advertiser clean room operator Adv agree on a hashing function (SHA256) and a preset elliptic curve (Curve25519).
  2. Pub generates a random hash salt s, and a private key (scalar) p, and rotates them periodically. s is rotated every 30 days, and p is rotated every 180 days.
  3. Adv generates a private key (scalar) a, and rotates it every 180 days.
offline matching
  1. Pub shares the hash salt s with Adv.
  2. Pub hashes each identifier xi ∈ X from his input audience list X and encrypts the hashed identifiers using p to obtain Ep(Hs(xi)), which is also known as the Publisher ID.
  3. Adv hashes each identifier yi ∈ Y from his input audience list Y and encrypts the hashed identifiers using a to obtain Ea(Hs(yi)), which is also known as the Advertiser ID.
  4. Pub and Adv exchange the Publisher IDs and Advertiser IDs respectively.
  5. Pub encrypts the Advertiser IDs using p to obtain Ep(Ea(Hs(yi))), the doubly encrypted and hashed identifier is known as the PAIR ID.
  6. Adv encrypts the Publisher IDs using a to obtain Ea(Ep(Hs(xi))), which is known as the PAIR ID.
  7. Pub and Adv exchange the PAIR IDs respectively.
  8. Pub intersects the PAIR IDs to obtain the match rate, and output a table containing his un-encrypted identitifiers xi and its Publisher ID counter part Ep(Hs(xi)).
  9. Adv intersects the PAIR IDs to obtain the match rate, and the intersected PAIR IDs. Adv decrypts the PAIR IDs using a to obtain the intersected Publisher IDs Ep(Hs(yi)).
online activation
  1. Adv sends the intersected Publisher IDs to his Demand Side Platform (DSP) for activation.
  2. Pub keeps the mapping of his identifier xi and the Publisher ID Ep(Hs(xi)).
  3. When a user visits the publisher's website, the publisher looks up the Publisher ID of the visitor and prepares an OpenRTB bid request containing the Publisher ID to his Sell Side Platform (SSP).
  4. The SSP sends the bid request to the DSP.
  5. The DSP looks up the Publisher ID in the list of intersected Publisher ID sent by Adv and decides the outcome of the bid request.

References

[1] TBD.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPAIRMode = errors.New("invalid PAIR mode")
	ErrInvalidSaltSize = errors.New("invalid hash salt size")
)

Functions

func Shuffle

func Shuffle(data [][]byte)

Shuffle shuffles the data in place by using the Fisher-Yates algorithm. Note that ideally, it should be called with less than 2^32-1 (4 billion) elements.

Types

type PAIRMode

type PAIRMode uint8
const (
	// PAIRSHA256Ristretto255 is PAIR with SHA256 as hash function and Ristretto255 as the group.
	PAIRSHA256Ristretto255 PAIRMode = 0x01
)

func (PAIRMode) New

func (p PAIRMode) New(salt []byte, scalar []byte) (*PrivateKey, error)

New instantiates a new private key with the given salt and scalar. It expects the scalar to be base64 encoded.

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

PrivateKey represents a PAIR private key.

func (*PrivateKey) Decrypt

func (pk *PrivateKey) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt undoes the encryption using the private key once, and returns the element of the group.

func (*PrivateKey) Encrypt

func (pk *PrivateKey) Encrypt(data []byte) ([]byte, error)

Encrypt first hashes the data with a salted hash function, it then derives the hashed data to an element of the group and encrypts it using the private key.

func (*PrivateKey) ReEncrypt

func (pk *PrivateKey) ReEncrypt(ciphertext []byte) ([]byte, error)

ReEncrypt re-encrypts the ciphertext using the same private key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL