zanobase

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize(rx io.Reader, target any) error

Deserialize implements epee deserializer (kind of)

func ReadVarBytes

func ReadVarBytes(r io.Reader) ([]byte, error)

func Serialize

func Serialize(w io.Writer, source any) error

func VariantAs

func VariantAs[T any](p *Variant) T

func VarintAppendUint64

func VarintAppendUint64(buf []byte, v uint64) []byte

func VarintPackedSize

func VarintPackedSize(v uint64) int

func VarintReadUint64

func VarintReadUint64(r io.ByteReader) (uint64, error)

func VarintTakeUint64

func VarintTakeUint64(buf []byte) ([]byte, uint64, error)

Types

type AccountPublicAddr

type AccountPublicAddr struct {
	SpendKey Value256
	ViewKey  Value256
	Flags    uint8
}

type BGEProof

type BGEProof struct {
	A  *Point    // public_key, premultiplied by 1/8
	B  *Point    // public_key, premultiplied by 1/8
	Pk []*Point  // premultiplied by 1/8, size = m
	F  []*Scalar // scalar_vec_t size = m * (n - 1)
	Y  *Scalar   // scalar_t
	Z  *Scalar   // scalar_t
}

type BPPSignature

type BPPSignature struct {
	Lv    []*Point // std::vector<public_key> size = ceil( log_2(m * n) )
	Rv    []*Point // std::vector<public_key>
	A0    *Point   // public_key
	A     *Point   // public_key
	B     *Point   // public_key
	R     *Scalar  // scalar_t
	S     *Scalar  // scalar_t
	Delta *Scalar  // scalar_t
}

type CLSAG_GGX_Input

type CLSAG_GGX_Input struct {
	BlindedAssetId   Value256
	StealthAddress   Value256
	AmountCommitment Value256
}

type CLSAG_Sig

type CLSAG_Sig struct {
	C  *Scalar   // scalar_t
	Rg []*Scalar // for G-components (layers 0, 1),    size = size of the ring
	Rx []*Scalar // for X-component  (layer 2),        size = size of the ring
	K1 *Point    // public_key auxiliary key image for layer 1 (G)
	K2 *Point    // public_key auxiliary key image for layer 2 (X)
}

type GenContext

type GenContext struct {
	AssetIds                            []*Point
	BlindedAssetIds                     []*Point
	AmountCommitments                   []*Point
	AssetIdBlindingMasks                []*Scalar
	Amounts                             []*Scalar
	AmountBlindingMasks                 []*Scalar
	PseudoOutsBlindedAssetIds           []*Point
	PseudoOutsPlusRealOutBlindingMasks  []*Scalar
	RealZcInsAssetIds                   []*Point
	ZcInputAmounts                      []uint64
	PseudoOutAmountCommitmentsSum       *Point
	PseudoOutAmountBlindingMasksSum     *Scalar
	RealInAssetIdBlindingMaskXAmountSum *Scalar
	AmountCommitmentsSum                *Point
	AmountBlindingMasksSum              *Scalar
	AssetIdBlindingMaskXAmountSum       *Scalar
	AoAssetId                           *Point
	AoAssetIdPt                         *Point
	AoAmountCommitment                  *Point
	AoAmountBlindingMask                *Scalar
	AoCommitmentInOutputs               bool
	TxKey                               *KeyPair
	TxPubKeyP                           *Point
}

func (*GenContext) Resize

func (g *GenContext) Resize(inCnt, outCnt int)

type GenericDoubleSchnorrSig

type GenericDoubleSchnorrSig struct {
	C  *Scalar
	Y0 *Scalar
	Y1 *Scalar
}

type KeyImageIndex

type KeyImageIndex struct {
	OutIndex uint64
	Image    Value256 // ec_point
}

type KeyPair

type KeyPair struct {
	// TODO KeyPair doesn't have a BEGIN_SERIALIZE_OBJECT
	Pub *Point
	Sec *Scalar
}

type Payload deprecated

type Payload = Variant

Payload type is actually Variant

Deprecated: use Variant, this will be removed

type Point

type Point struct {
	*edwards25519.Point
}

func (*Point) MarshalJSON

func (p *Point) MarshalJSON() ([]byte, error)

func (*Point) ReadFrom

func (p *Point) ReadFrom(r io.Reader) (int64, error)

