rangeproof

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commitment

type Commitment struct {
	Tokens              []*mathlib.G1
	CommitmentsToValues []*mathlib.G1
}

Commitment is the commitment to the randomness used in the range proof

type EqualityProofs

type EqualityProofs struct {
	// Type of tokens
	Type *mathlib.Zr
	// Value is an array of elements in Zr such that Value[i] is the value of the i^th token
	Value []*mathlib.Zr
	// TokenBlindingFactor is an array of elements in Zr such that
	// TokenBlindingFactor[i] is the blinding factor of the i^th token
	TokenBlindingFactor []*mathlib.Zr
	// CommitmentBlindingFactor is an array of elements in Zr such that
	// CommitmentBlindingFactor[i] is the blinding factor of the i^th commitment
	CommitmentBlindingFactor []*mathlib.Zr
}

EqualityProofs show that for each token in an array of tokens, token_value = \sum_{i=0}^exponent v_i base^i

type MembershipProof

type MembershipProof struct {
	// Commitments is an array of Pedersen commitments
	Commitments []*mathlib.G1
	// SignatureProofs is ZK proof that each committed value is signed
	// using Pointcheval-Sanders signature
	SignatureProofs []*sigproof.MembershipProof
}

MembershipProof shows that committed values 0=<v_i =<max_value, for 1 =< i =< n

type Prover

type Prover struct {
	*Verifier

	// Signatures are an array of Pointcheval-Sanders signatures
	Signatures []*pssign.Signature
	// contains filtered or unexported fields
}

Prover produces a proof that show that values of tokens is < max_value

func NewProver

func NewProver(tw []*token.TokenDataWitness, token []*mathlib.G1, signatures []*pssign.Signature, exponent int, pp []*mathlib.G1, PK []*mathlib.G2, P *mathlib.G1, Q *mathlib.G2, c *mathlib.Curve) *Prover

NewProver returns a Prover

func (*Prover) Prove

func (p *Prover) Prove() ([]byte, error)

Prove generates a range proof

type RangeProof

type RangeProof struct {
	// Challenge used to compute the proof
	Challenge *mathlib.Zr
	// EqualityProofs show that for each token in an array of tokens,
	// token_value = \sum_{i=0}^exponent v_i base^i
	EqualityProofs *EqualityProofs
	// MembershipProofs show that  0=<v_i =<base-1
	MembershipProofs []*MembershipProof
}

RangeProof is a range proof that show that an array of token have value < max_value max_value = base^exponent - 1 token_value = \sum_{i=0}^exponent v_i base^i and 0=<v_i =<base-1

type Verifier

type Verifier struct {
	// Tokens is an array of TokenData - commitment to (value, type)
	Tokens []*mathlib.G1
	// max_value = Base^Exponent
	Base     uint64
	Exponent int
	// PedersenParams corresponds to the Pedersen commitment generators
	PedersenParams []*mathlib.G1
	// Q is a random G2 generator
	Q *mathlib.G2
	// P is a random G1 generator
	P *mathlib.G1
	// PK is the public key of Pointcheval-Sanders signature
	PK []*mathlib.G2
	// Curve is an elliptic curve
	Curve *mathlib.Curve
}

Verifier checks the validity of range proofs produced by Prover

func NewVerifier

func NewVerifier(token []*mathlib.G1, base uint64, exponent int, pp []*mathlib.G1, PK []*mathlib.G2, P *mathlib.G1, Q *mathlib.G2, c *mathlib.Curve) *Verifier

NewVerifier returns a range proof Verifier

func (*Verifier) Verify

func (v *Verifier) Verify(raw []byte) error

Jump to

Keyboard shortcuts

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