本文整理匯總了Golang中code/google/com/p/go/crypto/bn256.G1.Neg方法的典型用法代碼示例。如果您正苦於以下問題:Golang G1.Neg方法的具體用法?Golang G1.Neg怎麽用?Golang G1.Neg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/google/com/p/go/crypto/bn256.G1
的用法示例。
在下文中一共展示了G1.Neg方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Open
// Open reveals which member private key made the given signature. The return
// value will match the result of calling Tag on the member private key in
// question.
func (priv *PrivateKey) Open(sig []byte) ([]byte, bool) {
if len(sig) != 12*32 {
return nil, false
}
t1, ok := new(bn256.G1).Unmarshal(sig[:2*32])
if !ok {
return nil, false
}
t2, ok := new(bn256.G1).Unmarshal(sig[2*32 : 4*32])
if !ok {
return nil, false
}
t3, ok := new(bn256.G1).Unmarshal(sig[4*32 : 6*32])
if !ok {
return nil, false
}
a := new(bn256.G1).ScalarMult(t1, priv.xi1)
b := new(bn256.G1).ScalarMult(t2, priv.xi2)
a.Add(a, b)
a.Neg(a)
a.Add(t3, a)
return a.Marshal(), true
}
示例2: Update
// Update alters mem to create a member private key for an updated Group. (Note
// that the Group of mem must also be updated.) This functions returns false if
// mem is the member private key that has been revoked.
func (mem *MemberKey) Update(r *Revocation) bool {
if mem.x.Cmp(r.x) == 0 {
return false
}
d := new(big.Int).Sub(mem.x, r.x)
d.Mod(d, bn256.Order)
d.ModInverse(d, bn256.Order)
newA := new(bn256.G1).ScalarMult(r.a, d)
t := new(bn256.G1).ScalarMult(mem.a, d)
t.Neg(t)
newA.Add(newA, t)
mem.a = newA
return true
}