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 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") } }
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 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) } }
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)) } }