crypto

package
v0.0.0-...-1b893ba Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsOnCurve

func IsOnCurve(x, y *big.Int) bool

func RandomZq

func RandomZq(n int) ([]*big.Int, error)

RandomZq returns n size of random number in Zq

func SetBytes

func SetBytes(b []byte) (*bn256.G1, error)

func ToBytes

func ToBytes(g *bn256.G1) []byte

Types

type Address

type Address [20]byte

func NewAddress

func NewAddress(h *Generator) Address

type Commitment

type Commitment struct {
	*bn256.G1
}

Commitment is the alias of bn256.G1 represent of the Pedersen Commitment

func (*Commitment) Add

func (c *Commitment) Add(a, b *Commitment) *Commitment

Add sets c to a+b and returns c

func (*Commitment) AddBy

func (c *Commitment) AddBy(a *Commitment) *Commitment

AddBy sets c to c+a and returns c

func (*Commitment) AddGenerator

func (c *Commitment) AddGenerator(g *Generator) *Commitment

AddGenerator sets c to c+a and returns c

func (*Commitment) Bytes

func (c *Commitment) Bytes() []byte

Bytes converts c to byte slice

func (*Commitment) Cmp

func (c *Commitment) Cmp(cm *Commitment) bool

Cmp return whether c and cm is the same Commitment

func (*Commitment) FixedSet

func (c *Commitment) FixedSet(g *Generator, h *Generator, v *big.Int, r *big.Int) *Commitment

FixedSet sets c to vg+rh returns c, r, err

func (*Commitment) Mul

func (c *Commitment) Mul(cm *Commitment, k *big.Int) *Commitment

Mul sets c to kc and returns c

func (*Commitment) MulBy

func (c *Commitment) MulBy(k *big.Int) *Commitment

MulBy sets c to kc and returns c

func (*Commitment) MultiSet

func (c *Commitment) MultiSet(g []*Generator, v []*big.Int) (*Commitment, error)

MultiSet sets c to sum(gv), returns c, err

func (*Commitment) MultiSetRandom

func (c *Commitment) MultiSetRandom(g []*Generator) (*Commitment, []*big.Int, error)

MultiSetRandom sets c to sum(gv) which v is a set of random numbers, returns c, v, err

func (*Commitment) Neg

func (c *Commitment) Neg() *Commitment

Neg sets c to -c and returns c

func (*Commitment) Set

func (c *Commitment) Set(g *Generator, h *Generator, v *big.Int) (*Commitment, *big.Int, error)

Set sets c to vg+rh with random r, returns c, r, err

func (*Commitment) SetBytes

func (c *Commitment) SetBytes(b []byte) *Commitment

SetBytes sets c to the result of converting the output of Marshal back into a group element and then returns c

func (*Commitment) SetInt

func (c *Commitment) SetInt(k *big.Int) *Commitment

SetInt set c to gk

func (*Commitment) SetIntByGenerator

func (c *Commitment) SetIntByGenerator(g *Generator, k *big.Int) *Commitment

SetIntByGenerator set c to gk

func (*Commitment) X

func (c *Commitment) X() *big.Int

func (*Commitment) Y

func (c *Commitment) Y() *big.Int

type Generator

type Generator struct {
	*bn256.G1
}

Generator is a curve generator

func RandomPoints

func RandomPoints(n int) ([]*Generator, []*big.Int, error)

RandomPoints returns n size of random number in Scalar

func (*Generator) Bytes

func (g *Generator) Bytes() []byte

Bytes converts c to byte slice

func (*Generator) Init

func (g *Generator) Init(k *big.Int) *Generator

Init sets Generator g to vg0 and returns g

func (*Generator) Mul

func (g *Generator) Mul(a *Generator, k *big.Int) *Generator

Mul sets Generator g to ka and returns g

func (*Generator) MulBy

func (g *Generator) MulBy(k *big.Int) *Generator

MulBy sets Generator g to kg and returns g

func (*Generator) Random

func (g *Generator) Random() (*Generator, *big.Int, error)

Random sets c to rg with random r, returns c, r, error

func (*Generator) SetBytes

func (g *Generator) SetBytes(b []byte) *Generator

SetBytes sets c to the result of converting the output of Marshal back into a group element and then returns c

func (*Generator) X

func (g *Generator) X() *big.Int

func (*Generator) Y

func (g *Generator) Y() *big.Int

type Hash

type Hash [32]byte

func Hash_

func Hash_(args ...HashVariable) Hash

func (Hash) BigInt

func (h Hash) BigInt() *big.Int

func (Hash) Bytes

func (h Hash) Bytes() []byte

func (Hash) Cmp

func (h Hash) Cmp(h0 Hash) bool

type HashVariable

type HashVariable interface {
	Bytes() []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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