utils

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package utils provides auxiliary functions required by the Coconut Scheme.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateLagrangianCoefficients

func GenerateLagrangianCoefficients(n int, p *Curve.BIG, xs []*Curve.BIG, x int) []*Curve.BIG

GenerateLagrangianCoefficients creates a slice of Lagragian Coefficients

func GenerateRandomBIGSlice

func GenerateRandomBIGSlice(p *Curve.BIG, rng *amcl.RAND, n int) []*Curve.BIG

GenerateRandomBIGSlice creates a slice of specified length with random BIGs.

func HashBytes

func HashBytes(sha int, b []byte) ([]byte, error)

HashBytes takes a bytes message and returns its SHA256/SHA384/SHA512 hash It is based on the amcl implementation: https://github.com/milagro-crypto/amcl/blob/master/version3/go/MPIN.go#L83

func HashBytesToBig

func HashBytesToBig(sha int, b []byte) (*Curve.BIG, error)

HashBytesToBig takes a bytes message and maps it to a BIG number It is based on the amcl implementation: https://github.com/milagro-crypto/amcl/blob/master/version3/go/MPIN.go#L707

func HashBytesToG1

func HashBytesToG1(sha int, b []byte) (*Curve.ECP, error)

HashBytesToG1 takes a bytes message and maps it to a point on G1 Curve Python implementation use SHA512, so temporarily hardcoding it here

func HashStringToBig

func HashStringToBig(sha int, m string) (*Curve.BIG, error)

HashStringToBig takes a string message and maps it to a BIG number

func HashStringToG1

func HashStringToG1(sha int, m string) (*Curve.ECP, error)

HashStringToG1 takes a string message and maps it to a point on G1 Curve

func LagrangeBasis

func LagrangeBasis(i int, o *Curve.BIG, xs []*Curve.BIG, x int) *Curve.BIG

LagrangeBasis generates the lagrange basis polynomial li(x), for a polynomial of degree t-1. Takes x values from xs and calculates the basis for point xs[i]. It is done around at x (usually 0). It's based on the original Python implementation: https://github.com/asonnino/coconut/blob/master/coconut/utils.py#L37.

func PolyEval

func PolyEval(coeff []*Curve.BIG, x *Curve.BIG, o *Curve.BIG) *Curve.BIG

PolyEval evaluates a polynomial defined by the slice of coefficient coeff at point x. All operations are performed mod o. It's based on the original Python implementation: https://github.com/asonnino/coconut/blob/master/coconut/utils.py#L33.

func ToCoconutString

func ToCoconutString(p Printable) string

ToCoconutString returns string representation of ECP or ECP2 object such that it is compatible with representation of Python implementation.

Types

type Printable

type Printable interface {
	ToString() string
}

Printable is a wrapper for all objects that have ToString method. In particular Curve.ECP and Curve.ECP2.

func CombinePrintables

func CombinePrintables(p ...[]Printable) []Printable

CombinePrintables combines multiple slices of Printable into a single slice.

func ECP2SliceToPrintable

func ECP2SliceToPrintable(s []*Curve.ECP2) []Printable

ECP2SliceToPrintable converts slice of ECP2 to slice of Printable.

func ECPSliceToPrintable

func ECPSliceToPrintable(s []*Curve.ECP) []Printable

ECPSliceToPrintable converts slice of ECP to slice of Printable.

Jump to

Keyboard shortcuts

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