func (*Point) WriteTo

func (p *Point) WriteTo(w io.Writer) (int64, error)

type RefById

type RefById struct {
	Hash Value256 // source transaction hash
	N    uint32   // output index in source transaction
}

type Scalar

type Scalar struct {
	*edwards25519.Scalar
}

func (*Scalar) MarshalJSON

func (s *Scalar) MarshalJSON() ([]byte, error)

func (*Scalar) ReadFrom

func (s *Scalar) ReadFrom(r io.Reader) (int64, error)

func (*Scalar) WriteTo

func (s *Scalar) WriteTo(w io.Writer) (int64, error)

type Tag

type Tag uint8
const (
	TagGen                    Tag = 0
	TagDerivationHint         Tag = 11
	TagPubKey                 Tag = 22
	TagEtcTxFlags16           Tag = 23
	TagDeriveXor              Tag = 24
	TagRefById                Tag = 25
	TagUint64                 Tag = 26
	TagUint32                 Tag = 28
	TagTxinZcInput            Tag = 37
	TagTxOutZarcanum          Tag = 38
	TagZarcaniumTxDataV1      Tag = 39
	TagZCSig                  Tag = 43
	TagZcAssetSurjectionProof Tag = 46
	TagZcOutsRangeProof       Tag = 47
	TagZcBalanceProof         Tag = 48
)

func TagFor

func TagFor[T any]() Tag

func (Tag) New

func (t Tag) New() any

func (Tag) Type

func (t Tag) Type() reflect.Type

type Transaction

type Transaction struct {
	Version Varint     `json:"version"` // varint, ==2
	Vin     []*Variant `json:"vin"`     // txin_v = boost::variant<txin_gen[0], txin_to_key[1], txin_multisig[2], txin_htlc[34], txin_zc_input[37]>
	Extra   []*Variant `json:"extra"`   // extra_v
	Vout    []*Variant `json:"vout"`    // tx_out_v = boost::variant<tx_out_bare[36], tx_out_zarcanum[38]>
	// up to here this was transaction_prefix
	Attachment []*Variant `json:"attachment,omitempty"`
	Signatures []*Variant `json:"signatures"` // signature_v = boost::variant<NLSAG_sig, void_sig, ZC_sig, zarcanum_sig>
	Proofs     []*Variant `json:"proofs"`     // proof_v
}

func (*Transaction) GetFee

func (tx *Transaction) GetFee() (uint64, bool)

func (*Transaction) Prefix

func (tx *Transaction) Prefix() *TransactionPrefix

type TransactionPrefix

type TransactionPrefix struct {
	Version Varint     `json:"version"` // varint, ==2
	Vin     []*Variant `json:"vin"`     // txin_v = boost::variant<txin_gen[0], txin_to_key[1], txin_multisig[2], txin_htlc[34], txin_zc_input[37]>
	Extra   []*Variant `json:"extra"`   // extra_v
	Vout    []*Variant `json:"vout"`    // tx_out_v = boost::variant<tx_out_bare[36], tx_out_zarcanum[38]>
}

func (*TransactionPrefix) Hash

func (txp *TransactionPrefix) Hash() ([]byte, error)

Hash of a transaction prefix. Can fail if the variants contains invalid data

type TransactionV3 added in v0.0.2

type TransactionV3 struct {
	Version Varint     `json:"version"` // varint, ==2
	Vin     []*Variant `json:"vin"`     // txin_v = boost::variant<txin_gen[0], txin_to_key[1], txin_multisig[2], txin_htlc[34], txin_zc_input[37]>
	Extra   []*Variant `json:"extra"`   // extra_v
	Vout    []*Variant `json:"vout"`    // tx_out_v = boost::variant<tx_out_bare[36], tx_out_zarcanum[38]>
	// up to here this was transaction_prefix
	Attachment []*Variant `json:"attachment,omitempty"`
	Signatures []*Variant `json:"signatures"`  // signature_v = boost::variant<NLSAG_sig, void_sig, ZC_sig, zarcanum_sig>
	Proofs     []*Variant `json:"proofs"`      // proof_v
	HardforkId uint8      `json:"hardfork_id"` // uint8_t
}

type TxInGen

type TxInGen struct {
	Height uint64
}

type TxInZcInput

