issue

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ProtocolV1 = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	// Issuer is the identity of issuer
	Issuer driver.Identity
	// Inputs are the tokens to be redeemed by this issue action
	Inputs []*ActionInput
	// Outputs are the newly issued tokens
	Outputs []*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
}

Action specifies an issue of one or more tokens

func NewAction

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

NewAction instantiates an IssueAction given the passed arguments

func (*Action) Deserialize

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

Deserialize un-marshals IssueAction

func (*Action) ExtraSigners

func (i *Action) ExtraSigners() []driver.Identity

func (*Action) GetCommitments

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

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

func (*Action) GetInputs

func (i *Action) GetInputs() []*token2.ID

func (*Action) GetIssuer

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

GetIssuer returns the Issuer of IssueAction

func (*Action) GetMetadata

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

GetMetadata returns IssueAction metadata if there is any.

func (*Action) GetOutputs

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

GetOutputs returns the Outputs in IssueAction

func (*Action) GetProof

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

GetProof returns IssueAction ZKP

func (*Action) GetSerialNumbers

func (i *Action) GetSerialNumbers() []string

func (*Action) GetSerializedInputs

func (i *Action) GetSerializedInputs() ([][]byte, error)

func (*Action) GetSerializedOutputs

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

GetSerializedOutputs returns the serialization of Outputs

func (*Action) IsAnonymous

func (i *Action) IsAnonymous() bool

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

func (*Action) IsGraphHiding

func (i *Action) IsGraphHiding() bool

IsGraphHiding returns false, this driver does not hide the transaction graph

func (*Action) NumInputs

func (i *Action) NumInputs() int

func (*Action) NumOutputs

func (i *Action) NumOutputs() int

NumOutputs returns the number of outputs in IssueAction

func (*Action) Serialize

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

Serialize marshal IssueAction

func (*Action) Validate

func (i *Action) Validate() error

type ActionInput

type ActionInput struct {
	ID    token2.ID
	Token []byte
}

func (*ActionInput) FromProtos

func (i *ActionInput) FromProtos(p *actions.IssueActionInput) error

func (*ActionInput) ToProtos

func (i *ActionInput) ToProtos() (*actions.IssueActionInput, error)

type Issuer

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

Issuer is the entity that issues tokens

func (*Issuer) GenerateZKIssue

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

func (*Issuer) New

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

New returns an Issuer as a function of the passed parameters

func (*Issuer) SignTokenActions

func (i *Issuer) SignTokenActions(raw []byte) ([]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.Metadata, tokens []*math.G1, pp *v1.PublicParams) (*Prover, error)

func (*Prover) Prove

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

Prove produces a Proof for an IssueAction

type SameType

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
	// 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

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

Deserialize un-marshals SameType proof

func (*SameType) Serialize

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

Serialize marshals SameType proof

type SameTypeProver

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

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

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

Prove returns a SameType proof

type SameTypeRandomness

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

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

type SameTypeVerifier

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

SameTypeVerifier checks the validity of SameType proof

func NewSameTypeVerifier

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

NewSameTypeVerifier returns a SameTypeVerifier corresponding to the passed parameters

func (*SameTypeVerifier) Verify

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

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

type SigningIdentity

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 *v1.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