dcnet

package
v2.0.0-...-6df3d38 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: ISC Imports: 10 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(kx *KX, ecdhPubs []*x25519.Public, cts []*PQCiphertext, sid []byte, msize, run, myvk int, mcounts []int) (sr [][][]byte, dc [][]*Vec, err error)

SharedKeys creates the pairwise SR and DC shared secret keys for mcounts[myvk] mixes. ecdhPubs, cts, and mcounts must all share the same slice length.

Types

type KX

type KX struct {
	X25519       *x25519.KX
	PQPublic     *[sntrup4591761.PublicKeySize]byte
	PQSecret     *[sntrup4591761.PrivateKeySize]byte
	PQCleartexts []*[sntrup4591761.SharedKeySize]byte
}

KX contains the client public and secret keys to perform shared key exchange with other peers.

func NewKX

func NewKX(prng io.Reader) (*KX, error)

NewKX generates X25519 and Sntrup4591761 public and secret keys from a PRNG.

func (*KX) Encapsulate

func (kx *KX) Encapsulate(prng io.Reader, pubkeys []*PQPublicKey, my int) ([]*PQCiphertext, error)

Encapsulate performs encapsulation for sntrup4591761 key exchanges with each other peer in the DC-net. It populates the PQCleartexts field of kx and return encrypted cyphertexts of these shared keys.

Encapsulation in the DC-net requires randomness from a CSPRNG seeded by a committed secret; blame assignment is not possible otherwise.

type PQCiphertext

type PQCiphertext = [sntrup4591761.CiphertextSize]byte

Aliases for sntrup4591761 types

type PQPublicKey

type PQPublicKey = [sntrup4591761.PublicKeySize]byte

Aliases for sntrup4591761 types

type PQSecretKey

type PQSecretKey = [sntrup4591761.PrivateKeySize]byte

Aliases for sntrup4591761 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