type TxInZcInput struct {
	// referring_input
	KeyOffsets []*Payload `json:"key_offsets"` // std::vector<txout_ref_v>; typedef boost::variant<uint64_t, ref_by_id> txout_ref_v
	// txin_zc_input
	KeyImage   *Point     `json:"key_image"`             // crypto::key_image = ec_point
	EtcDetails []*Payload `json:"etc_details,omitempty"` // std::vector<txin_etc_details_v> = std::vector<boost::variant<signed_parts, extra_attachment_info>>
}

type TxOutZarcanium

type TxOutZarcanium struct {
	// tx_out_zarcanum
	StealthAddress   Value256
	ConcealingPoint  Value256 // group element Q, see also Zarcanum paper, premultiplied by 1/8
	AmountCommitment Value256 // premultiplied by 1/8
	BlindedAssetId   Value256 // group element T, premultiplied by 1/8
	EncryptedAmount  uint64
	MixAttr          uint8
}

type UGAggProof

type UGAggProof struct {
	AmountCommitmentsForRPAgg []*Point  `json:"amount_commitments_for_rp_aggregation"` // std::vector<public_key> E' = e * U + y' * G, premultiplied by 1/8
	Y0s                       []*Scalar `json:"y0s"`                                   // scalar_vec_t
	Y1s                       []*Scalar `json:"y1s"`                                   // scalar_vec_t
	C                         *Scalar   `json:"c"`                                     // common challenge
}

type Value256

type Value256 [32]byte

func ReadVec32

func ReadVec32(r io.Reader) ([]Value256, error)

func (Value256) B32

func (v Value256) B32() [32]byte

func (Value256) Bytes

func (v Value256) Bytes() []byte

func (Value256) IsZero

func (v Value256) IsZero() bool

func (Value256) MarshalJSON

func (v Value256) MarshalJSON() ([]byte, error)

func (*Value256) PB32

func (v *Value256) PB32() *[32]byte

func (*Value256) ReadFrom

func (v *Value256) ReadFrom(r io.Reader) (int64, error)

func (Value256) String

func (v Value256) String() string

func (*Value256) ToPoint

func (v *Value256) ToPoint() *edwards25519.Point

type Variant

type Variant struct {
	Tag   Tag
	Value any // any type stored as a boost::variant
}

func VariantFor

func VariantFor[T any](obj T) *Variant

func (*Variant) MarshalJSON

func (p *Variant) MarshalJSON() ([]byte, error)

type Varint

type Varint uint64

func (Varint) Bytes

func (v Varint) Bytes() []byte

func (*Varint) ReadFrom

func (v *Varint) ReadFrom(r io.Reader) (int64, error)

type ZCAssetSurjectionProof

type ZCAssetSurjectionProof struct {
	// zc_asset_surjection_proof
	BGEProofs []*BGEProof // std::vector<crypto::BGE_proof_s> bge_proofs
}

type ZCBalanceProof

type ZCBalanceProof struct {
	// zc_balance_proof
	DSS *GenericDoubleSchnorrSig // crypto::generic_double_schnorr_sig_s
}

First part of a double Schnorr proof:

  1. for txs without ZC inputs: proves that balance point = lin(G) (cancels out G component of outputs' amount commitments, asset tags assumed to be H (native coin) and non-blinded)
  2. for txs with ZC inputs: proves that balance point = lin(X) (cancels out X component of blinded asset tags within amount commitments for both outputs and inputs (pseudo outs))

Second part:

proof of knowing transaction secret key (with respect to G)

type ZCOutsRangeProof

type ZCOutsRangeProof struct {
	// zc_outs_range_proof
	BPP *BPPSignature // for commitments in form: amount * U + mask * G
	// crypto::vector_UG_aggregation_proof_serialized
	AggregationProof *UGAggProof // E'_j = e_j * U + y'_j * G    +   vector Shnorr
}

type ZCSig

type ZCSig struct {
	// ZC_sig
	PseudoOutAmountCommitment *Point // premultiplied by 1/8
	PseudoOutBlindedAssetId   *Point // premultiplied by 1/8
	// crypto::CLSAG_GGX_signature_serialized clsags_ggx
	GGX *CLSAG_Sig
}

type ZarcaniumTxDataV1

type ZarcaniumTxDataV1 struct {
	Fee uint64 `json:"fee"`
}

Jump to

Keyboard shortcuts

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