Documentation ¶
Index ¶
- Variables
- func HashBP(A, S *p256.P256) (*big.Int, *big.Int, error)
- func IsPowerOfTwo(x int64) bool
- func ScalarProduct(a, b []*big.Int) (*big.Int, error)
- func SetupGeneric(a, b int64) (*bprp, error)
- 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) ([]*p256.P256, error)
- func VectorExp(a []*p256.P256, b []*big.Int) (*p256.P256, error)
- func VectorMul(a, b []*big.Int) ([]*big.Int, error)
- func VectorScalarMul(a []*big.Int, b *big.Int) ([]*big.Int, error)
- func VectorSub(a, b []*big.Int) ([]*big.Int, error)
- type BulletProof
- type BulletProofSetupParams
- type InnerProductParams
- type InnerProductProof
- type ProofBPRP
Constants ¶
This section is empty.
Variables ¶
var MAX_RANGE_END int64 = 4294967296 // 2**32
var MAX_RANGE_END_EXPONENT = 32 // 2**32
var ORDER = p256.CURVE.N
var SEEDH = "BulletproofsDoesNotNeedTrustedSetupH"
var SEEDU = "BulletproofsDoesNotNeedTrustedSetupU"
Functions ¶
func IsPowerOfTwo ¶
IsPowerOfTwo returns true for arguments that are a power of 2, false otherwise. https://stackoverflow.com/a/600306/844313
func ScalarProduct ¶
ScalarProduct return the inner product between a and b.
func SetupGeneric ¶
SetupGeneric is responsible for calling the Setup algorithm for each BulletProof.
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 ¶
VectorECMul computes vector EC addition componentwisely.
func VectorScalarMul ¶
VectorScalarMul computes vector scalar multiplication componentwisely.
Types ¶
type BulletProof ¶
type BulletProof struct { V *p256.P256 A *p256.P256 S *p256.P256 T1 *p256.P256 T2 *p256.P256 Taux *big.Int Mu *big.Int Tprime *big.Int InnerProductProof InnerProductProof Commit *p256.P256 Params BulletProofSetupParams }
BulletProofs structure contains the elements that are necessary for the verification of the Zero Knowledge Proof.
func Prove ¶
func Prove(secret *big.Int, params BulletProofSetupParams) (BulletProof, error)
Prove computes the ZK rangeproof. The documentation and comments are based on eprint version of Bulletproofs papers: https://eprint.iacr.org/2017/1066.pdf
func (*BulletProof) Verify ¶
func (proof *BulletProof) Verify() (bool, error)
Verify returns true if and only if the proof is valid.
type BulletProofSetupParams ¶
type BulletProofSetupParams struct { // N is the bit-length of the range. N int64 // G is the Elliptic Curve generator. G *p256.P256 // H is a new generator, computed using MapToGroup function, // such that there is no discrete logarithm relation with G. H *p256.P256 // Gg and Hh are sets of new generators obtained using MapToGroup. // They are used to compute Pedersen Vector Commitments. Gg []*p256.P256 Hh []*p256.P256 // InnerProductParams is the setup parameters for the inner product proof. InnerProductParams InnerProductParams }
BulletProofSetupParams is the structure that stores the parameters for the Zero Knowledge Proof system.
func Setup ¶
func Setup(b int64) (BulletProofSetupParams, error)
SetupInnerProduct is responsible for computing the common parameters. Only works for ranges to 0 to 2^n, where n is a power of 2 and n <= 32 TODO: allow n > 32 (need uint64 for that).
type InnerProductParams ¶
type InnerProductParams struct { N int64 Cc *big.Int Uu *p256.P256 H *p256.P256 Gg []*p256.P256 Hh []*p256.P256 P *p256.P256 }
InnerProductParams contains elliptic curve generators used to compute Pedersen commitments.
type InnerProductProof ¶
type InnerProductProof struct { N int64 Ls []*p256.P256 Rs []*p256.P256 U *p256.P256 P *p256.P256 Gg *p256.P256 Hh *p256.P256 A *big.Int B *big.Int Params InnerProductParams }
InnerProductProof contains the elements used to verify the Inner Product Proof.
func (InnerProductProof) Verify ¶
func (proof InnerProductProof) Verify() (bool, error)
Verify is responsible for the verification of the Inner Product Proof.
type ProofBPRP ¶
type ProofBPRP struct { P1 BulletProof P2 BulletProof }
ProofBPRP stores the generic ZKRP.
func ProveGeneric ¶
BulletProof only works for interval in the format [0, 2^N). In order to allow generic intervals in the format [A, B) it is necessary to use 2 BulletProofs, as explained in Section 4.3 from the following paper: https://infoscience.epfl.ch/record/128718/files/CCS08.pdf