bb84

package
v0.0.0-...-a5cfb8a Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package bb84 provides utilities for negotiating a shared secret using the BB84 protocol.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultMeasurementBatchBytes = 1 << 14
	DefaultMainBlockSize         = int(1e5)
	DefaultTestBlockSize         = int(1e5)
	DefaultEpsilon               = 1e-12
)

Functions

This section is empty.

Types

type Peer

type Peer interface {
	// NegotiateKey performs one round of BB84 key exchange, including
	// "post-processing" steps, e.g.  error correction and privacy
	// amplification.
	NegotiateKey() (bitmap.Dense, Stats, error)
}

TODO: make Peer embed io.Reader, expose Stats via a secondary method, and make bitmap an internal lib. A Peer represents one of the two legitimate participants in a BB84 key exchange.

func NewPeer

func NewPeer(opts PeerOpts) (Peer, error)

NewPeer returns a new Peer, configured in accordance with opts, or an error if the options are nonsensical.

type PeerOpts

type PeerOpts struct {
	// Sender/Receiver handles photon transmission. Exactly one must be non-nil.
	Sender   photon.Sender
	Receiver photon.Receiver

	// ClassicalChannel provides a channel for classical communications. Must be
	// non-nil.
	ClassicalChannel io.ReadWriter

	// Rand provides a source of randomness, e.g. for salting hashes. This may
	// reasonably use pRNG for experimental and/or testing purposes, but for
	// unconditional security it should be truly random. Must be non-nil.
	Rand *rand.Rand

	// Secret provides a bootstrap secret shared between Alice and Bob for
	// authentication. Must be non-nil.
	Secret io.Reader

	// MeasurementBatchBytes specifies the number of bytes worth of qubit
	// measurements to batch together before performing a basis announcement.
	//
	// Defaults to DefaultMeasurementBatchBytes.
	MeasurementBatchBytes int

	// MainBlockSize specifies the minimum number of qubit measurements in the
	// "main" basis to accumulate before moving on to error correction, privacy
	// amplificiation, etc.
	//
	// Defaults to DefaultMainBlockSize.
	MainBlockSize int

	// TestBlockSize specifies the minimum number of qubit measurements in the
	// "test" basis to accumulate beforem oving on to error correction, privacy
	// amplificiation, etc.
	//
	// Defaults to DefaultTestBlockSize.
	TestBlockSize int

	// EpsilonAuth specifies the probability that we are willing to accept that
	// Eve can forge a message. Each classical message exchanged spends
	// log_2(1/EpsilonAuth) bits of Secret, rounded up to the nearest byte.
	//
	// Defaults to DefaultEpsilon.
	EpsilonAuth float64

	// EpsilonCorrect specifies the maximum acceptable probability that Alice
	// and Bob wind up with different secrets at the end of key negotiation.
	//
	// Defaults to DefaultEpsilon.
	EpsilonCorrect float64

	// EpsilonPrivacy specifies the statistical distance from uniform we are willing
	// to tolerate our final extracted key being, conditioned on the information made
	// available during the public phases of the protocol.
	//
	// Defaults to DefaultEpsilon.
	EpsilonPrivacy float64

	// PulseAttrs provide information about the attenuated laser pulses used to
	// carry information between Alice and Bob. Must be provided.
	PulseAttrs PulseAttrs

	// WinnowOpts provides options for using Winnow (see
	// https://arxiv.org/abs/quant-ph/0203096) for error correction. Non-nil iff
	// using Winnow for information reconciliation.
	WinnowOpts *WinnowOpts
}

A PeerOpts packages together the arguments necessary to construct a new Peer. Many of the fields of a PeerOpts do *not* have reasonable defaults, and leaving those fields to zero-initialize will result in NewPeer returning an error.

type PulseAttrs

type PulseAttrs struct {
	// MuLo, MuMed, and MuHi specify the mean photons per pulse of the low,
	// medium, and high intensity pulse states, respectively. It is required
	// that:
	//
	// (0 <= MuLo < MuMed < MuHi) and (MuLo + MuMed < MuHi)
	MuLo, MuMed, MuHi float64

	// ProbLo, ProbMed, and ProbHi describe the underlying probability that any
	// given pulse will be prepared at low, medium, or high intensities. It is
	// required that the three of them sum to one.
	ProbLo, ProbMed, ProbHi float64
}

PulseAttrs provide information about the attenuated laser pulses used to carry information between Alice and Bob. We assume a decoy-state setup with three total states.

type Stats

type Stats struct {
	Pulses           int
	QBits            int
	QBER             float64
	MessagesSent     int
	MessagesReceived int
	BytesRead        int
	BytesSent        int
}

Stats packages together a collection of potentially interesting metrics pertaining to a BB84 key negotiation.

type WinnowOpts

type WinnowOpts struct {
	// SyncRand provides a *synchronized* randomness source between Alice and
	// Bob. This source is only used to de-correlate error positions in the
	// shared secret and may operate on pRNG. Must be non-nil.
	SyncRand *rand.Rand

	// Iters specifies the sequence of hamming bit counts to use during
	// winnowing. E.g.  a sequence {3,3,4} performs two rounds of winnowing with
	// 8-bit code blocks, followed by one with 16-bit code blocks.
	Iters []int
}

A WinnowOpts packages together the parameters necessary for the Winnow error correction scheme (see https://arxiv.org/abs/quant-ph/0203096).

Directories

Path Synopsis
Package bitmap provides utilities for operating on densely-packed arrays of booleans.
Package bitmap provides utilities for operating on densely-packed arrays of booleans.
Package photon provides utilities for handling photon-encoded qubits.
Package photon provides utilities for handling photon-encoded qubits.

Jump to

Keyboard shortcuts

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