rangeproof

package
v0.0.0-...-202feaa Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFalseStatement  = errors.New("requested inequality does not hold")
	ErrUnsupportedSign = errors.New("unsupported sign: must be 1 or -1")
)

Functions

This section is empty.

Types

type FourSquaresSplitter

type FourSquaresSplitter struct{}

func (*FourSquaresSplitter) Ld

func (*FourSquaresSplitter) Ld() uint

func (*FourSquaresSplitter) Split

func (*FourSquaresSplitter) Split(delta *big.Int) ([]*big.Int, error)

func (*FourSquaresSplitter) SquareCount

func (*FourSquaresSplitter) SquareCount() int

type Proof

type Proof struct {
	// Actual proof responses
	Cs         []*big.Int `json:"Cs"`
	DResponses []*big.Int `json:"ds"`
	VResponses []*big.Int `json:"vs"`
	V5Response *big.Int   `json:"v5"`
	MResponse  *big.Int   `json:"-"`

	// Proof structure description
	Ld   uint     `json:"l_d"`
	Sign int      `json:"sign"`
	A    uint     `json:"a"`
	K    *big.Int `json:"k"`
}

func (*Proof) ExtractStructure

func (p *Proof) ExtractStructure(index int, g *gabikeys.PublicKey) (*ProofStructure, error)

ExtractStructure extracts the proof structure from proof

func (*Proof) ProvenStatement

func (p *Proof) ProvenStatement() (StatementType, uint, *big.Int)

ProvenStatement returns the statement that this proof proves. Calling the second and third return parameters "factor" and "bound" respectively, then

factor*attribute - bound >= 0  or  <= 0

where the inequality type is returned as the first parameter.

NB: this method does not verify the proof. Do not trust the output unless proof.Verify() has been invoked first.

func (*Proof) Proves

func (p *Proof) Proves(statement *Statement) bool

Proves returns whether the Proof proves or implies the specified statement.

func (*Proof) ProvesStatement

func (p *Proof) ProvesStatement(sign int, factor uint, bound *big.Int) bool

ProvesStatement returns whether the Proof proves or implies the specified statement.

type ProofCommit

type ProofCommit struct {
	// contains filtered or unexported fields
}

type ProofStructure

type ProofStructure struct {
	// contains filtered or unexported fields
}

func NewProofStructure

func NewProofStructure(index, sign int, factor uint, bound *big.Int, splitter SquareSplitter) (*ProofStructure, error)

NewProofStructure creates a new proof structure for proving a statement of the form sign(factor*m - bound) >= 0.

index specifies the index of the attribute. splitter describes the method used for splitting numbers into sum of squares.

func (*ProofStructure) BuildProof

func (s *ProofStructure) BuildProof(commit *ProofCommit, challenge *big.Int) *Proof

func (*ProofStructure) CommitmentsFromProof

func (s *ProofStructure) CommitmentsFromProof(g *gabikeys.PublicKey, p *Proof, challenge *big.Int) []*big.Int

func (*ProofStructure) CommitmentsFromSecrets

func (s *ProofStructure) CommitmentsFromSecrets(g *gabikeys.PublicKey, m, mRandomizer *big.Int) ([]*big.Int, *ProofCommit, error)

func (*ProofStructure) VerifyProofStructure

func (s *ProofStructure) VerifyProofStructure(g *gabikeys.PublicKey, p *Proof) bool

type SquareSplitter

type SquareSplitter interface {
	// Ld returns the number of bits per square
	Ld() uint
	// SquareCount return the number of squares in result
	SquareCount() int
	// Split is the actual splitting function. On input delta, it should return array x such that sum_i x_i^2 = delta and len(x) = SquareCount()
	Split(*big.Int) ([]*big.Int, error)
}

SquareSplitter provides a combined interface for all facets describing a method for splitting positive numbers into a sum of squares.

type SquaresTable

type SquaresTable [][]int64

func GenerateSquaresTable

func GenerateSquaresTable(limit int64) *SquaresTable

GenerateSquaresTable generates lookup table for splitting numbers into 3 squares containing entries up-to and including limit takes O(n^3/2)

func (*SquaresTable) Ld

func (t *SquaresTable) Ld() uint

func (*SquaresTable) Split

func (t *SquaresTable) Split(delta *big.Int) ([]*big.Int, error)

func (*SquaresTable) SquareCount

func (t *SquaresTable) SquareCount() int

type Statement

type Statement struct {
	Sign     int
	Factor   uint
	Bound    *big.Int
	Splitter SquareSplitter
}

Statement states that an attribute m satisfies Sign*(Factor*m-Bound) >= 0, and that Sign*(Factor*m-Bound) can be split into squares with the given Splitter. E.g. if Factor = 1 then Factor*m >= Bound. Defaults to four square splitter when splitter is not specified.

func NewStatement

func NewStatement(typ StatementType, bound *big.Int) (*Statement, error)

func (*Statement) ProofStructure

func (statement *Statement) ProofStructure(index int) (*ProofStructure, error)

type StatementType

type StatementType int
const (
	GreaterOrEqual StatementType = iota
	LesserOrEqual
)

func (StatementType) Sign

func (typ StatementType) Sign() (int, error)

Jump to

Keyboard shortcuts

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