api

package module
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: Apache-2.0 Imports: 30 Imported by: 1

README

Golang version of build transaction of MobileCoin

Documentation

Index

Constants

View Source
const (
	/// The length of the header1 field, in bytes
	HEADER_LEN = 16
	/// The length of the header2 field, in bytes
	HEADER2_LEN = 16
	/// The length of the SWDEFINED field, in bytes
	SWDEFINED_LEN = 4
	/// The length of the MODULUS field, in bytes
	PUBKEY_LEN = 384
	/// The length of the SIGNATURE field, in bytes
	SIGNATURE_LEN = PUBKEY_LEN
	/// The length of the ENCLAVEHASH field, in bytes
	MRENCLAVE_LEN = 32
	/// The length of the hash of the signer values, in bytes
	MRSIGNER_LEN = 32
	/// The length of the "Q1" signature verification value
	Q1_LEN = PUBKEY_LEN
	/// The length of the "Q2" signature verification value
	Q2_LEN = PUBKEY_LEN

	RESERVED1_LEN = 84
	RESERVED2_LEN = 20
	RESERVED3_LEN = 32
	RESERVED4_LEN = 12
)
View Source
const (
	BULLETPROOF_DOMAIN_TAG               = "mc_bulletproof_transcript"
	AMOUNT_VALUE_DOMAIN_TAG              = "mc_amount_value"
	AMOUNT_TOKEN_ID_DOMAIN_TAG           = "mc_amount_token_id"
	AMOUNT_BLINDING_DOMAIN_TAG           = "mc_amount_blinding"
	HASH_TO_POINT_DOMAIN_TAG             = "mc_onetime_key_hash_to_point"
	HASH_TO_SCALAR_DOMAIN_TAG            = "mc_onetime_key_hash_to_scalar"
	RING_MLSAG_CHALLENGE_DOMAIN_TAG      = "mc_ring_mlsag_challenge"
	TXOUT_CONFIRMATION_NUMBER_DOMAIN_TAG = "mc_tx_out_confirmation_number"
	AMOUNT_SHARED_SECRET_DOMAIN_TAG      = "mc_amount_shared_secret"
	AMOUNT_BLINDING_FACTORS_DOMAIN_TAG   = "mc_amount_blinding_factors"
	MILLIMOB_TO_PICOMOB                  = 1_000_000_000
	PICOMOB                              = 1_000_000_000_000 // precision = 12
	MOB_MINIMUM_FEE                      = 400_000_000
	MINIMUM_EUSD                         = 1_000_000

	MAX_TOMBSTONE_BLOCKS = 20160
	MAX_INPUTS           = 16
	RING_SIZE            = 11 // Each input ring must contain this many elements.
)
View Source
const (
	PRIMITIVE     = "prim"
	SEQUENCE      = "seq"
	AGGREGATE     = "agg"
	AGGREGATE_END = "agg-end"
	VARIANT       = "var"
	NONE          = ""
)

Variables

View Source
var (
	ZEROV        [84]byte
	HEADER1      = [16]byte{0x06, 0x00, 0x00, 0x00, 0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}
	HEADER2      = [16]byte{0x01, 0x01, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00}
	VENDOR_INTEL = [4]byte{0x00, 0x00, 0x80, 0x86}
	VENDOR_OTHER [4]byte
)

Functions

func AppendPoint

func AppendPoint(label string, p *ristretto.Point, t *merlin.Transcript)

func AppendScalar

func AppendScalar(label string, s *ristretto.Scalar, t *merlin.Transcript)

func ChallengeScalar

func ChallengeScalar(label string, t *merlin.Transcript) *ristretto.Scalar

func ComputeAmountSharedSecretV2 added in v1.2.2

func ComputeAmountSharedSecretV2(secret *ristretto.Point) []byte

compute_amount_shared_secret

func ComputeCommitmentV2 added in v1.2.2

