和环签名相关的方法

并不是所有和环签名相关的方法都放这里,只是很小的一部分,归纳如下:

  • 序列化(将对象转换成字节)
  • 格式化(反序列化,将字节转换成对象)
  • 验证总输入等于总输出+交易费、验证范围证明、验证环签名(验签)
  • 金额加解密(钱包,以及 Web 客户端证明发送交易会用到)

SerializeBase

RctSigBase 序列化

BaseHash

封装上面的 SerializeBase,序列化后获取散列哈希值

SerializePrunable

序列化 RctSig 的部分数据(范围证明、环签名)

Get_Sig_Type

Get_TX_Fee

PrunableHash

封装上面的 SerializePrunable,序列化后获取散列哈希值

Verify

封装下面 3 个验证方法。

// this is the function which should be used by external world
// if any exceptions occur while handling, we simply return false
// transaction must be expanded before verification
// coinbase transactions are always success, since they are tied to PoW of block

总出口,虽然内容都是调用其它方法。

VerifyRctSimple

验证方法之一。

会验证总输出 + 手续费是否等于总输入,结尾是封装 VerifyRCTSimple_Core.

// Verify a RCTTypeSimple RingCT Signature

VerifyRctSimpleBulletProof

验证方法之一。

会验证总输出 + 手续费是否等于总输入,结尾是封装 VerifyRCTSimple_Core.

// Verify a RCTTypeSimple RingCT Signature

VerifyRctFull

验证方法之一。

结尾是封装 VerifyRCTFull_Core.

其它函数

(它们不是 RctSig 或者其它实例方法)

ParseCtKey

将 buf 数据格式化

ParseKey64

将 buf 数据格式化

ParseBoroSig

// parse Borromean signature

将 buf 数据格式化

ParseRangeSig

// range data consists of Single Borromean sig and 64 keys for 64 bits

将 buf 数据格式化

ParseRingCtSignature

// parser for ringct signature
// we need to be extra cautious as almost anything cam come as input

将 buf 数据格式化

ParseBulletProof

将 buf 数据格式化

ecdhEncode

   //Elliptic Curve Diffie Helman: encodes and decodes the amount b and mask a
   // where C= aG + bH
   void ecdhEncode(ecdhTuple & unmasked, const key & sharedSec) {
       key sharedSec1 = hash_to_scalar(sharedSec);
       key sharedSec2 = hash_to_scalar(sharedSec1);
       //encode
       sc_add(unmasked.mask.bytes, unmasked.mask.bytes, sharedSec1.bytes);
       sc_add(unmasked.amount.bytes, unmasked.amount.bytes, sharedSec2.bytes);
   }

ecdhDecode

   //Elliptic Curve Diffie Helman: encodes and decodes the amount b and mask a
   // where C= aG + bH
   void ecdhDecode(ecdhTuple & masked, const key & sharedSec) {
       key sharedSec1 = hash_to_scalar(sharedSec);
       key sharedSec2 = hash_to_scalar(sharedSec1);
       //decode
       sc_sub(masked.mask.bytes, masked.mask.bytes, sharedSec1.bytes);
       sc_sub(masked.amount.bytes, masked.amount.bytes, sharedSec2.bytes);
   }

Decode_Amount

// decode and verify a previously encrypted tuple
// the keys come in from the wallet
// tuple is the encoded data
// skey is the secret scalar key
// outpk is public key used to verify whether the decode was sucessfull

genC

根据公式 C = rG + vH 得到 C

/* from rctOps.cpp
//generates C =aG + bH from b, a is given..
    void genC(key & C, const key & a, xmr_amount amount) {
        key bH = scalarmultH(d2h(amount));
        addKeys1(C, a, bH);
    }
*/
// Commit X amount to random  // see Commitment_From_Amount and ZeroCommitment_From_Amount in key.go

基础算法,和具体业务无关。

results matching ""

    No results matching ""