debias

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

README

Debias

Go Reference

Debiasing implementations for randomness extraction from binary data.

Algorithms

This repository contains a Go implementation of the Von Neumann debiasing algorithm and extension from Dan Kaminsky.

Von Neumann Debiasing
Kaminsky Debiasing

API

See the docs for an API description.

Test

$ go test .

Documentation

Index

Constants

View Source
const (
	ModeVonNeumann = 0
	ModeKaminsky   = 1
)

Variables

View Source
var MaxChunkSize = 1024

Functions

func Kaminsky

func Kaminsky(reader io.ByteReader, wait bool, blockSize int64) (*io.PipeReader, context.Context, context.CancelFunc)

The Von Neumann Debiasing algorithm works on pairs of bits, and produces output as follows: - If the input is "00" or "11", the input is discarded (no output). - If the input is "10", output a "1". - If the input is "01", output a "0".

Kaminsky addition: - collect discarded bytes - use discarded bytes as input for SHA512 - use the SHA512 hash as key for encrypting the output data with AES

func ShannonEntropy added in v0.2.0

func ShannonEntropy(data []byte) int

func VonNeumann

func VonNeumann(reader io.ByteReader, wait bool) (*io.PipeReader, context.Context, context.CancelFunc)

The Von Neumann Debiasing algorithm works on pairs of bits, and produces output as follows: - If the input is "00" or "11", the input is discarded (no output). - If the input is "10", output a "1". - If the input is "01", output a "0".

Types

type Mode

type Mode int

type Stats added in v0.1.0

type Stats struct {
	FileName string
	BytesIn  int64
	BytesOut int64
	Duration time.Duration
}

func Directory

func Directory(path string, ext string, mode Mode) []*Stats

Directory will debias all files in the given directory and only for files that have the given extension.

func File

func File(path string, file string, finfo fs.FileInfo, mode Mode) *Stats

File will debias a file using the chosen method

Jump to

Keyboard shortcuts

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