fuzzycrypto

package module
v0.0.0-...-1c1bc02 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: MIT Imports: 12 Imported by: 0

README

fuzzycrypto

⚠️ DO NOT USE THIS LIBRARY IN PRODUCTION LEVEL CODE ⚠️

Fuzzy Message Detection Schemes

This repository contains research code for benchmarking the FMD2 and FracFMD schemes as described in Fuzzy Message Detection. This paper introduces a new cryptographic primitive known as a fuzzy message detection scheme (FMD). FMD is a tool that facilitates receiver anonymity in store-and-forward messaging systems where a single party or small collection of parties aggregates messages for a large number of users. Using the key generation algorithm of the FMD scheme, a receiver can publish a public key to allow senders to address a message to them. At a later point in time the receiver can then outsource detection of messages to a third party by extracting a "faulty" key from their secret key and handing it off to the server. The server then uses this key to test if a message was meant for the receiver. The faulty key (called a detection key in the paper) has associated with it some false positive rate p so that each message not intended for the receiver has some chance of being forward to the receiver. FMD security requires that to the server a true and false positive are indistinguishable from one another.

Notes on Repo

The interface for FMD is defined in scheme.go. The package toygarble contains code to garble a circuit provided in Bristol format. The directory c2c-converter contains files related to the CBMCGCC compiler which can take in C programs and output Boolean circuits. They also provide the ability to output files in Bristol (which we make use of).

It should go without saying that as research code this is untested, does not necessarily have any protection against side channel attacks, does not handle errors gracefully, is unoptimized, has copy pasta, etc, etc.

Other implementations of FMD2 in particular can be found at the following locations:


To run the benchmarks:

go test -bench=.

For FMD2 the benchmarks specify a 24 bit ciphertext, and perform extraction/testing at N=5, N=10, N=15. These parameters can be changed by changing the relevant test files.

Documentation

Index

Constants

View Source
const SECURITYPARAM int = 40

kappa (statistical param)

Variables

View Source
var CIRCUITFILES []string = []string{"48Num8Mod.circ", "64Num24Mod.circ"}

Functions

This section is empty.

Types

type Ciphertext

type Ciphertext struct {
	U      GroupElement
	BitVec []byte
	Y      *big.Int
}

type ElGamalPower2

type ElGamalPower2 struct {
}

func (*ElGamalPower2) Extract

func (el *ElGamalPower2) Extract(numKeys int, priv *SecKey) (dsk *SecKey)

Extract a dsk from a secret key. In practice this just involves making a copy of the same structure, but it contains only a subset of the private keys.

func (*ElGamalPower2) Flag

func (el *ElGamalPower2) Flag(curve elliptic.Curve, rand io.Reader, pk *PubKey) []byte

Encrypt a ciphertext

func (*ElGamalPower2) JsonifySK

func (el *ElGamalPower2) JsonifySK(sk *SecKey) []byte

func (*ElGamalPower2) KeyGen

func (el *ElGamalPower2) KeyGen(curve elliptic.Curve, numKeys int, rand io.Reader) (priv *SecKey, pub *PubKey)

Generate a full keypair for an n-bit ciphertext

func (*ElGamalPower2) MarshalSK

func (el *ElGamalPower2) MarshalSK(fname string) *SecKey

func (*ElGamalPower2) Test

func (el *ElGamalPower2) Test(curve elliptic.Curve, ctBytes []byte, priv *SecKey) bool

Test a ciphertext given a dsk, and return true/false. Note that if the number of subkeys in dsk is 0, this will always return "true".

func (*ElGamalPower2) TheoreticalFlag

func (el *ElGamalPower2) TheoreticalFlag(curve elliptic.Curve, rand io.Reader, pk *PubKey) *Ciphertext

Encrypt a ciphertext

type Fractional

type Fractional struct {
}

func (*Fractional) Extract

func (frac *Fractional) Extract(numerator int, priv *SecKey) (dsk *SecKey)

the interface here is a little mixed up between types and not intuitive....

func (*Fractional) Flag

func (frac *Fractional) Flag(curve elliptic.Curve, random io.Reader, pk *PubKey) []byte

func (*Fractional) JsonifySK

func (frac *Fractional) JsonifySK(sk *SecKey) []byte

func (*Fractional) KeyGen

func (frac *Fractional) KeyGen(curve elliptic.Curve, gamma int, rand io.Reader) (priv *SecKey, pub *PubKey)

Implementing the fuzzy scheme interface

func (*Fractional) MarshalSK

func (frac *Fractional) MarshalSK(fname string) *SecKey

func (*Fractional) Test

func (frac *Fractional) Test(curve elliptic.Curve, ctBytes []byte, priv *SecKey) bool

type FuzzyScheme

type FuzzyScheme interface {
	// a public key algorithm that takes in an int representing  the constant param gamma,
	// outputs a public and private key pair
	KeyGen(elliptic.Curve, int, io.Reader) (*SecKey, *PubKey)
	// an algorithm that takes in a secret key and produces detection key with
	// probability p / q if possible, nil otherwise
	Extract(int, int, *SecKey) *SecKey
	// self-explanatory, flagging alg.
	// io.Reader is the source you're using for randomness so MAKE SURE IT's GOOD
	Flag(elliptic.Curve, io.Reader, *PubKey) []byte
	// tests whether or not a ciphertext was addressed to a particular individ.
	Test(elliptic.Curve, []byte, *SecKey) bool
}

type GroupElement

type GroupElement struct {
	X *big.Int
	Y *big.Int
}

type PubKey

type PubKey struct {
	NumKeys int
	PubKeys []*GroupElement
}

type SecKey

type SecKey struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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