core

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

This is referenced from ./venachain/usage.go with tiny modification (line: 198)

Index

Constants

This section is empty.

Variables

View Source
var (
	RegisterCmd = cli.Command{
		Name:   "register",
		Usage:  "register a new account",
		Action: register,
		Flags:  registerCmdFlags,
		Description: `
		client register --bc-owner ... --contract ... --url ...

Register a new account in the privacy token contract`,
	}

	DepositCmd = cli.Command{
		Name:   "deposit",
		Usage:  "deposit amount of token",
		Action: deposit,
		Flags:  depositCmdFlags,
		Description: `
		client deposit --account ... --value ... --bc-owner ... --contract ... --url ...

Deposit amount of token from bc token to privacy token contract.
the operation may be failed if the amount of token is insufficient in bc token contract`,
	}

	TransferCmd = cli.Command{
		Name:   "transfer",
		Usage:  "invoke contract function",
		Action: transfer,
		Flags:  transferCmdFlags,
		Description: `
		client transfer --account ... --receiver ... --value ... --bc-owner ... --contract ... --url ... 

Transfer privacy token from an account to another account
The --receiver should also be an account registered in the privacy token
`,
	}

	WithdrawCmd = cli.Command{
		Name:   "withdraw",
		Usage:  "withdraw amount of token",
		Action: withdraw,
		Flags:  withdrawCmdFlags,
		Description: `
		client withdraw --account ... --value ... --abi ... --bc-owner ... --contract ... --url ...

Withdraw amount of token from privacy token to bc token contract.
the operation may be failed if the amount of token is insufficient in privacy token contract`,
	}

	QueryCmd = cli.Command{
		Name:   "query",
		Usage:  "query the amount of the privacy token in plaintext",
		Action: query,
		Flags:  queryCmdFlags,
		Description: `
		client query --account ... --bc-owner ... --contract ... --url ... 

query the AVAILABLE amount of privacy token at current epoch`,
	}

	ConfigCmd = cli.Command{
		Name:   "config",
		Usage:  "generate a config file to eliminate the ",
		Action: genConfig,
		Flags:  configCmdFlags,
		Description: `
		client config --bc-owner ... --contract ... --url ... 

set the value of the config file`,
	}
)
View Source
var (
	/*
		AbiFlag = cli.StringFlag{
			Name:  "abi",
			Usage: "abi file of the privacy token contract.",
		}*/
	UrlFlag = cli.StringFlag{
		Name:  "url",
		Usage: "url of remote nodes, format: http://<ip>:<port>",
	}
	ContractFlag = cli.StringFlag{
		Name:  "contract",
		Usage: "contract address of privacy token contract",
	}
	TxSenderFlag = cli.StringFlag{
		Name:  "bc-owner",
		Usage: "account registered in the bc token contract",
	}
	AccountFlag = cli.StringFlag{
		Name:  "account",
		Usage: "account registered in the privacy token contract",
	}
	TransferPubFlag = cli.StringFlag{
		Name:  "receiver",
		Usage: "public key of the receiver for receiving privacy token",
	}
	ValueFlag = cli.StringFlag{
		Name:  "value",
		Usage: "amount of token",
	}
	DecoyNumFlag = cli.IntFlag{
		Name:  "decoy-num",
		Usage: "2^n of members in the decoy, where n is a number from 2 to 6. e.g. --decoy-num 2 means 4 decoy members",
		Value: 3,
	}
	LeftIntervalFlag = cli.Int64Flag{
		Name:  "l-invl",
		Usage: "left interval of the balance. it is used for revealing the balance from ciphertext",
	}
	RightIntervalFlag = cli.Int64Flag{
		Name:  "r-invl",
		Usage: "right interval of the balance. it is used for revealing the balance from ciphertext",
	}
	OutputFlag = cli.StringFlag{
		Name:  "o",
		Usage: "specify the account file name",
		Value: defaultFile,
	}
	ConfigFlag = cli.BoolFlag{
		Name:  "config",
		Usage: "set the value of the config flags provided to the config.json file",
	}
)
View Source
var AppHelpFlagGroups = []flagGroup{
	{
		Name: "CONFIG",
		Flags: []cli.Flag{

			UrlFlag,
			ContractFlag,
			TxSenderFlag,
			ConfigFlag,
		},
	},
	{
		Name: "COMMON",
		Flags: []cli.Flag{
			AccountFlag,
			TransferPubFlag,
			ValueFlag,
		},
	},
	{
		Name: "MISC",
	},
}

AppHelpFlagGroups is the application flags, grouped by functionality.

View Source
var AppHelpTemplate = `` /* 637-byte string literal not displayed */

AppHelpTemplate is the test template for the default, global app help topic.

View Source
var ErrGetReceipt = errors.New("get transaction receipt error")
View Source
var ErrNonceUsed = errors.New("nonce is used")

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func Deposit

func Deposit(z *ZCS, home common.Address, acc *Account, value string, l, r *big.Int) ([]interface{}, error)

func PointCmp

func PointCmp(point1, point2 *bn256.G1) int

func PointToBn256

func PointToBn256(data *simAccReturn) *bn256.G1

func Query

func Query(z *ZCS, acc *Account, l, r *big.Int) (*big.Int, error)

func Register

func Register(z *ZCS, home common.Address, a *Account) ([]interface{}, error)

func Transfer

func Transfer(z *ZCS, home common.Address, acc *Account, value string, decoyNum int, l, r *big.Int, txPub string) error

func Withdraw

func Withdraw(z *ZCS, home common.Address, acc *Account, value string, l, r *big.Int) error

func WriteConfig

func WriteConfig(filePath string, config *Config)

WriteConfigFile writes data into config.json

Types

type Account

type Account struct {
	State *UserState
	Key   *crypto.KeyPair
}

func NewAccount

func NewAccount() *Account

func (*Account) Marshal

func (a *Account) Marshal() ([]byte, error)

func (*Account) Unmarshal

func (a *Account) Unmarshal(b []byte) error

type AccountCopy

type AccountCopy struct {
	State   *UserState
	KeyPair *KeyPair
}

func NewAccountCopy

func NewAccountCopy() *AccountCopy

type Config

type Config struct {
	From      string `json:"from"`      // the address used to send the transaction
	Contract  string `json:"contract"`  // the address of the privacy token
	Url       string `json:"url"`       // the ip address of the remote node
	Verbosity int    `json:"verbosity"` // the log level
}

Config store the values from config.json file

func ParseConfigJson

func ParseConfigJson(configPath string) *Config

ParseConfigJson parses the data in config.json to Config object

type Decoy

type Decoy []*bn256.G1

func (Decoy) Shuffle

func (items Decoy) Shuffle(sender, receiver *bn256.G1)

this function should be tested later--------zbx the sender and receiver must be have opposite parity

type KeyPair

type KeyPair struct {
	Sk string
	Pk string
}

type UserState

type UserState struct {
	Balance *big.Int
	/// Pending      *big.Int
	NonceUsed    bool
	LastRollOver int64
}

func NewUserState

func NewUserState() *UserState

type ZCS

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

func (*ZCS) Call

func (z *ZCS) Call() ([]interface{}, error)

func (*ZCS) GetAccCipher

func (z *ZCS) GetAccCipher(decoy []*bn256.G1, epoch int64) (cLn, cRn []*bn256.G1, err error)

func (*ZCS) Send

func (z *ZCS) Send(from common.Address, gas string, isSync bool) ([]interface{}, error)

Jump to

Keyboard shortcuts

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