bp

package
v0.0.0-...-4097cb8 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Implementation of BulletProofs in Go

Index

Constants

This section is empty.

Variables

View Source
var VecLength = 64

Functions

func CalculateL

func CalculateL(aL, sL []*big.Int, z, x *big.Int) []*big.Int

Calculates (aL - z*1^n) + sL*x

func CalculateLMRP

func CalculateLMRP(aL, sL []*big.Int, z, x *big.Int) []*big.Int

Calculates (aL - z*1^n) + sL*x

func CalculateR

func CalculateR(aR, sR, y, po2 []*big.Int, z, x *big.Int) []*big.Int

func CalculateRMRP

func CalculateRMRP(aR, sR, y, zTimesTwo []*big.Int, z, x *big.Int) []*big.Int

func Delta

func Delta(y []*big.Int, z *big.Int) *big.Int

func DeltaMRP

func DeltaMRP(y []*big.Int, z *big.Int, m int) *big.Int

func GenerateNewParams

func GenerateNewParams(G, H []ECPoint, x *big.Int, L, R, P ECPoint) ([]ECPoint, []ECPoint, ECPoint)

func InnerProduct

func InnerProduct(a []*big.Int, b []*big.Int) *big.Int

The length here always has to be a power of two

func InnerProductVerify

func InnerProductVerify(c *big.Int, P, U ECPoint, G, H []ECPoint, ipp InnerProdArg) bool
Inner Product Verify

Given a inner product proof, verifies the correctness of the proof Since we're using the Fiat-Shamir transform, we need to verify all x hash computations, all g' and h' computations P : the Pedersen commitment we are verifying is a commitment to the innner product ipp : the proof

func InnerProductVerifyFast

func InnerProductVerifyFast(c *big.Int, P, U ECPoint, G, H []ECPoint, ipp InnerProdArg) bool

func MRPVerify

func MRPVerify(mrp MultiRangeProof) bool

MultiRangeProof Verify Takes in a MultiRangeProof and verifies its correctness

func PadLeft

func PadLeft(str, pad string, l int) string

from here: https://play.golang.org/p/zciRZvD0Gr with a fix

func PowerVector

func PowerVector(l int, base *big.Int) []*big.Int

func RPVerify

func RPVerify(rp RangeProof) bool

func RandVector

func RandVector(l int) []*big.Int

func STRNot

func STRNot(str string) string

func ScalarVectorMul

func ScalarVectorMul(v []*big.Int, s *big.Int) []*big.Int

func StrToBigIntArray

func StrToBigIntArray(str string) []*big.Int

func VectorAdd

func VectorAdd(v []*big.Int, w []*big.Int) []*big.Int

func VectorAddScalar

func VectorAddScalar(v []*big.Int, s *big.Int) []*big.Int

func VectorHadamard

func VectorHadamard(v, w []*big.Int) []*big.Int

func VectorSum

func VectorSum(y []*big.Int) *big.Int

Types

type CryptoParams

type CryptoParams struct {
	C   elliptic.Curve      // curve
	KC  *btcec.KoblitzCurve // curve
	BPG []ECPoint           // slice of gen 1 for BP
	BPH []ECPoint           // slice of gen 2 for BP
	N   *big.Int            // scalar prime
	U   ECPoint             // a point that is a fixed group element with an unknown discrete-log relative to g,h
	V   int                 // Vector length
	G   ECPoint             // G value for commitments of a single value
	H   ECPoint             // H value for commitments of a single value
}
var EC CryptoParams

func NewECPrimeGroupKey

func NewECPrimeGroupKey(n int) CryptoParams

NewECPrimeGroupKey returns the curve (field), Generator 1 x&y, Generator 2 x&y, order of the generators

func (CryptoParams) Zero

func (c CryptoParams) Zero() ECPoint

type ECPoint

type ECPoint struct {
	X, Y *big.Int
}

func PedersonCommit

func PedersonCommit(value []*big.Int) (ECPoint, []*big.Int)

func (ECPoint) Add

func (p ECPoint) Add(p2 ECPoint) ECPoint

Add adds points p and p2 and returns the resulting point

func (ECPoint) Equal

func (p ECPoint) Equal(p2 ECPoint) bool

Equal returns true if points p (self) and p2 (arg) are the same.

func (ECPoint) Mult

func (p ECPoint) Mult(s *big.Int) ECPoint

Mult multiplies point p by scalar s and returns the resulting point

func (ECPoint) Neg

func (p ECPoint) Neg() ECPoint

Neg returns the additive inverse of point p

type InnerProdArg

type InnerProdArg struct {
	L []ECPoint
	R []ECPoint
	A *big.Int
	B *big.Int

	Challenges []*big.Int
}

InnerProd Proof This stores the argument values

func InnerProductProve

func InnerProductProve(a []*big.Int, b []*big.Int, c *big.Int, P, U ECPoint, G, H []ECPoint) InnerProdArg

func InnerProductProveSub

func InnerProductProveSub(proof InnerProdArg, G, H []ECPoint, a []*big.Int, b []*big.Int, u ECPoint, P ECPoint) InnerProdArg
Inner Product Argument

Proves that <a,b>=c This is a building block for BulletProofs

type MultiRangeProof

type MultiRangeProof struct {
	Comms []ECPoint
	A     ECPoint
	S     ECPoint
	T1    ECPoint
	T2    ECPoint
	Tau   *big.Int
	Th    *big.Int
	Mu    *big.Int
	IPP   InnerProdArg

	// challenges
	Cy *big.Int
	Cz *big.Int
	Cx *big.Int
}

func MRPProve

func MRPProve(values []*big.Int) MultiRangeProof

MultiRangeProof Prove Takes in a list of values and provides an aggregate range proof for all the values. changes:

all values are concatenated
r(x) is computed differently
tau_x calculation is different
delta calculation is different

{(g, h \in G, \textbf{V} \in G^m ; \textbf{v, \gamma} \in Z_p^m) :

V_j = h^{\gamma_j}g^{v_j} \wedge v_j \in [0, 2^n - 1] \forall j \in [1, m]}

type RangeProof

type RangeProof struct {
	Comm ECPoint
	A    ECPoint
	S    ECPoint
	T1   ECPoint
	T2   ECPoint
	Tau  *big.Int
	Th   *big.Int
	Mu   *big.Int
	IPP  InnerProdArg

	// challenges
	Cy *big.Int
	Cz *big.Int
	Cx *big.Int
}

func RPProve

func RPProve(v *big.Int) RangeProof

RPProver : Range Proof Prove Given a value v, provides a range proof that v is inside 0 to 2^64-1

Jump to

Keyboard shortcuts

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