Documentation ¶
Overview ¶
Package oprf provides an Oblivious Pseudo-Random Function protocol.
An Oblivious Pseudorandom Function (OPRFs) is a two-party protocol for computing the output of a PRF. One party (the server) holds the PRF secret key, and the other (the client) holds the PRF input.
Obliviousness: Ensures that the server does not learn anything about the client's input during the Evaluation step.
Verifiability: Allows the client to verify that the server used a committed secret key during Evaluation step.
OPRF is defined on draft-irtf-cfrg-voprf: https://datatracker.ietf.org/doc/draft-irtf-cfrg-voprf
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedSuite = errors.New("non-supported suite")
ErrUnsupportedSuite is thrown when requesting a non-supported suite.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a representation of a OPRF client during protocol execution.
func NewVerifiableClient ¶
NewVerifiableClient creates a client in verifiable mode. A server's public key must be provided.
func (*Client) Finalize ¶
func (c *Client) Finalize(r *ClientRequest, e *Evaluation) ([][]byte, error)
Finalize computes the signed token from the server Evaluation and returns the output of the OPRF protocol. The function uses server's public key to verify the proof in verifiable mode.
type ClientRequest ¶
type ClientRequest struct {
// contains filtered or unexported fields
}
ClientRequest is a structure to encapsulate the output of a Request call.
func (ClientRequest) BlindedElements ¶
func (r ClientRequest) BlindedElements() [][]byte
BlindedElements returns the serialized blinded elements produced for the client request.
type Evaluation ¶
type Evaluation struct { Elements []SerializedElement Proof *Proof }
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func DeriveKey ¶
func DeriveKey(id SuiteID, seed []byte) (*PrivateKey, error)
DeriveKey derives a pair of keys given a seed and in accordance with the suite.
func GenerateKey ¶
func GenerateKey(id SuiteID) (*PrivateKey, error)
GenerateKey generates a pair of keys in accordance with the suite.
func (*PrivateKey) Deserialize ¶
func (k *PrivateKey) Deserialize(id SuiteID, data []byte) error
func (*PrivateKey) Public ¶
func (k *PrivateKey) Public() *PublicKey
func (*PrivateKey) Serialize ¶
func (k *PrivateKey) Serialize() ([]byte, error)
type SerializedElement ¶
type SerializedElement = []byte
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a representation of a OPRF server during protocol execution.
func NewServer ¶
func NewServer(id SuiteID, skS *PrivateKey) (*Server, error)
NewServer creates a Server in base mode, and generates a key if no skS is provided.
func NewVerifiableServer ¶
func NewVerifiableServer(id SuiteID, skS *PrivateKey) (*Server, error)
NewVerifiableServer creates a Server in verifiable mode, and generates a key if no skS is provided.
func (*Server) Evaluate ¶
func (s *Server) Evaluate(blindedElements []Blinded) (*Evaluation, error)
Evaluate evaluates a set of blinded inputs from the client.
func (*Server) FullEvaluate ¶
FullEvaluate performs a full OPRF protocol at server-side.
func (*Server) GetPublicKey ¶
GetPublicKey returns the public key corresponding to the server.
func (*Server) VerifyFinalize ¶
VerifyFinalize performs a full OPRF protocol and returns true if the output matches the expected output.