issue

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IssueAction

type IssueAction struct {
	// Issuer is the identity of issuer
	Issuer []byte
	// OutputTokens are the newly issued tokens
	OutputTokens []*token.Token `protobuf:"bytes,1,rep,name=outputs,proto3" json:"outputs,omitempty"`
	// Proof carries the ZKP of IssueAction validity
	Proof []byte
	// Metadata of the issue action
	Metadata map[string][]byte
}

IssueAction specifies an issue of one or more tokens

func NewIssue

func NewIssue(issuer []byte, coms []*math.G1, owners [][]byte, proof []byte) (*IssueAction, error)

NewIssue instantiates an IssueAction given the passed arguments

func (*IssueAction) Deserialize

func (i *IssueAction) Deserialize(raw []byte) error

Deserialize un-marshals IssueAction

func (*IssueAction) GetCommitments

func (i *IssueAction) GetCommitments() ([]*math.G1, error)

GetCommitments return the Pedersen commitment of (type, value) in the OutputTokens

func (*IssueAction) GetIssuer

func (i *IssueAction) GetIssuer() []byte

GetIssuer returns the Issuer of IssueAction

func (*IssueAction) GetMetadata

func (i *IssueAction) GetMetadata() map[string][]byte

GetMetadata returns IssueAction metadata if there is any.

func (*IssueAction) GetOutputs

func (i *IssueAction) GetOutputs() []driver.Output

GetOutputs returns the OutputTokens in IssueAction

func (*IssueAction) GetProof

func (i *IssueAction) GetProof() []byte

GetProof returns IssueAction ZKP

func (*IssueAction) GetSerializedOutputs

func (i *IssueAction) GetSerializedOutputs() ([][]byte, error)

GetSerializedOutputs returns the serialization of OutputTokens

func (*IssueAction) IsAnonymous

func (i *IssueAction) IsAnonymous() bool

IsAnonymous returns a Boolean. True if IssueAction is anonymous, and False otherwise.

func (*IssueAction) IsGraphHiding added in v0.4.0

func (i *IssueAction) IsGraphHiding() bool

IsGraphHiding returns false, indicating that fabtoken does not hide the transaction graph

func (*IssueAction) NumOutputs

func (i *IssueAction) NumOutputs() int

NumOutputs returns the number of outputs in IssueAction

func (*IssueAction) Serialize

func (i *IssueAction) Serialize() ([]byte, error)

Serialize marshal IssueAction

type Issuer

type Issuer struct {
	Signer       SigningIdentity
	PublicParams *crypto.PublicParams
	Type         token2.Type
}

Issuer is the entity that issues tokens

func (*Issuer) GenerateZKIssue

func (i *Issuer) GenerateZKIssue(values []uint64, owners [][]byte) (*IssueAction, []*token.Metadata, error)

func (*Issuer) New

func (i *Issuer) New(ttype token2.Type, signer common.SigningIdentity, pp *crypto.PublicParams)

New returns an Issuer as a function of the passed parameters

func (*Issuer) SignTokenActions

func (i *Issuer) SignTokenActions(raw []byte, txID string) ([]byte, error)

type Proof

type Proof struct {
	// SameType is the proof that a bridge commitment is of type G_0^typeH^r
	SameType *SameType
	// RangeCorrectness is the proof that issued tokens have value in the authorized range
	RangeCorrectness *rp.RangeCorrectness
}

Proof proves that an IssueAction is valid

func (*Proof) Deserialize

func (p *Proof) Deserialize(bytes []byte) error

Deserialize un-marshals Proof

func (*Proof) Serialize

func (p *Proof) Serialize() ([]byte, error)

Serialize marshals Proof

type Prover

type Prover struct {
	// SameType encodes the SameType Prover
	SameType *SameTypeProver
	// RangeCorrectness encodes the range proof Prover
	RangeCorrectness *rp.RangeCorrectnessProver
}

Prover produces a proof of validity of an IssueAction

func NewProver

func NewProver(tw []*token.TokenDataWitness, tokens []*math.G1, pp *crypto.PublicParams) (*Prover, error)

func (*Prover) Prove

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

Prove produces a Proof for an IssueAction

type SameType added in v0.4.0

type SameType struct {
	// Proof of type
	Type *math.Zr
	// Proof of randomness used to compute the commitment to type and value in the issued tokens
	// i^th proof is for the randomness  used to compute the i^th token
	BlindingFactor *math.Zr
	// only when the type is not hidden
	TypeInTheClear string
	// Challenge computed using the Fiat-Shamir Heuristic
	Challenge *math.Zr
	// CommitmentToType is a commitment to the type being issued
	CommitmentToType *math.G1
}

SameType shows that issued tokens contains Pedersen commitments to (type, value) SameType also shows that all the issued tokens contain the same type

func (*SameType) Deserialize added in v0.4.0

func (stp *SameType) Deserialize(bytes []byte) error

Deserialize un-marshals SameType proof

func (*SameType) Serialize added in v0.4.0

func (stp *SameType) Serialize() ([]byte, error)

Serialize marshals SameType proof

type SameTypeProver added in v0.4.0

type SameTypeProver struct {
	PedParams []*math.G1
	Curve     *math.Curve

	// CommitmentToType is a commitment to tokenType using blindingFactor
	CommitmentToType *math.G1
	// contains filtered or unexported fields
}

SameTypeProver contains information that allows an Issuer to prove that issued tokens are have the same type

func NewSameTypeProver added in v0.4.0

func NewSameTypeProver(ttype token2.Type, bf *math.Zr, com *math.G1, pp []*math.G1, c *math.Curve) *SameTypeProver

NewSameTypeProver returns a SameTypeProver for the passed parameters

func (*SameTypeProver) Prove added in v0.4.0

func (p *SameTypeProver) Prove() (*SameType, error)

Prove returns a SameType proof

type SameTypeRandomness added in v0.4.0

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

SameTypeRandomness is the randomness used to generate the well-formedness proof

type SameTypeVerifier added in v0.4.0

type SameTypeVerifier struct {
	PedParams []*math.G1
	Curve     *math.Curve
	Tokens    []*math.G1
}

SameTypeVerifier checks the validity of SameType proof

func NewSameTypeVerifier added in v0.4.0

func NewSameTypeVerifier(tokens []*math.G1, pp []*math.G1, c *math.Curve) *SameTypeVerifier

NewSameTypeVerifier returns a SameTypeVerifier corresponding to the passed parameters

func (*SameTypeVerifier) Verify added in v0.4.0

func (v *SameTypeVerifier) Verify(proof *SameType) error

Verify returns an error if the serialized proof is an invalid SameType proof

type SigningIdentity added in v0.4.0

type SigningIdentity interface {
	driver.SigningIdentity
}

type Verifier

type Verifier struct {
	// SameType encodes the SameType Verifier
	SameType *SameTypeVerifier
	// RangeCorrectness encodes the range proof verifier
	RangeCorrectness *rp.RangeCorrectnessVerifier
}

Verifier checks if Proof is valid

func NewVerifier

func NewVerifier(tokens []*math.G1, pp *crypto.PublicParams) *Verifier

func (*Verifier) Verify

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

Verify returns an error if Proof of an IssueAction is invalid

Jump to

Keyboard shortcuts

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