Mina中的Schnorr signature

1. 引言

前序博客有:

Mina系列博客有:

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

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

Mina Schnorr签名模块实现有:

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 RG,R.xFp,sFr 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系列博客有:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值