3 Star 6 Fork 7

Gitee 极速下载/Hyperledger fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/hyperledger/fabric
克隆/下载
weak-bb.go 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
Manu Drijvers 提交于 2018-04-27 21:00 . [FAB-8921] adds weak-bb signatures
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package idemix
import (
"github.com/hyperledger/fabric-amcl/amcl"
"github.com/hyperledger/fabric-amcl/amcl/FP256BN"
"github.com/pkg/errors"
)
// WBBKeyGen creates a fresh weak-Boneh-Boyen signature key pair (http://ia.cr/2004/171)
func WBBKeyGen(rng *amcl.RAND) (*FP256BN.BIG, *FP256BN.ECP2) {
// sample sk uniform from Zq
sk := RandModOrder(rng)
// set pk = g2^sk
pk := GenG2.Mul(sk)
return sk, pk
}
// WBBSign places a weak Boneh-Boyen signature on message m using secret key sk
func WBBSign(sk *FP256BN.BIG, m *FP256BN.BIG) *FP256BN.ECP {
// compute exp = 1/(m + sk) mod q
exp := Modadd(sk, m, GroupOrder)
exp.Invmodp(GroupOrder)
// return signature sig = g1^(1/(m + sk))
return GenG1.Mul(exp)
}
// WBBVerify verifies a weak Boneh-Boyen signature sig on message m with public key pk
func WBBVerify(pk *FP256BN.ECP2, sig *FP256BN.ECP, m *FP256BN.BIG) error {
if pk == nil || sig == nil || m == nil {
return errors.Errorf("Weak-BB signature invalid: received nil input")
}
// Set P = pk * g2^m
P := FP256BN.NewECP2()
P.Copy(pk)
P.Add(GenG2.Mul(m))
P.Affine()
// check that e(sig, pk * g2^m) = e(g1, g2)
if !FP256BN.Fexp(FP256BN.Ate(P, sig)).Equals(GenGT) {
return errors.Errorf("Weak-BB signature is invalid")
}
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/fabric.git
git@gitee.com:mirrors/fabric.git
mirrors
fabric
Hyperledger fabric
v1.2.1

搜索帮助