func ComputeCommitmentV2(masked_value uint64, secret []byte) (uint64, error)

compute_commitment

func ConfirmationNumberFromSecret

func ConfirmationNumberFromSecret(buf []byte) []byte

func DecryptEMemoPayload added in v1.1.1

func DecryptEMemoPayload(encryptedMemoStr, txOutPublicKey, viewPrivateKeyStr, spendPrivateKeyStr string) (string, error)

mc_memo_decrypt_e_memo_payload

func DecryptMemo added in v1.1.0

func DecryptMemo(text string, public, private string) ([]byte, error)

func EncryptMemo added in v1.1.0

func EncryptMemo(plain string, public, private string) ([]byte, error)

func GetBlinding

func GetBlinding(secret *ristretto.Point) *ristretto.Scalar

func GetBlindingFactorsV2 added in v1.2.2

func GetBlindingFactorsV2(secret []byte) (uint64, error)

get_blinding_factors

func GetConsensusEnclave

func GetConsensusEnclave(path string) ([]byte, error)

func GetFogReportResponse

func GetFogReportResponse(address string) (*types.ReportResponse, error)

func GetProductionData

func GetProductionData() ([]byte, error)

func GetValue added in v1.2.2

func GetValue(output *TxOut, viewPrivate string) (uint64, error)

func GetValueFromAmountSharedSecretV2 added in v1.2.2

func GetValueFromAmountSharedSecretV2(maskedValue uint64, secret *ristretto.Point) (uint64, error)

get_value_from_amount_shared_secret

func GetValueMask

func GetValueMask(secret *ristretto.Point) uint64

func GetValueV2 added in v1.2.2

func GetValueV2(amount *Amount, viewPrivate, publicKey string) (uint64, error)

func GetValueWithBlinding

func GetValueWithBlinding(output *TxOut, viewPrivate *ristretto.Scalar) (uint64, *ristretto.Scalar)

func GetValueWithBlindingNew

func GetValueWithBlindingNew(viewPrivate, publicKey string, maskedValue uint64) (uint64, *ristretto.Scalar)

func HashOfTxPrefix

func HashOfTxPrefix(tx *TxPrefix) []byte

Convert tx_prefix to merlin transcript

func InnerproductDomainSep

func InnerproductDomainSep(n uint64, t *merlin.Transcript)

func KeyImageFromPrivate

func KeyImageFromPrivate(private *ristretto.Scalar) *ristretto.Point

func MCAccountKeyGetSubAddressPrivateKeys added in v1.1.1

func MCAccountKeyGetSubAddressPrivateKeys(viewPrivateKeyStr, spendPrivateKeyStr string, index uint) (string, string, error)

func MCTxOutMatchesSubaddress added in v1.1.1

func MCTxOutMatchesSubaddress(txOutTargetKeyStr, txOutPublicKeyStr, viewPrivateKeyStr, subaddressSpendPrivateKeyStr string) (bool, error)

func MCTxOutReconstructCommitment added in v1.1.1

func MCTxOutReconstructCommitment(maskedAmountStr, maskedTokenIDStr string, version int64, publicKeyStr, viewPrivateKeyStr string) (string, error)

func MarshalTxOut added in v1.1.1

func MarshalTxOut(input *TxOut) *types.TxOut

func MarshalTxOutMembershipProof added in v1.1.1

func MarshalTxOutMembershipProof(proof *TxOutMembershipProof) *types.TxOutMembershipProof

func McTxOutGetSharedSecret added in v1.1.1

func McTxOutGetSharedSecret(publicKeyStr, viewPrivateKeyStr string) (string, error)

func NewCommitment

func NewCommitment(value uint64, blinding *ristretto.Scalar) *ristretto.Point

func PublicAddressToProtobuf

func PublicAddressToProtobuf(addr *account.PublicAddress) (*types.PublicAddress, error)

Utility method to convert the internal Go PublicAddress to the external GRPC object

