Documentation
¶
Overview ¶
Package bulletproofs Copyright 2024 Distributed Lab. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package bulletproofs Copyright 2024 Distributed Lab. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package bulletproofs Copyright 2024 Distributed Lab. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package bulletproofs Copyright 2024 Distributed Lab. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package bulletproofs Copyright 2024 Distributed Lab. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package bulletproofs Copyright 2024 Distributed Lab. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package bulletproofs Copyright 2024 Distributed Lab. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package bulletproofs Copyright 2024 Distributed Lab. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package bulletproofs implements Bulletproofs++ zero-knowledge range proofs using the reciprocal argument construction with arithmetic circuits.
This package provides: - Single value range proofs (ProveRange/VerifyRange) - Batch aggregated range proofs for K values (ProveBatchRange/VerifyBatchRange) - Efficient Pedersen commitment utilities
Range proofs demonstrate that committed values lie in [0, 2^n) without revealing the values. Batch proofs aggregate multiple range proofs into a single proof for improved efficiency.
Package bulletproofs Copyright 2024 Distributed Lab. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package bulletproofs Copyright 2024 Distributed Lab. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- Constants
- func BatchCommitValues(public *BatchReciprocalPublic, values []*big.Int, blindings []*big.Int) []*bn256.G1
- func HexMapping(digits []*big.Int) []*big.Int
- func Keccak256(data ...[]byte) []byte
- func NewRandPoint() *bn256.G1
- func NewRandScalar() *big.Int
- func SecureRandPoint() (*bn256.G1, error)
- func SecureRandScalar() (*big.Int, error)
- func UInt64Hex(x uint64) []*big.Int
- func ValidateEntropy(data []byte) error
- func VerifyBatchRange(public *BatchReciprocalPublic, V []*bn256.G1, fs FiatShamirEngine, ...) error
- func VerifyCircuit(public *ArithmeticCircuitPublic, V []*bn256.G1, fs FiatShamirEngine, ...) error
- func VerifyRange(public *ReciprocalPublic, V *bn256.G1, fs FiatShamirEngine, ...) error
- func VerifyWNLA(public *WeightNormLinearPublic, proof *WeightNormLinearArgumentProof, ...) error
- type ArithmeticCircuitPrivate
- type ArithmeticCircuitProof
- type ArithmeticCircuitPublic
- type BatchReciprocalPrivate
- type BatchReciprocalProof
- type BatchReciprocalPublic
- type FiatShamirEngine
- type KeccakFS
- type KeccakState
- type PartitionF
- type PartitionType
- type ReciprocalPrivate
- type ReciprocalProof
- type ReciprocalPublic
- type WeightNormLinearArgumentProof
- type WeightNormLinearPublic
Constants ¶
const ( DOMAIN_CIRCUIT = "EMZA-BP++-Circuit-v1" DOMAIN_RANGE = "EMZA-BP++-Range-v1" DOMAIN_WNLA = "EMZA-BP++-WNLA-v1" )
Domain separation constants for different protocols
Variables ¶
This section is empty.
Functions ¶
func BatchCommitValues ¶
func BatchCommitValues(public *BatchReciprocalPublic, values []*big.Int, blindings []*big.Int) []*bn256.G1
BatchCommitValues creates Pedersen commitments for K values using the batch public parameters. Returns K commitments: V[i] = value[i]*G + blinding[i]*H for i in 0..K-1
Parameters:
- public: Batch public parameters (uses G and H[0] for commitments)
- values: K values to commit
- blindings: K random blinding factors for hiding
Returns:
- []*bn256.G1: K Pedersen commitments
func NewRandPoint ¶
NewRandPoint creates a new random point, panicking if random generation fails This is for internal use in setup/testing where crypto failure should be fatal
func NewRandScalar ¶
NewRandScalar creates a new random scalar, panicking if random generation fails This is for internal use in setup/testing where crypto failure should be fatal
func SecureRandPoint ¶
SecureRandPoint generates a cryptographically secure random group element with validation
func SecureRandScalar ¶
SecureRandScalar generates a cryptographically secure random scalar with entropy validation Uses rejection sampling for unbiased field element generation
func ValidateEntropy ¶
ValidateEntropy performs basic entropy quality checks
func VerifyBatchRange ¶
func VerifyBatchRange( public *BatchReciprocalPublic, V []*bn256.G1, fs FiatShamirEngine, proof *BatchReciprocalProof, ) error
VerifyBatchRange verifies an aggregated BP++ reciprocal argument range proof for K values. Returns nil if the proof is valid, error otherwise.
Architecture: Reconstructs the same concatenated circuit structure (Nm = K*Nd) used for proving. Verifies that all K values satisfy their range constraints in the aggregated proof.
Parameters:
- public: Batch public parameters including K (number of values)
- V: K value commitments (Pedersen commitments: V[i] = value[i]*G + blinding[i]*H)
- fs: Fiat-Shamir engine for challenge generation (use empty engine)
- proof: BatchReciprocalProof containing aggregated circuit proof and K reciprocal commitments
Returns:
- nil if proof is valid
- error with descriptive message if verification fails
func VerifyCircuit ¶
func VerifyCircuit(public *ArithmeticCircuitPublic, V []*bn256.G1, fs FiatShamirEngine, proof *ArithmeticCircuitProof) error
VerifyCircuit verifies BP++ arithmetic circuit zero-knowledge proof using WNLA protocol. If err is nil then proof is valid. Use empty FiatShamirEngine for call.
func VerifyRange ¶
func VerifyRange(public *ReciprocalPublic, V *bn256.G1, fs FiatShamirEngine, proof *ReciprocalProof) error
VerifyRange verifies BP++ reciprocal argument range proof on arithmetic circuits. If err is nil then proof is valid. Use empty FiatShamirEngine for call.
func VerifyWNLA ¶
func VerifyWNLA(public *WeightNormLinearPublic, proof *WeightNormLinearArgumentProof, Com *bn256.G1, fs FiatShamirEngine) error
VerifyWNLA verifies the weight norm linear argument proof. If err is nil then proof is valid. Use empty FiatShamirEngine for call. Also, use the same commitment that has been used during proving.
Types ¶
type ArithmeticCircuitProof ¶
type ArithmeticCircuitProof struct {
CL, CR, CO, CS *bn256.G1
WNLA *WeightNormLinearArgumentProof
}
func ProveCircuit ¶
func ProveCircuit(public *ArithmeticCircuitPublic, V []*bn256.G1, fs FiatShamirEngine, private *ArithmeticCircuitPrivate) *ArithmeticCircuitProof
ProveCircuit generates zero knowledge proof that witness satisfies BP++ arithmetic circuit. Use empty FiatShamirEngine for call.
type ArithmeticCircuitPublic ¶
type ArithmeticCircuitPublic struct {
Nm, Nl, Nv, Nw, No int // Nw = Nm + Nm + No (for L, R, O parts), Nl = Nv * K
K int // Count of witness vectors v.
G *bn256.G1
GVec []*bn256.G1 // Nm
HVec []*bn256.G1 // Nv+9
Wm [][]*big.Int // Nm * Nw
Wl [][]*big.Int // Nl * Nw
Am []*big.Int // Nm
Al []*big.Int // Nl
Fl bool
Fm bool
F PartitionF
// Vectors of points that will be used in WNLA protocol
GVec_ []*bn256.G1 // 2^n - Nm
HVec_ []*bn256.G1 // 2^n - (Nv+9)
}
func (*ArithmeticCircuitPublic) CommitCircuit ¶
CommitCircuit creates a commitment for v vector and blinding s. Com = v[0]*G + s*H[0] + <v[1:], H[9:]>
type BatchReciprocalPrivate ¶
type BatchReciprocalPrivate struct {
X []*big.Int // K committed values
M [][]*big.Int // K sets of multiplicities (each of length No)
Digits [][]*big.Int // K sets of digits (each of length Nd)
S []*big.Int // K blinding values (one per commitment)
}
BatchReciprocalPrivate contains private witness data for K values in batch range proofs. Each slice must have length K for proper batch proof generation.
type BatchReciprocalProof ¶
type BatchReciprocalProof struct {
*ArithmeticCircuitProof
V []*bn256.G1 // K reciprocal commitments
}
BatchReciprocalProof contains the aggregated range proof for K values. V contains K reciprocal commitments (one per value).
func ProveBatchRange ¶
func ProveBatchRange(public *BatchReciprocalPublic, fs FiatShamirEngine, private *BatchReciprocalPrivate) *BatchReciprocalProof
ProveBatchRange proves K range proofs in a single aggregated proof using the K-witness circuit. All K values share the same range parameters (Nd, Np) from public parameter. Returns proof with K reciprocal commitments that can be verified together.
Architecture: Creates a concatenated circuit with Nm = K*Nd gates where each value uses Nd gates. Constraint matrices and wire assignments are concatenated from all K proofs.
Parameters:
- public: Batch public parameters including K (number of values) and range parameters
- fs: Fiat-Shamir engine for non-interactive proof generation
- private: Private witness data for K values (values, digits, multiplicities, blindings)
Returns:
- BatchReciprocalProof containing aggregated circuit proof and K reciprocal commitments
Use empty FiatShamirEngine for call.
type BatchReciprocalPublic ¶
type BatchReciprocalPublic struct {
*ReciprocalPublic
K int // Number of values to prove (K > 0)
}
BatchReciprocalPublic extends ReciprocalPublic for batch range proofs with K>1 values. K represents the number of values to prove in a single aggregated proof.
func (*BatchReciprocalPublic) BatchCommitValues ¶
func (p *BatchReciprocalPublic) BatchCommitValues(values []*big.Int, blindings []*big.Int) []*bn256.G1
BatchCommitValues is a convenience method on BatchReciprocalPublic for batch commitments. Returns K commitments: V[i] = value[i]*G + blinding[i]*H for i in 0..K-1
type FiatShamirEngine ¶
type FiatShamirEngine interface {
AddPoint(*bn256.G1) error
AddNumber(*big.Int) error
AddDomain(domain string) error
AddBytes([]byte) error
GetChallenge() *big.Int
}
func NewKeccakFS ¶
func NewKeccakFS() FiatShamirEngine
type KeccakFS ¶
type KeccakFS struct {
// contains filtered or unexported fields
}
func (*KeccakFS) AddDomain ¶
AddDomain adds a domain separation tag to prevent cross-protocol attacks
func (*KeccakFS) GetChallenge ¶
type KeccakState ¶
KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.
type PartitionF ¶
type PartitionF = func(typ PartitionType, index int) *int
type PartitionType ¶
type PartitionType int
const ( PartitionLO PartitionType = iota PartitionLL PartitionLR PartitionNO )
type ReciprocalPrivate ¶
type ReciprocalProof ¶
type ReciprocalProof struct {
*ArithmeticCircuitProof
V *bn256.G1
}
func ProveRange ¶
func ProveRange(public *ReciprocalPublic, fs FiatShamirEngine, private *ReciprocalPrivate) *ReciprocalProof
ProveRange proves BP++ reciprocal argument range proof on arithmetic circuits. Returns range proof. Use empty FiatShamirEngine for call.
type ReciprocalPublic ¶
type ReciprocalPublic struct {
G *bn256.G1
GVec []*bn256.G1 // Nm
HVec []*bn256.G1 // Nv+9
Nd, Np int
// Vectors of points that will be used in WNLA protocol
GVec_ []*bn256.G1 // 2^n - Nm
HVec_ []*bn256.G1 // 2^n - (Nv+9)
}
ReciprocalPublic dimensions: Nd - count of private proles (size of committed value), Np - count of public poles (number system base). Nm = Nd, No = Np Nv = 1 + Nd G and HVec[0] will be used for the value commitment: VCom = value*G + blinding*HVec[0]
func (*ReciprocalPublic) CommitPoles ¶
CommitPoles creates a commitment to reciprocal poles r with blinding factor s. Returns commitment C = s*H[0] + sum(r[i]*H[9+i]) using reciprocal generators.
func (*ReciprocalPublic) CommitValue ¶
CommitValue creates a Pedersen commitment to value v with blinding factor s. Returns commitment V = v*G + s*H where G and H[0] are public generators.
type WeightNormLinearArgumentProof ¶
WeightNormLinearArgumentProof contains the proof of knowledge of vectors L, N for corresponding commitment C (is not included into the proof structure).
func ProveWNLA ¶
func ProveWNLA(public *WeightNormLinearPublic, Com *bn256.G1, fs FiatShamirEngine, l, n []*big.Int) *WeightNormLinearArgumentProof
ProveWNLA generates zero knowledge proof of knowledge of two vectors l and n that satisfies the commitment C (see WeightNormLinearPublic.Commit() function). Use empty FiatShamirEngine for call.
type WeightNormLinearPublic ¶
type WeightNormLinearPublic struct {
G *bn256.G1
GVec, HVec []*bn256.G1
C []*big.Int
Ro, Mu *big.Int // mu = ro^2
}
WeightNormLinearPublic contains the public values to be used in weight norm linear argument proof. The GVec and HVec sizes are recommended to be a powers of 2 and equal to the `n` and `l` private vector sizes.
func NewWeightNormLinearPublic ¶
func NewWeightNormLinearPublic(lLen int, nLen int) *WeightNormLinearPublic
func (*WeightNormLinearPublic) CommitWNLA ¶
CommitWNLA creates a commitment for vectors n, l based on public parameters p. Commit(l, n) = v*G + <l, H> + <n, G> where v = <c, l> + |n^2|_mu