您当前的位置: 首页 > 

mutourend

暂无认证

  • 1浏览

    0关注

    661博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Mina中的Schnorr signature

mutourend 发布时间:2022-03-22 17:47:25 ,浏览量:1

1. 引言

前序博客有:

  • ECDSA VS Schnorr signature VS BLS signature

Mina系列博客有:

  • Mina概览
  • Mina的支付流程
  • Mina的zkApp
  • Mina中的Pasta(Pallas和Vesta)曲线

Mina基于Pasta曲线实现了相应的Schnorr signature。

Mina中采用Schnorr签名对支付交易 和 质押委托交易进行签名的代码示例有:

  • https://github.com/MinaProtocol/c-reference-signer(C语言)
  • https://github.com/MinaProtocol/signer-reference(OCaml语言)

Mina Schnorr签名模块实现有:

  • O(1) Labs团队 proof-systems中的Schnorr签名模块(Rust语言)
  • Mina Protocol官方Schnorr签名模块(OCaml语言)
  • Ledger Nano S 和 Nano X 硬件钱包中集成的Mina Schnorr签名模块(C语言)
2. Mina中的Schnorr signature实现

Mina中的Schnorr签名方案不同于Bitcoin的Schnorr signature方案,Bitcoin的签名结果为 ( R , s ) (R,s) (R,s),而Mina的签名结果为 ( R . x , s ) (R.x, s) (R.x,s)。其中 R ∈ G , R . x ∈ F p , s ∈ F r R\in \mathbb{G},R.x\in \mathbb{F}_p, s\in\mathbb{F}_r R∈G,R.x∈Fp​,s∈Fr​, G \mathbb{G} G为group point, F p \mathbb{F}_p Fp​为base field, F r \mathbb{F}_r Fr​为scalar field。

Mina中的Schnoor签名方案见Mina Schnorr Signatures: Mina Schnorr签名流程:

  • Input:
    • Secret key d: an integer in the range 1..n-1
    • Public key P: a curve point
    • Message m: message to be signed
    • Network id id: blockchain instance identifier
  • To sign m for public key P = dG:
    • Let k = derive_nonce(d, P, m, id)
    • Let R = [k]G
    • If odd(y(R)) then negate(k)
    • Let e = message_hash(P, x(R), m, id)
    • Let s = k + e*d
  • The signature σ = (x(R), s)

Mina Schnorr验签流程:

  • Input:
    • Public key P: a curve point
    • Message m: message
    • Signature σ: signature on m
    • Network id id: blockchain instance identifier
  • The signature is valid if and only if the algorithm below does not fail.
    • Let e = message_hash(P, x(R), m, id)
    • Let R = [s(σ)]G - [e]P
    • Fail if infinite(R) OR odd(y(R)) OR x(R) != x(σ)

实际代码实现时,根据不同的network id设置了不同的derive_nonce派生实现:

let derive =
      let open Mina_signature_kind in
      match signature_kind with
      | None ->
          Message.derive
      | Some Mainnet ->
          Message.derive_for_mainnet
      | Some Testnet ->
          Message.derive_for_testnet
参考资料

[1] Mina Schnorr Signatures

附录1. Mina系列博客

Mina系列博客有:

  • Mina概览
  • Mina的支付流程
  • Mina的zkApp
  • Mina中的Pasta(Pallas和Vesta)曲线
  • Mina中的Schnorr signature
  • Mina中的Pickles SNARK
  • Mina中的Kimchi SNARK
  • Mina Kimchi SNARK 代码解析
  • Mina Berkeley QANet测试网zkApp初体验
  • Mina中的Poseidon hash
  • Mina中的多项式承诺方案
  • Recursive SNARKs总览
  • Mina技术白皮书
  • Mina代码解析
  • Mina中的Snark Worker
  • Mina中的Scan State
  • Mina中的VRF
  • Mina中的delta_transition_chain_proof/delta_block_chain_proof
  • Mina中的stake delegation
  • Mina如何实现22KB?
  • Mina中的stake_proof
关注
打赏
1664532908
查看更多评论
立即登录/注册

微信扫码登录

0.0384s