dcnet

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

F is the field prime 2**127 - 1.

Functions

func AddVectors

func AddVectors(vs ...[]*big.Int) []*big.Int

AddVectors sums each vector element over F, returning a new vector. When peers are honest (DC-mix pads sum to zero) this creates the unpadded vector of message power sums.

func Coefficients

func Coefficients(S []*big.Int) []*big.Int

Coefficients calculates a{0}..a{n} for the polynomial:

g(x) = a{0} + a{1}x + a{2}x**2 + ... + a{n-1}x**(n-1) + a{n}x**n  (mod F)

where

a{n}   = -1
a{n-1} = -(1/1) *    a{n}*S{0}
a{n-2} = -(1/2) * (a{n-1}*S{0} +   a{n}*S{1})
a{n-3} = -(1/3) * (a{n-2}*S{0} + a{n-1}*S{1} + a{n}*S{2})
...

The roots of this polynomial are the set of recovered messages.

Note that the returned slice of coefficients is one element larger than the slice of partial sums.

func InField

func InField(x *big.Int) bool

InField returns whether x is bounded by the field F.

func IsRoot

func IsRoot(m *big.Int, a []*big.Int) bool

IsRoot checks that the message m is a root of the polynomial with coefficients a (mod F) without solving for every root.

func SRMix

func SRMix(m *big.Int, pads []*big.Int) []*big.Int

SRMix creates the padded {m**1, m**2, ..., m**n} message exponentials vector. Message must be bounded by the field prime and must be unique to every exponential SR run in a mix session to ensure anonymity.

func SRMixPads

func SRMixPads(kp [][]byte, my int) []*big.Int

SRMixPads creates a vector of exponential DC-net pads from a vector of shared secrets with each participating peer in the DC-net.

func SharedKeys

func SharedKeys(secrets []*x25519.KX, publics []*x25519.Public, sid []byte, msize, run, start, mcount int) (sr [][][]byte, dc [][]*Vec)

SharedKeys creates the SR and DC shared secret keys for mcount mixes, where indexes [start, start+mcount) are a peer's pre-assigned non-anonymous positions.

Types

type Vec

type Vec struct {
	N     int
	Msize int
	Data  []byte
}

Vec is a N-element vector of Msize []byte messages.

func DCMix

func DCMix(pads *Vec, m []byte, slot int) *Vec

DCMix creates the DC-net vector of message m xor'd into m's reserved anonymous slot position of the pads DC-net pads. Panics if len(m) is not the vector's message size.

func DCMixPads

func DCMixPads(kp []*Vec, msize, my int) *Vec

DCMixPads creates the vector of DC-net pads from shared secrets with each mix participant.

func NewVec

func NewVec(n, msize int) *Vec

NewVec returns a zero vector for holding n messages of msize length.

func XorVectors

func XorVectors(vs []*Vec) *Vec

XorVectors calculates the xor of all vectors. Panics if vectors do not share identical dimensions.

func (*Vec) Equals

func (v *Vec) Equals(other *Vec) bool

Equals returns whether the two vectors have equal dimensions and data.

func (*Vec) IsDim

func (v *Vec) IsDim(n, msize int) bool

IsDim returns whether the Vec has dimensions n-by-msize.

func (*Vec) M

func (v *Vec) M(i int) []byte

M returns the i'th message of the vector.

func (*Vec) String

func (v *Vec) String() string

func (*Vec) Xor

func (v *Vec) Xor(src1, src2 *Vec)

Xor writes the xor of each vector element of src1 and src2 into v. Source and destination vectors are allowed to be equal. Panics if vectors do not share identical dimensions.

Jump to

Keyboard shortcuts

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