common

package
Version: v0.0.0-...-0443316 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2019 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Crt

func Crt(a *big.Int, pa *big.Int, b *big.Int, pb *big.Int) *big.Int

Find a number x (mod pa*pb) such that x = a (mod pa) and x = b (mod pb)

func GetHashNumber

func GetHashNumber(a *big.Int, b *big.Int, index int, bitlen uint) *big.Int

func HashCommit

func HashCommit(values []*big.Int) *big.Int

func LegendreSymbol

func LegendreSymbol(a, p *big.Int) int

legendreSymbol calculates the Legendre symbol (a/p).

func ModSqrt

func ModSqrt(a *big.Int, factors []*big.Int) (*big.Int, bool)

Calculate Sqrt modulo a number with given prime factors. Also allows 4 as a factor All factors should be relatively prime to each other!

func PrimeSqrt

func PrimeSqrt(a *big.Int, pa *big.Int) (*big.Int, bool)

Calculate sqrt modulo a prime

func RandomBigInt

func RandomBigInt(limit *big.Int) *big.Int

Derives a random number uniformly chosen below the given limit from a random 256 bit seed generated when the application starts.

Types

type CPRNG

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

Simple threadsafe cryptographically secure pseudo-random number generator.

Implemented with AES in counter mode with the seed as key and an atomic uint64 as counter.

func NewCPRNG

func NewCPRNG(seed *[32]byte) (*CPRNG, error)

func (*CPRNG) Read

func (c *CPRNG) Read(buf []byte) (n int, err error)

type FastMod

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

func (*FastMod) Mod

func (m *FastMod) Mod(ret, x *big.Int) *big.Int

func (*FastMod) Set

func (m *FastMod) Set(p *big.Int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL