issue

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: 8 Imported by: 0

Documentation

Overview

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IssueAction

type IssueAction struct {
	// 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
	// flag to indicate whether the Issuer is anonymous or not
	Anonymous bool
	// 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, anonymous bool) (*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) 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 interface {
	GenerateZKIssue(values []uint64, owners [][]byte) (*IssueAction, []*token.Metadata, error)

	SignTokenActions(raw []byte, txID string) ([]byte, error)

	New(ttype string, signer common.SigningIdentity, pp *crypto.PublicParams)
}

type Proof

type Proof struct {
	// proof that issued tokens are well-formed
	// tokens contain a commitment to type and value
	WellFormedness []byte
	// proof that issued tokens have value in the authorized range
	RangeCorrectness []byte
}

Proof poves that an IssueAction is valid

func (*Proof) Deserialize

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

Deserialize unmarshals Proof

func (*Proof) Serialize

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

Serialize marshals Proof

type Prover

type Prover struct {
	// WellFormedness encodes the WellFormedness Prover
	WellFormedness *WellFormednessProver
	// RangeCorrectness encodes the range proof Prover
	RangeCorrectness *rp.Prover
}

Prover produces a proof of validity of an IssueAction

func NewProver

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

func (*Prover) Prove

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

Prove produces a Proof for an IssueAction

type Verifier

type Verifier struct {
	// WellFormedness encodes the WellFormedness Verifier
	WellFormedness *WellFormednessVerifier
	// RangeCorrectness encodes the range proof verifier
	RangeCorrectness *rp.Verifier
}

Verifier checks if Proof is valid

func NewVerifier

func NewVerifier(tokens []*math.G1, anonymous bool, 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

type WellFormedness

type WellFormedness struct {
	// Proof of type
	Type *math.Zr
	// Proof of values of tokens to be issued
	// i^th proof for the value of the i^th token
	Values []*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
	BlindingFactors []*math.Zr
	// only when issue is not anonymous
	TypeInTheClear string
	// Challenge computed using the Fiat-Shamir Heuristic
	Challenge *math.Zr
}

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

func (*WellFormedness) Deserialize

func (wf *WellFormedness) Deserialize(bytes []byte) error

Deserialize un-marshals WellFormedness proof

func (*WellFormedness) Serialize

func (wf *WellFormedness) Serialize() ([]byte, error)

Serialize marshals WellFormedness proof

type WellFormednessProver

type WellFormednessProver struct {
	*WellFormednessVerifier

	// Commitments is the commitment to the randomness used to generate the proof
	Commitments []*math.G1
	// contains filtered or unexported fields
}

WellFormednessProver contains information that allows an Issuer to prove that issued tokens are well formed

func NewWellFormednessProver

func NewWellFormednessProver(witness []*token.TokenDataWitness, tokens []*math.G1, anonymous bool, pp []*math.G1, c *math.Curve) *WellFormednessProver

NewWellFormednessProver returns a WellFormednessProver for the passed parameters

func (*WellFormednessProver) Prove

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

Prove returns a serialized wellformedness proof

type WellFormednessRandomness

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

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

type WellFormednessVerifier

type WellFormednessVerifier struct {
	PedParams []*math.G1
	Curve     *math.Curve
	Tokens    []*math.G1
	// Anonymous indicates if the issuance is anonymous
	Anonymous bool
}

WellFormednessVerifier checks the validity of WellFormedness proof

func NewWellFormednessVerifier

func NewWellFormednessVerifier(tokens []*math.G1, anonymous bool, pp []*math.G1, c *math.Curve) *WellFormednessVerifier

NewWellFormednessVerifier returns a WellFormednessVerifier corresponding to the passed parameters

func (*WellFormednessVerifier) Verify

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

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

Directories

Path Synopsis
mock
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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