func RecoverPublicSubaddressSpendKey

func RecoverPublicSubaddressSpendKey(viewPrivate, onetimePublicKey, publicKey string) (*ristretto.Point, error)

func ValidateAddress added in v1.1.10

func ValidateAddress(recipient string) error

func ValidateFogAddressWithEnclave added in v1.1.10

func ValidateFogAddressWithEnclave(recipient *account.PublicAddress, enclave string) error

Types

type AggregatedGensIter

type AggregatedGensIter struct {
	Array    [][]*ristretto.Point
	N, M     int64
	PartyIdX int64
	GenIdX   int64
}

func (*AggregatedGensIter) Next

func (a *AggregatedGensIter) Next() *ristretto.Point

type Amount

type Amount struct {
	Commitment    string      `json:"commitment"`
	MaskedValue   MaskedValue `json:"masked_value"`
	MaskedTokenID string      `json:"masked_token_id"`
	Version       int64       `json:"version"`
}

type BulletproofGens

type BulletproofGens struct {
	GensCapacity  int64
	PartyCapacity int64
	GVec          [][]*ristretto.Point
	HVec          [][]*ristretto.Point
}

func NewBulletproofGens

func NewBulletproofGens(gensCapacity, partyCapacity int64) *BulletproofGens

func (*BulletproofGens) G

func (*BulletproofGens) H

func (*BulletproofGens) IncreaseCapacity

func (b *BulletproofGens) IncreaseCapacity(capacity int64)

func (*BulletproofGens) Share

type BulletproofGensShare

type BulletproofGensShare struct {
	Gens  *BulletproofGens
	Share int
}

func (*BulletproofGensShare) G

func (g *BulletproofGensShare) G(n int64) []*ristretto.Point

func (*BulletproofGensShare) H

func (g *BulletproofGensShare) H(n int64) []*ristretto.Point

type FeeValue

type FeeValue uint64

func (FeeValue) MarshalJSON

func (fv FeeValue) MarshalJSON() ([]byte, error)

func (*FeeValue) UnmarshalJSON

func (fv *FeeValue) UnmarshalJSON(data []byte) error

type FogFullyValidatedPubkey

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

type GeneratorsChain

type GeneratorsChain struct {
	sha3.ShakeHash
}

func NewGeneratorsChain

func NewGeneratorsChain(label []byte) *GeneratorsChain

func (*GeneratorsChain) FastForward

func (c *GeneratorsChain) FastForward(n int64)

func (*GeneratorsChain) Next

func (c *GeneratorsChain) Next() *ristretto.Point

type InputC added in v1.1.1

type InputC struct {
	ViewPrivate            *ristretto.Scalar
	SpendPrivate           *ristretto.Scalar
	SubAddressSpendPrivate *ristretto.Scalar
	RealIndex              int
	TxOutWithProofCs       []*TxOutWithProofC
}

func BuildRingElements added in v1.1.1

func BuildRingElements(utxos []*UTXO, proofs *Proofs) ([]*InputC, error)

mc_transaction_builder_ring_add_element

type MaskedValue

type MaskedValue uint64

func (MaskedValue) MarshalJSON

func (mv MaskedValue) MarshalJSON() ([]byte, error)

func (*MaskedValue) UnmarshalJSON

func (mv *MaskedValue) UnmarshalJSON(data []byte) error

type Outlay

type Outlay struct {
	Value    string                 `json:"value"`
	Receiver *account.PublicAddress `json:"receiver"`
}

type Output added in v1.1.1

type Output struct {
	TransactionHash string
	RawTransaction  string
	SharedSecret    string
	Fee             uint64
	OutputIndex     int64
	OutputHash      string
	ChangeIndex     int64
	ChangeHash      string
	ChangeAmount    uint64
}

func TransactionBuilderBuild added in v1.1.1

func TransactionBuilderBuild(inputs []*UTXO, proofs *Proofs, output string, amount, fee uint64, tombstone, memo uint64, tokenID, version uint, changeStr string) (*Output, error)

