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 ¶
- Variables
- func GetSizes(id SuiteID) (s struct{ ... }, err error)
- type Blind
- type Blinded
- type Client
- type ClientRequest
- type Evaluation
- type Mode
- type PrivateKey
- type Proof
- type PublicKey
- type SerializedElement
- type SerializedScalar
- type Server
- func (s *Server) Evaluate(blindedElements []Blinded, info []byte) (*Evaluation, error)
- func (s *Server) FullEvaluate(input, info []byte) ([]byte, error)
- func (s *Server) GetMode() Mode
- func (s *Server) GetPublicKey() *PublicKey
- func (s *Server) VerifyFinalize(input, info, expectedOutput []byte) bool
- type SuiteID
- type UnBlinded
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedSuite = errors.New("non-supported suite")
ErrUnsupportedSuite is thrown when requesting a non-supported suite.
Functions ¶
func GetSizes ¶
func GetSizes(id SuiteID) ( s struct { SerializedElementLength uint // Size in bytes of a serialized element. SerializedScalarLength uint // Size in bytes of a serialized scalar. OutputLength uint // Size in bytes of OPRF's output. }, err error, )
GetSizes returns the size in bytes of a SerializedElement, SerializedScalar, and the length of the OPRF's output protocol.
Types ¶
type Blinded ¶
type Blinded = SerializedElement
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, info []byte) ([][]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, mode Mode, seed []byte) (*PrivateKey, error)
DeriveKey derives a pair of keys given a seed and in accordance with the suite and mode.
func GenerateKey ¶
func GenerateKey(id SuiteID, rnd io.Reader) (*PrivateKey, error)
GenerateKey generates a pair of keys in accordance with the suite. Panics if rnd is nil.
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 Proof ¶
type Proof struct {
C, S SerializedScalar
}
type SerializedElement ¶
type SerializedElement = []byte
type SerializedScalar ¶
type SerializedScalar = []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, info []byte) (*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.
type UnBlinded ¶
type UnBlinded = SerializedElement