Documentation
¶
Overview ¶
Package zk implements zero-knowledge proof systems for MPC-TSS
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilSecret is returned when a nil secret is provided ErrNilSecret = errors.New("secret cannot be nil") // ErrNilPublicPoint is returned when a nil public point is provided ErrNilPublicPoint = errors.New("public point cannot be nil") // ErrNilCurve is returned when a nil curve is provided ErrNilCurve = errors.New("curve cannot be nil") // ErrInvalidWitness is returned when the witness doesn't satisfy the relation ErrInvalidWitness = errors.New("invalid witness: does not satisfy the relation") // ErrInvalidProof is returned when proof verification fails ErrInvalidProof = errors.New("invalid proof") // ErrMismatchedLengths is returned when array lengths don't match ErrMismatchedLengths = errors.New("mismatched array lengths") // ErrInvalidRange is returned when a value is outside valid range ErrInvalidRange = errors.New("value outside valid range") // ErrNilValue is returned when a nil value is provided ErrNilValue = errors.New("value cannot be nil") // ErrInvalidCommitment is returned when a commitment is invalid ErrInvalidCommitment = errors.New("invalid commitment") )
Functions ¶
func VerifyCompactSchnorr ¶
func VerifyCompactSchnorr(proof *CompactSchnorrProof, publicPoint *curve.Point, c curve.Curve, context []byte) bool
VerifyCompact verifies a compact proof
Types ¶
type BitProof ¶
type BitProof struct {
// Proof0 is a Schnorr proof assuming bit = 0
Proof0 *SchnorrProof
// Proof1 is a Schnorr proof assuming bit = 1
Proof1 *SchnorrProof
// Challenge is the Fiat-Shamir challenge
Challenge *big.Int
}
BitProof proves a committed value is either 0 or 1
func (*BitProof) Verify ¶
func (bp *BitProof) Verify(bitCommitment *commitment.PedersenCommitment, gp *commitment.GeneratorPair) bool
Verify verifies a bit proof
type CompactSchnorrProof ¶
CompactSchnorrProof is a space-optimized Schnorr proof Only stores Response and Challenge (Commitment can be recomputed)
type DLogEqualityProof ¶
type DLogEqualityProof struct {
// Commitment1 is k*G1
Commitment1 *curve.Point
// Commitment2 is k*G2
Commitment2 *curve.Point
// Challenge is the Fiat-Shamir challenge
Challenge *big.Int
// Response is z = k + e*x
Response *big.Int
// Curve for operations
Curve curve.Curve
}
DLogEqualityProof proves that two points have the same discrete log Proves: Y1 = x*G1 and Y2 = x*G2 for the same secret x
type RangeProof ¶
type RangeProof struct {
// BitCommitments are Pedersen commitments to each bit
BitCommitments []*commitment.PedersenCommitment
// BitProofs prove each commitment opens to 0 or 1
BitProofs []*BitProof
// AggregateProof proves the bits sum to the committed value
AggregateProof *SchnorrProof
// NumBits is the bit length (value < 2^NumBits)
NumBits int
}
RangeProof proves that a committed value is in a specific range [0, 2^n) without revealing the value itself
func ProveRange ¶
func ProveRange(value *big.Int, valueCommitment *commitment.PedersenCommitment, gp *commitment.GeneratorPair, numBits int) (*RangeProof, error)
ProveRange creates a range proof for a committed value Proves that value ∈ [0, 2^numBits) without revealing value
func (*RangeProof) Verify ¶
func (rp *RangeProof) Verify(valueCommitment *commitment.PedersenCommitment, gp *commitment.GeneratorPair) bool
Verify verifies the range proof
type SchnorrBatchProof ¶
type SchnorrBatchProof struct {
// Proofs is the list of individual proofs
Proofs []*SchnorrProof
// AggregateChallenge is the combined challenge (optional optimization)
AggregateChallenge *big.Int
}
SchnorrBatchProof represents a batch Schnorr proof for multiple secrets
func ProveBatchSchnorr ¶
func ProveBatchSchnorr(secrets []*big.Int, publicPoints []*curve.Point, c curve.Curve, context []byte) (*SchnorrBatchProof, error)
ProveBatchSchnorr creates proofs for multiple discrete logs efficiently
func (*SchnorrBatchProof) VerifyBatch ¶
func (sbp *SchnorrBatchProof) VerifyBatch(publicPoints []*curve.Point, context []byte) bool
VerifyBatch verifies all proofs in the batch
type SchnorrProof ¶
type SchnorrProof struct {
// Commitment is the prover's commitment R = k*G
Commitment *curve.Point
// Challenge is the Fiat-Shamir challenge e = H(G, Y, R, context)
Challenge *big.Int
// Response is z = k + e*x mod n
Response *big.Int
// Curve is the elliptic curve being used
Curve curve.Curve
}
SchnorrProof represents a Schnorr proof of knowledge of discrete logarithm Proves knowledge of x such that Y = x*G without revealing x
func ProveSchnorr ¶
func ProveSchnorr(secret *big.Int, publicPoint *curve.Point, c curve.Curve, context []byte) (*SchnorrProof, error)
ProveSchnorr creates a Schnorr proof of knowledge of discrete log Proves knowledge of secret such that publicPoint = secret * G Uses Fiat-Shamir heuristic for non-interactive proof
func (*SchnorrProof) ToCompact ¶
func (sp *SchnorrProof) ToCompact() *CompactSchnorrProof
ToCompact converts a standard proof to compact form