Documentation ¶
Index ¶
Constants ¶
const ( // EncodedLen is the length of an encoded ristretto point EncodedLen = 32 // EmailPrefixedLen is the length of a prefixed email identifier EmailPrefixedLen = 66 )
const ( RistrettoTypeGR = iota RistrettoTypeR255 RistrettoNil )
Variables ¶
var (
ErrUnexpectedPoint = fmt.Errorf("received a point to encode past the configured encoder size")
)
Functions ¶
This section is empty.
Types ¶
type DeriveMultiplyParallelShuffler ¶
type DeriveMultiplyParallelShuffler struct {
// contains filtered or unexported fields
}
DeriveMultiplyParallelShuffler contains the necessary machineries to derive identifiers into ristretto point multiply them with secret key and permute them, all in a parallel fashion.
func NewDeriveMultiplyParallelShuffler ¶
func NewDeriveMultiplyParallelShuffler(w io.Writer, n int64, gr Ristretto) (*DeriveMultiplyParallelShuffler, error)
NewDeriveMultiplyParallelShuffler returns a dhpsi encoder that hashes, encrypts and shuffles matchable values on n sequences of bytes to be sent out. It first computes a permutation table and subsequently sends out sequences ordered by the precomputed permutation table. This is the first stage of doing a DH exchange.
This version operates on multiple cores in parallel
func (*DeriveMultiplyParallelShuffler) Permutations ¶
func (enc *DeriveMultiplyParallelShuffler) Permutations() permutations.Permutations
Permutations returns the permutation matrix that was computed on initialization
func (*DeriveMultiplyParallelShuffler) Shuffle ¶
func (enc *DeriveMultiplyParallelShuffler) Shuffle(identifier []byte) (err error)
Shuffle shuffles one prefixed ID. First derive and then multiply by the precomputed scaler, written out to the underlying writer while following the order of permutations created at NewDeriveMultiplyShuffler. Returns ErrUnexpectedEncodeByte when the whole expected sequence has been sent.
type DeriveMultiplyShuffler ¶
type DeriveMultiplyShuffler struct {
// contains filtered or unexported fields
}
DeriveMultiplyShuffler contains the necessary machineries to derive identifiers into ristretto point, multiply them with secret key and permute them.
func NewDeriveMultiplyShuffler ¶
NewDeriveMultiplyShuffler returns a dhpsi encoder that hashes, encrypts and shuffles matchable values on n sequences of bytes to be sent out. It first computes a permutation table and subsequently sends out sequences ordered by the precomputed permutation table. This is the first stage of doing a DH exchange.
func (*DeriveMultiplyShuffler) Permutations ¶
func (enc *DeriveMultiplyShuffler) Permutations() permutations.Permutations
Permutations returns the permutation matrix that was computed on initialization
func (*DeriveMultiplyShuffler) Shuffle ¶
func (enc *DeriveMultiplyShuffler) Shuffle(identifier []byte) (err error)
Shuffle shuffles one identifier. First derive and then multiply by the precomputed scalar, then write out to the underlying writer while following the order of permutations created at NewDeriveMultiplyShuffler. Returns ErrUnexpectedPoint when the whole expected sequence has been sent.
type GR ¶
type GR struct {
// contains filtered or unexported fields
}
GR uses ristretto implementation from "github.com/bwesterb/go-ristretto"
func (GR) DeriveMultiply ¶
func (g GR) DeriveMultiply(dst *[EncodedLen]byte, src []byte)
DeriveMultiply derives src to a ristretto point and multiplies it with the private key and stores it into dst.
func (GR) Multiply ¶
func (g GR) Multiply(dst *[EncodedLen]byte, src [EncodedLen]byte)
Multiply multiplies src with private key and stores it into dst.
type MultiplyParallelReader ¶
type MultiplyParallelReader struct {
// contains filtered or unexported fields
}
A MultiplyParallelReader is a reader that sits on the other end of a DeriveMultiplyShuffler or a Writer and reads encoded ristretto hashes and multiplies them using gr.
func NewMultiplyParallelReader ¶
func NewMultiplyParallelReader(r io.Reader, gr Ristretto) (*MultiplyParallelReader, error)
NewMultiplyParallelReader makes a ristretto multiplier reader that sits on the other end of the DeriveMultiplyShuffler or the Writer and reads encoded ristretto hashes and multiplies them using gr.
This version operates on multiple cores in parallel
func (*MultiplyParallelReader) Max ¶
func (dec *MultiplyParallelReader) Max() int64
Max returns the expected number of matchable this decoder will receive
func (*MultiplyParallelReader) Read ¶
func (dec *MultiplyParallelReader) Read(point *[EncodedLen]byte) (err error)
Read reads a point from the underlying reader, multiplies it with ristretto and writes it into point. Returns io.EOF when the sequence has been completely read.
type MultiplyReader ¶
type MultiplyReader struct {
// contains filtered or unexported fields
}
func NewMultiplyReader ¶
func NewMultiplyReader(r io.Reader, gr Ristretto) (*MultiplyReader, error)
NewMultiplyReader makes a ristretto multiplier reader that sits on the other end of the DeriveMultiplyShuffler or the Writer and reads encoded ristretto hashes and multiplies them using gr.
func (*MultiplyReader) Max ¶
func (r *MultiplyReader) Max() int64
Max returns the expected number of matchable this decoder will receive
func (*MultiplyReader) Read ¶
func (r *MultiplyReader) Read(point *[EncodedLen]byte) (err error)
Read reads a point from the underlying reader, multiplies it with ristretto and writes it into point. Returns io.EOF when the sequence has been completely read.
type R255 ¶
type R255 struct {
// contains filtered or unexported fields
}
R255 uses ristretto implementation from "github.com/gtank/ristretto255"
func (R255) DeriveMultiply ¶
func (r R255) DeriveMultiply(dst *[EncodedLen]byte, src []byte)
DeriveMultiply derives src to a ristretto point and multiplies it with the private key and stores it into dst.
func (R255) Multiply ¶
func (r R255) Multiply(dst *[EncodedLen]byte, src [EncodedLen]byte)
Multiply multiplies src with private key and stores it into dst.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func NewReader ¶
NewReader makes a simple reader that sits on the other end of the DeriveMultiplyShuffler or the Writer and reads encoded ristretto points
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver represents the receiver in a DHPSI operation, often the publisher. The receiver learns the intersection of matchable between its set and the set of the sender
func NewReceiver ¶
func NewReceiver(rw io.ReadWriter) *Receiver
NewReceiver returns a receiver initialized to use rw as the communication layer
type Ristretto ¶
type Ristretto interface { DeriveMultiply(dst *[EncodedLen]byte, src []byte) Multiply(dst *[EncodedLen]byte, src [EncodedLen]byte) }
Ristretto represents a ristretto point on an edward2559 curve.
The method DeriveMultiply converts an identifier to a ristretto point and multiply it with the secret key. Multiply operates on ristretto point directly and multiply it with the secret key.
func NewRistretto ¶
NewRistretto returns a new Ristretto of a given ristretto implementation.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender represents the sender in a DHPSI operation, often the advertiser. The sender initiates the transfer and in the case of DHPSI, it learns nothing.
func NewSender ¶
func NewSender(rw io.ReadWriter) *Sender
NewSender returns a sender initialized to use rw as the communication layer
func (*Sender) Send ¶
Send initiates a DHPSI exchange with n identifiers that are read from the identifiers channel, until identifiers closes or n is reached. The format of an indentifier is string example:
0e1f461bbefa6e07cc2ef06b9ee1ed25101e24d4345af266ed2f5a58bcd26c5e
func (*Sender) SendFromReader ¶
SendFromReader initiates a DHPSI exchange with n identifiers that are read from r. The format of an indentifier is
string\n
example:
0e1f461bbefa6e07cc2ef06b9ee1ed25101e24d4345af266ed2f5a58bcd26c5e\r\n