type PedersenGens

type PedersenGens struct {
	B         *ristretto.Point
	BBlinding *ristretto.Point
}

func DefaultPedersenGens

func DefaultPedersenGens() *PedersenGens

func NewPedersenGens

func NewPedersenGens() *PedersenGens

func (*PedersenGens) Commit

func (pg *PedersenGens) Commit(value, blinding *ristretto.Scalar) *ristretto.Point

CommitPedersenGens includes multiscalar_mul

type Proofs

type Proofs struct {
	Ring  []*TxOutWithProof   `json:"ring"`
	Rings [][]*TxOutWithProof `json:"rings"`
}

type Range

type Range struct {
	From string `json:"from"`
	To   string `json:"to"`
}

type RingMLSAG

type RingMLSAG struct {
	CZero     string   `json:"c_zero"`
	Responses []string `json:"responses"`
	KeyImage  string   `json:"key_image"`
}

func UnmarshalRingMLSAG added in v1.1.1

func UnmarshalRingMLSAG(mlsag *types.RingMLSAG) *RingMLSAG

type Signature

type Signature struct {
	Header        [16]byte
	Vendor        [4]byte
	Date          [4]byte
	Header2       [16]byte
	Swdefined     [4]byte
	Reserved1     [RESERVED1_LEN]byte
	Modulus       [384]byte
	Exponent      [4]byte
	Signature     [384]byte
	Miscselect    [4]byte
	Miscmask      [4]byte
	Reserved2     [RESERVED2_LEN]byte
	Attributes    [16]byte
	Attributemask [16]byte
	Enclavehash   [32]byte
	Reserved3     [RESERVED3_LEN]byte
	Isvprodid     [2]byte
	Isvsvn        [2]byte
	Reserved4     [RESERVED4_LEN]byte
	Q1            [384]byte
	Q2            [384]byte
}

func ParseSignature

func ParseSignature() (*Signature, error)

func (*Signature) MRENCLAVE

func (s *Signature) MRENCLAVE() [32]byte

func (*Signature) MrSigner

func (s *Signature) MrSigner() [sha256.Size]byte

func (*Signature) ProductID

func (s *Signature) ProductID() uint16

func (*Signature) Size

func (s *Signature) Size() int

func (*Signature) Version

func (s *Signature) Version() uint16

type SignatureRctBulletproofs

type SignatureRctBulletproofs struct {
	RingSignatures          []*RingMLSAG `json:"ring_signatures"`
	PseudoOutputCommitments []string     `json:"pseudo_output_commitments"`
	RangeProofs             string       `json:"range_proofs"`
}

func UnmarshalSignatureRctBulletproofs added in v1.1.1

func UnmarshalSignatureRctBulletproofs(signature *types.SignatureRctBulletproofs) *SignatureRctBulletproofs

type TombstoneValue

type TombstoneValue uint64

func (TombstoneValue) MarshalJSON

func (tv TombstoneValue) MarshalJSON() ([]byte, error)

func (*TombstoneValue) UnmarshalJSON

func (tv *TombstoneValue) UnmarshalJSON(data []byte) error

type Tx

type Tx struct {
	Prefix    *TxPrefix                 `json:"prefix"`
	Signature *SignatureRctBulletproofs `json:"signature"`
}

func UnmarshalTx added in v1.1.1

func UnmarshalTx(tx *types.Tx) *Tx

type TxC added in v1.1.1

type TxC struct {
	Tx                 []byte
	TxOut              *types.TxOut
	ShareSecretOut     []byte
	ConfirmationOut    []byte
	TxOutChange        *types.TxOut
	ShareSecretChange  []byte
	ConfirmationChange []byte
}

func MCTransactionBuilderCreateC added in v1.1.1

