交易
Transaction_Prefix
前缀,又可称之为“交易头”。
// the core transaction
type Transaction_Prefix struct {
Version uint64 `json:"version"`
Unlock_Time uint64 `json:"unlock_time"` // used to lock first output
Vin []Txin_v
Vout []Tx_out
Extra []byte
Extra_map map[EXTRA_TAG]interface{} `json:"-"` // all information parsed from extra is placed here
PaymentID_map map[EXTRA_TAG]interface{} `json:"-"` // payments id parsed or set are placed her
ExtraType byte `json:"-"` // NOT used, candidate for deletion
}
Transaction
由前缀、后缀,即交易头、签名组成。
type Transaction struct {
Transaction_Prefix
// same as Transaction_Prefix
// Signature not sure of what form
Signature []Signature_v1 `json:"-"` // old format, the array size is always equal to vin length,
//Signature_RCT RCT_Signature // version 2
RctSignature *ringct.RctSig
Expanded bool `json:"-"`
}
签名,又可称之为“后缀”,对应的数据结构参考 rct/ringct
里对应的章节。
“交易”数据结构拆分:
前缀(交易头),后缀(交易体、签名)
前缀:输入、输出、额外数据、交易基础数据
签名:签名基础数据、签名数据
输入:密钥镜像 + 环成员
输出:一次性地址
额外数据:支付ID、交易公钥、智能合约源代码
签名基础数据:输入见证、输出见证、手续费、加密的交易金额
签名数据:范围证明、环签名
签名基础数据,可以包含环成员;
签名数据里的环签名,会生成密钥镜像;
上述两者在输入里均已存在,为避免重复只保留一份。
其它相关数据结构:
除了这里的“Transaction”外,我们还有一些和“交易”相关的数据结构。
数据来源 - 它们数据来源于交易和区块。
完整性 - 一对一比较,它们不如“交易”和“区块”完整,但却是非常必要的补充。
作用 - 方便后续使用。
算法:
Hp 哈希转椭圆曲线
Hs 散列哈希
输入见证 pseudoOuts
输出见证 OutPk
加密的金额 ECdhInfo/ECdhTuple
范围证明 RangeSig/BoroSig
防弹协议 BulletSigs/BulletProof
环签名 RctSignature/MlsagSigs/RingCT
一次性地址 P
密钥镜像 I/II
环成员 MixRing/Ring_Member
手续费 txFee
挖矿算法 CryptoNight
ECDH 密钥交换