本文整理汇总了Golang中github.com/agl/pond/bbssig.Group类的典型用法代码示例。如果您正苦于以下问题:Golang Group类的具体用法?Golang Group怎么用?Golang Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Group类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var err error
var challenge []byte
var response []byte
var group *bbssig.Group = new(bbssig.Group)
var gfile *os.File
gfile, err = os.Open(os.Args[3])
if err != nil {
log.Fatal(err)
}
var ghandle = bufio.NewReader(gfile)
{
var gb = basepack.Unpack(ghandle)
var success bool
_, success = group.Unmarshal(gb)
if !success {
log.Fatal("Unable to unmarshal public key")
}
}
challenge, err = base64.StdEncoding.DecodeString(os.Args[1])
if err != nil {
log.Fatal("Invalid challenge")
}
response, err = base64.StdEncoding.DecodeString(os.Args[2])
if err != nil {
log.Fatal("Invalid response")
}
if group.Verify(challenge, sha256.New(), response) {
fmt.Printf("yes\n")
os.Exit(0)
} else {
fmt.Printf("no\n")
os.Exit(1)
}
}
示例2: main
func main() {
var err error
var ofhandle *os.File
ofhandle, err = os.Create(os.Args[1])
if err != nil {
log.Fatal(err)
}
var privhandle *os.File
privhandle, err = os.Open(os.Args[2])
if err != nil {
log.Fatal(err)
}
var privreader *bufio.Reader
privreader = bufio.NewReader(privhandle)
var group *bbssig.Group = new(bbssig.Group)
var privkey *bbssig.PrivateKey = new(bbssig.PrivateKey)
var part *bbssig.MemberKey = new(bbssig.MemberKey)
var randreader *os.File
randreader, err = os.Open("/dev/random")
if err != nil {
log.Fatal(err)
}
var gb []byte
{
gb = basepack.Unpack(privreader)
var success bool
_, success = group.Unmarshal(gb)
if !success {
log.Fatal("Unable to unpack group data")
}
var pb = basepack.Unpack(privreader)
_, success = privkey.Unmarshal(group, pb)
if !success {
log.Fatal("Unable to unpack private key")
}
}
part, err = privkey.NewMember(randreader)
if err != nil {
log.Fatal(err)
}
{
var partbyte = part.Marshal()
objpack.PackGroup(ofhandle, part.Group)
basepack.Packout(ofhandle, partbyte)
fmt.Printf("Tag for part is ")
basepack.Packout(os.Stdout, part.Tag())
}
ofhandle.Close()
privhandle.Close()
randreader.Close()
}
示例3: UnPackPart
func UnPackPart(partreader *bufio.Reader, group *bbssig.Group,
part *bbssig.MemberKey) {
var gb = basepack.Unpack(partreader)
var success bool
_, success = group.Unmarshal(gb)
if !success {
log.Fatal("Unable to unpack group")
}
var mb = basepack.Unpack(partreader)
_, success = part.Unmarshal(group, mb)
if !success {
log.Fatal("Unable to unpack part")
}
}
示例4: main
func main() {
var err error
var group = new(bbssig.Group)
var sk = new(bbssig.PrivateKey)
var part = new(bbssig.MemberKey)
var rev *bbssig.Revocation
var revbyte []byte
var partfile *os.File
partfile, err = os.Open(os.Args[1])
if err != nil {
log.Fatal(err)
}
var privfile *os.File
privfile, err = os.Open(os.Args[2])
if err != nil {
log.Fatal(err)
}
var partreader = bufio.NewReader(partfile)
var privreader = bufio.NewReader(privfile)
/* Now we have a detail, namely need to skip some stuff from
the part file before we can use it. But first load the
private key*/
{
var gb = basepack.Unpack(privreader)
var success bool
_, success = group.Unmarshal(gb)
if !success {
log.Fatal("Could not load key")
}
var sb = basepack.Unpack(privreader)
_, success = sk.Unmarshal(group, sb)
if !success {
log.Fatal("Could not load private key")
}
}
{
var success bool
basepack.Unpack(partreader) /*Skip first entry*/
var memb = basepack.Unpack(partreader)
_, success = part.Unmarshal(group, memb)
if !success {
log.Fatal("Part could not be upacked")
}
}
rev = sk.GenerateRevocation(part)
revbyte = rev.Marshal()
fmt.Printf("The revokation string is %s\n",
base64.StdEncoding.EncodeToString(revbyte))
}
示例5: main
func main() {
var err error
var group = new(bbssig.Group)
var priv = new(bbssig.PrivateKey)
var privhandle *os.File
privhandle, err = os.Open(os.Args[2])
if err != nil {
log.Fatal(err)
}
var privreader *bufio.Reader
privreader = bufio.NewReader(privhandle)
{
var gp []byte
var success bool
gp = basepack.Unpack(privreader)
_, success = group.Unmarshal(gp)
if !success {
log.Fatal("Unable to read group data")
}
var pb []byte
pb = basepack.Unpack(privreader)
_, success = priv.Unmarshal(group, pb)
if !success {
log.Fatal("Unable to read private key")
}
}
var sig []byte
sig, err = base64.StdEncoding.DecodeString(os.Args[1])
if err != nil {
log.Fatal("Signature is invalid")
}
var tag []byte
var success bool
tag, success = priv.Open(sig)
if !success {
log.Fatal("Signature unknown")
} else {
fmt.Printf("The tag is %s\n", base64.StdEncoding.EncodeToString(tag))
}
}
示例6: revocation
func (s *Server) revocation(from *[32]byte, signedRevocation *pond.SignedRevocation) *pond.Reply {
account, ok := s.getAccount(from)
if !ok {
return &pond.Reply{Status: pond.Reply_NO_ACCOUNT.Enum()}
}
revocation, ok := new(bbssig.Revocation).Unmarshal(signedRevocation.Revocation.Revocation)
if !ok {
return &pond.Reply{Status: pond.Reply_CANNOT_PARSE_REVOCATION.Enum()}
}
// First check that the account doesn't have too many revocations
// stored.
revPath := account.RevocationPath()
os.MkdirAll(revPath, 0777)
revDir, err := os.Open(revPath)
if err != nil {
log.Printf("Failed to open %s: %s", revPath, err)
return &pond.Reply{Status: pond.Reply_INTERNAL_ERROR.Enum()}
}
defer revDir.Close()
ents, err := revDir.Readdir(0)
if err != nil {
log.Printf("Failed to read %s: %s", revDir, err)
return &pond.Reply{Status: pond.Reply_INTERNAL_ERROR.Enum()}
}
if len(ents) > maxRevocations {
// Delete the oldest revocation.
names := make([]string, 0, len(ents))
for _, ent := range ents {
names = append(names, ent.Name())
}
sort.Strings(names)
path := filepath.Join(revPath, names[0])
if err := os.Remove(path); err != nil {
log.Printf("Failed to remove %s: %s", path, err)
return &pond.Reply{Status: pond.Reply_INTERNAL_ERROR.Enum()}
}
}
path := filepath.Join(revPath, fmt.Sprintf("%08x", *signedRevocation.Revocation.Generation))
revBytes, err := proto.Marshal(signedRevocation)
if err != nil {
log.Printf("Failed to serialise revocation: %s", err)
return &pond.Reply{Status: pond.Reply_INTERNAL_ERROR.Enum()}
}
if err := ioutil.WriteFile(path, revBytes, 0666); err != nil {
log.Printf("Failed to write revocation file: %s", err)
return &pond.Reply{Status: pond.Reply_INTERNAL_ERROR.Enum()}
}
group := account.Group()
if group == nil {
return &pond.Reply{Status: pond.Reply_INTERNAL_ERROR.Enum()}
}
groupCopy, _ := new(bbssig.Group).Unmarshal(group.Marshal())
groupCopy.Update(revocation)
account.Lock()
defer account.Unlock()
account.group = groupCopy
groupPath := filepath.Join(account.Path(), "group")
if err := ioutil.WriteFile(groupPath, groupCopy.Marshal(), 0600); err != nil {
log.Printf("failed to write group file: %s", err)
}
return nil
}
示例7: PackGroup
func PackGroup(out io.Writer, g *bbssig.Group) {
var pub []byte
pub = g.Marshal()
basepack.Packout(out, pub)
}