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() }
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)) }
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)) } }
func main() { /* Generate parameters for a new ring and store in public and private. */ var sk *bbssig.PrivateKey var randread, err = os.Open("/dev/random") if err != nil { log.Fatal(err) } sk, err = bbssig.GenerateGroup(randread) if err != nil { log.Fatal(err) } /* Need to output marshelled form of group ring */ var pubhandle *os.File pubhandle, err = os.Create(os.Args[1]) if err != nil { log.Fatal(err) } objpack.PackGroup(pubhandle, sk.Group) pubhandle.Close() /*Now to save private key*/ var priv []byte var privhandle *os.File privhandle, err = os.Create(os.Args[2]) if err != nil { log.Fatal("err") } priv = sk.Marshal() /*TODO: pros and cons of encrypting this file*/ /*We write the group first as it is needed information for unmarshalling*/ objpack.PackGroup(privhandle, sk.Group) basepack.Packout(privhandle, priv) privhandle.Close() }