func (priv *PrivateKey) NewMember(r io.Reader) (*MemberKey, error) {
	mem := new(MemberKey)
	var err error
	mem.Group = priv.Group
	mem.x, err = randomZp(r)
	if err != nil {
		return nil, err
	}
	s := new(big.Int).Add(priv.gamma, mem.x)
	s.ModInverse(s, bn256.Order)
	mem.a = new(bn256.G1).ScalarMult(priv.g1, s)
	return mem, nil
}
NewMember creates a new member private key for the group.
package bbssig
import (
	"crypto/rand"
	"hash"
	"io"
	"math/big"
	"golang.org/x/crypto/bn256"
)
const SignatureSize = 12 * 32
type Group struct {
	g1, h, u, v           *bn256.G1
	g2, w                 *bn256.G2
	ehw, ehg2, minusEg1g2 *bn256.GT
}
func (g *Group) Marshal() []byte {
	out := make([]byte, 0, 4*2*32+2*2*2*32)
	out = append(out, g.g1.Marshal()...)
	out = append(out, g.h.Marshal()...)
	out = append(out, g.u.Marshal()...)
	out = append(out, g.v.Marshal()...)
	out = append(out, g.g2.Marshal()...)
	out = append(out, g.w.Marshal()...)
	return out
}
func (g *Group) Unmarshal(b []byte) (*Group, bool) {
	if len(b) != 4*2*32+2*2*2*32 {
		return nil, false
	}
	var ok bool
	if g.g1, ok = new(bn256.G1).Unmarshal(b[0*2*32 : 1*2*32]); !ok {
		return nil, false
	}
	if g.h, ok = new(bn256.G1).Unmarshal(b[1*2*32 : 2*2*32]); !ok {
		return nil, false
	}
	if g.u, ok = new(bn256.G1).Unmarshal(b[2*2*32 : 3*2*32]); !ok {
		return nil, false
	}
	if g.v, ok = new(bn256.G1).Unmarshal(b[3*2*32 : 4*2*32]); !ok {
		return nil, false
	}
	b = b[4*2*32:]
	if g.g2, ok = new(bn256.G2).Unmarshal(b[0*2*2*32 : 1*2*2*32]); !ok {
		return nil, false
	}
	if g.w, ok = new(bn256.G2).Unmarshal(b[1*2*2*32 : 2*2*2*32]); !ok {
		return nil, false
	}
	g.precompute()
	return g, true
}
func (g *Group) precompute() {
	g.ehw = bn256.Pair(g.h, g.w)
	g.ehg2 = bn256.Pair(g.h, g.g2)
	t := bn256.Pair(g.g1, g.g2)
	g.minusEg1g2 = new(bn256.GT).Neg(t)
}
type PrivateKey struct {
	*Group
	xi1, xi2 *big.Int
	gamma    *big.Int
}
func (priv *PrivateKey) Marshal() []byte {
	out := make([]byte, 0, 3*32)
	out = appendN(out, priv.xi1)
	out = appendN(out, priv.xi2)
	out = appendN(out, priv.gamma)
	return out
}
func (priv *PrivateKey) Unmarshal(g *Group, b []byte) (*PrivateKey, bool) {
	if len(b) != 3*32 {
		return nil, false
	}
	priv.Group = g
	priv.xi1 = new(big.Int).SetBytes(b[0*32 : 1*32])
	priv.xi2 = new(big.Int).SetBytes(b[1*32 : 2*32])
	priv.gamma = new(big.Int).SetBytes(b[2*32 : 3*32])
	return priv, true
}
type MemberKey struct {
	*Group
	x *big.Int
	a *bn256.G1
}
func (mem *MemberKey) Tag() []byte {
	return mem.a.Marshal()
}
func (mem *MemberKey) Marshal() []byte {
	out := make([]byte, 0, 3*32)
	out = appendN(out, mem.x)
	out = append(out, mem.a.Marshal()...)
	return out
}
func (mem *MemberKey) Unmarshal(g *Group, b []byte) (*MemberKey, bool) {
	if len(b) != 3*32 {
		return nil, false
	}
	var ok bool
	mem.Group = g
	mem.x = new(big.Int).SetBytes(b[0*32 : 1*32])
	if mem.a, ok = new(bn256.G1).Unmarshal(b[1*32:]); !ok {
		return nil, false
	}
	return mem, true
}
func randomZp(r io.Reader) (*big.Int, error) {
	for {
		n, err := rand.Int(r, bn256.Order)
		if err != nil {
			return nil, err
		}
		if n.Sign() > 0 {
			return n, nil
		}
	}
	panic("unreachable")
}
func GenerateGroup(r io.Reader) (*PrivateKey, error) {
	priv := new(PrivateKey)
	priv.Group = new(Group)
	var err error
	if _, priv.g1, err = bn256.RandomG1(r); err != nil {
		return nil, err
	}
	if _, priv.g2, err = bn256.RandomG2(r); err != nil {
		return nil, err
	}
	if _, priv.h, err = bn256.RandomG1(r); err != nil {
		return nil, err
	}
	if priv.xi1, err = randomZp(r); err != nil {
		return nil, err
	}
	if priv.xi2, err = randomZp(r); err != nil {
		return nil, err
	}
	z0 := new(big.Int).ModInverse(priv.xi1, bn256.Order)
	priv.u = new(bn256.G1).ScalarMult(priv.h, z0)
	z0.ModInverse(priv.xi2, bn256.Order)
	priv.v = new(bn256.G1).ScalarMult(priv.h, z0)
	priv.gamma, err = randomZp(r)
	if err != nil {
		return nil, err
	}
	priv.w = new(bn256.G2).ScalarMult(priv.g2, priv.gamma)
	priv.precompute()
	return priv, nil
}