Documentation ¶
Index ¶
- Variables
- func Add(x *big.Int, y *big.Int) *big.Int
- func BIP(a, b []*big.Int, g, h []*p256, u, P *p256, n int64, Ls, Rs []*p256) (proofBip, error)
- func CalculateHash(b1 *big.Int, b2 *big.Int) (*big.Int, error)
- func Commit(x, r *big.Int, h *bn256.G2) (*bn256.G2, error)
- func CommitG1(x, r *big.Int, h *p256) (*p256, error)
- func CommitInnerProduct(g, h []*p256, a, b []*big.Int) (*p256, error)
- func CommitVector(aL, aR []int64, alpha *big.Int, G, H *p256, g, h []*p256, n int64) (*p256, error)
- func CommitVectorBig(aL, aR []*big.Int, alpha *big.Int, G, H *p256, g, h []*p256, n int64) (*p256, error)
- func ComputeAR(x []int64) ([]int64, error)
- func Decompose(x *big.Int, u int64, l int64) ([]int64, error)
- func DumpProof(t *big.Int, h []*p256, p *p256, proof *proofBP) ([]byte, error)
- func F(x *big.Int) (*big.Int, error)
- func GetBigInt(value string) *big.Int
- func Hash(a []*bn256.GT, D *bn256.G2) (*big.Int, error)
- func HashBP(A, S *p256) (*big.Int, *big.Int, error)
- func HashIP(g, h []*p256, P *p256, c *big.Int, n int64) (*big.Int, error)
- func HashSet(a *bn256.GT, D *bn256.G2) (*big.Int, error)
- func HashToInt(b bytes.Buffer) (*big.Int, error)
- func LoadProofFromDisk(s string) (*proofBP, error)
- func MapToGroup(m string) (*p256, error)
- func Mod(base *big.Int, modulo *big.Int) *big.Int
- func ModInverse(base *big.Int, modulo *big.Int) *big.Int
- func ModPow(base *big.Int, exponent *big.Int, modulo *big.Int) *big.Int
- func Mult(a *p256, n *big.Int) *p256
- func Multiply(factor1 *big.Int, factor2 *big.Int) *big.Int
- func PowerOf(x *big.Int, n int64) ([]*big.Int, error)
- func ProveSet(x int64, r *big.Int, p paramsSet) (proofSet, error)
- func ProveUL(x, r *big.Int, p paramsUL) (proofUL, error)
- func ScalarProduct(a, b []*big.Int) (*big.Int, error)
- func SetupSet(s []int64) (paramsSet, error)
- func SetupUL(u, l int64) (paramsUL, error)
- func Sub(x *big.Int, y *big.Int) *big.Int
- func VectorAdd(a, b []*big.Int) ([]*big.Int, error)
- func VectorConvertToBig(a []int64, n int64) ([]*big.Int, error)
- func VectorCopy(a *big.Int, n int64) ([]*big.Int, error)
- func VectorECAdd(a, b []*p256) ([]*p256, error)
- func VectorExp(a []*p256, b []*big.Int) (*p256, error)
- func VectorG1Copy(a *p256, n int64) ([]*p256, error)
- func VectorMul(a, b []*big.Int) ([]*big.Int, error)
- func VectorScalarExp(a []*p256, b *big.Int) ([]*p256, error)
- func VectorScalarMul(a []*big.Int, b *big.Int) ([]*big.Int, error)
- func VectorSub(a, b []*big.Int) ([]*big.Int, error)
- func VerifyPedersenCommitment(input, output []*PedersenCommitment, blindDiff *big.Int) bool
- func VerifySet(proof_out *proofSet, p *paramsSet) (bool, error)
- func VerifyUL(proof_out *proofUL, p *paramsUL) (bool, error)
- type Bp
- func (zkrp *Bp) Delta(y, z *big.Int) (*big.Int, error)
- func (zkrp *Bp) GenerateProof(secret *big.Int) (*big.Int, *big.Int, []*p256, *p256, proofBP, error)
- func (s *Bp) MarshalJSON() ([]byte, error)
- func (zkrp *Bp) SaveToDisk(s string, p *proofBP) error
- func (zkrp *Bp) Setup(a, b int64)
- func (zkrp *Bp) SetupPre(a, b int64)
- func (s *Bp) UnmarshalJSON(data []byte) error
- func (zkrp *Bp) Verify(proof proofBP) (bool, error)
- type PedersenCommitment
- type ProofData
Constants ¶
This section is empty.
Variables ¶
var ( ORDER = CURVE.N SEEDH = "BulletproofsDoesNotNeedTrustedSetupH" SEEDU = "BulletproofsDoesNotNeedTrustedSetupU" SAVE = true )
var ( CURVE = secp256k1.S256() GX = CURVE.Gx GY = CURVE.Gy )
var ( G1 = new(bn256.G1).ScalarBaseMult(new(big.Int).SetInt64(1)) G2 = new(bn256.G2).ScalarBaseMult(new(big.Int).SetInt64(1)) E = bn256.Pair(G1, G2) )
Constants that are going to be used frequently, then we just need to compute them once.
Functions ¶
func BIP ¶
BIP is the main recursive function that will be used to compute the inner product argument.
func Commit ¶
Commit method corresponds to the Pedersen commitment scheme. Namely, given input message x, and randomness r, it outputs g^x.h^r.
func CommitG1 ¶
CommitG1 method corresponds to the Pedersen commitment scheme. Namely, given input message x, and randomness r, it outputs g^x.h^r.
func CommitInnerProduct ¶
CommitInnerProduct is responsible for calculating g^a.h^b.
func CommitVector ¶
Commitvector computes a commitment to the bit of the secret.
func CommitVectorBig ¶
func Decompose ¶
Decompose receives as input a bigint x and outputs an array of integers such that x = sum(xi.u^i), i.e. it returns the decomposition of x into base u.
func LoadProofFromDisk ¶
LoadProofFromDisk reads the generator from a file.
func MapToGroup ¶
MapToGroup is a hash function that returns a valid elliptic curve point given as input a string. It is also known as hash-to-point and is used to obtain a generator that has no discrete logarithm known relation, thus addressing the concept of NUMS (nothing up my sleeve). This implementation is based on the paper: Short signatures from the Weil pairing Boneh, Lynn and Shacham Journal of Cryptology, September 2004, Volume 17, Issue 4, pp 297–319
func ModPow ¶
*
- Returns base**exponent mod |modulo| also works for negative exponent (contrary to big.Int.Exp)
func ProveUL ¶
ProveUL method is used to produce the ZKRP proof that secret x belongs to the interval [0,U^L].
func ScalarProduct ¶
ScalarProduct return the inner product between a and b.
func SetupUL ¶
SetupUL generates the signature for the interval [0,u^l). The value of u should be roughly b/log(b), but we can choose smaller values in order to get smaller parameters, at the cost of having worse performance.
func VectorConvertToBig ¶
VectorConvertToBig converts an array of int64 to an array of big.Int.
func VectorCopy ¶
VectorCopy returns a vector composed by copies of a.
func VectorECAdd ¶
func VectorECAdd(a, b []*p256) ([]*p256, error)
VectorECMul computes vector EC addition componentwisely.
func VectorG1Copy ¶
VectorCopy returns a vector composed by copies of a.
func VectorScalarExp ¶
VectorScalarExp computes a[i]^b for each i.
func VectorScalarMul ¶
VectorScalarMul computes vector scalar multiplication componentwisely.
func VerifyPedersenCommitment ¶
func VerifyPedersenCommitment(input, output []*PedersenCommitment, blindDiff *big.Int) bool
Pedersen Commitment verification, check input_sum == output_sum ?
Types ¶
type Bp ¶
type Bp struct { N int64 // n 位 G *p256 // 曲线上的点 G 和 H H *p256 Gg []*p256 Hh []*p256 Zkip bip }
Bulletproofs parameters.
func LoadParamFromDisk ¶
LoadGenFromDisk reads the generator from a file.
func (*Bp) GenerateProof ¶
Prove computes the ZK proof.
func (*Bp) MarshalJSON ¶
func (*Bp) SaveToDisk ¶
SaveToDisk is responsible for saving the generator to disk, such it is possible to then later.
func (*Bp) UnmarshalJSON ¶
type PedersenCommitment ¶
type PedersenCommitment = p256