func MCTransactionBuilderCreateC(inputCs []*InputC, amount, changeAmount, fee, tombstone, memo uint64, tokenID, version uint, recipient, change *account.PublicAddress) (*TxC, error)

func MCTransactionBuilderCreateCWithEnclave added in v1.1.7

func MCTransactionBuilderCreateCWithEnclave(inputCs []*InputC, amount, changeAmount, fee, tombstone, memo uint64, tokenID, version uint, recipient, change *account.PublicAddress, enclave string) (*TxC, error)

mc_transaction_builder_create

type TxIn

type TxIn struct {
	Ring   []*TxOut                `json:"ring"`
	Proofs []*TxOutMembershipProof `json:"proofs"`
}

type TxOut

type TxOut struct {
	Amount    *Amount `json:"masked_amount"`
	TargetKey string  `json:"target_key"`
	PublicKey string  `json:"public_key"`
	EFogHint  string  `json:"e_fog_hint"`
	EMemo     string  `json:"e_memo"`
}

func UnmarshalTxOut added in v1.1.1

func UnmarshalTxOut(out *types.TxOut) *TxOut

type TxOutAmount added in v1.1.1

type TxOutAmount struct {
	Value   uint64
	TokenID uint64
}

func MCTxOutGetAmount added in v1.1.1

func MCTxOutGetAmount(maskedAmountStr, maskedTokenIDStr string, version int64, publicKeyStr, viewPrivateKeyStr string) (*TxOutAmount, error)

type TxOutMembershipElement

type TxOutMembershipElement struct {
	Range *Range `json:"range"`
	Hash  string `json:"hash"`
}

type TxOutMembershipProof

type TxOutMembershipProof struct {
	Index        string                    `json:"index"`
	HighestIndex string                    `json:"highest_index"`
	Elements     []*TxOutMembershipElement `json:"elements"`
}

func UnmarshalTxOutMembershipProof added in v1.1.1

func UnmarshalTxOutMembershipProof(proof *types.TxOutMembershipProof) *TxOutMembershipProof

type TxOutWithProof

type TxOutWithProof struct {
	TxOut *TxOut                `json:"tx_out"`
	Proof *TxOutMembershipProof `json:"proof"`
}

type TxOutWithProofC added in v1.1.1

type TxOutWithProofC struct {
	TxOut                *types.TxOut
	TxOutMembershipProof *types.TxOutMembershipProof
}

type TxPrefix

type TxPrefix struct {
	Inputs         []*TxIn        `json:"inputs"`
	Outputs        []*TxOut       `json:"outputs"`
	Fee            FeeValue       `json:"fee"`
	TombstoneBlock TombstoneValue `json:"tombstone_block"`
}

func UnmarshalPrefix added in v1.1.1

func UnmarshalPrefix(prefix *types.TxPrefix) *TxPrefix

type TxProposal

type TxProposal struct {
	InputList                 []*UnspentTxOut `json:"input_list"`
	OutlayList                []*Outlay       `json:"outlay_list"`
	Tx                        *Tx             `json:"tx"`
	Fee                       uint64          `json:"fee"`
	OutlayIndexToTxOutIndex   [][]int         `json:"outlay_index_to_tx_out_index"`
	OutlayConfirmationNumbers [][]int         `json:"outlay_confirmation_numbers"`
}

type UTXO

type UTXO struct {
	TransactionHash string
	Index           uint32
	Amount          uint64
	PrivateKey      string
	ScriptPubKey    string
}

type UnspentTxOut

type UnspentTxOut struct {
	TxOut                   *TxOut `json:"tx_out"`
	SubaddressIndex         uint64 `json:"subaddress_index"`
	KeyImage                string `json:"key_image"`
	Value                   string `json:"value"`
	AttemptedSpendHeight    uint64 `json:"attempted_spend_height"`
	AttemptedSpendTombstone uint64 `json:"attempted_spend_tombstone"`
	MonitorId               string `json:"monitor_id"`
}

Jump to

Keyboard shortcuts

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