Exemple #1
0
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()
}
Exemple #2
0
func main() {
	var challenge = os.Args[1]
	var err error
	var parthandle *os.File
	parthandle, err = os.Open(os.Args[2])
	if err != nil {
		log.Fatal(err)
	}
	var partreader = bufio.NewReader(parthandle)
	var randreader *os.File
	randreader, err = os.Open("/dev/random")
	if err != nil {
		log.Fatal(err)
	}
	var group *bbssig.Group = new(bbssig.Group)
	var mem *bbssig.MemberKey = new(bbssig.MemberKey)
	var hash = sha256.New()
	var cb []byte
	var response []byte
	objpack.UnPackPart(partreader, group, mem)
	cb, err = base64.StdEncoding.DecodeString(challenge)
	if err != nil {
		log.Fatal("Invalid Challenge")
	}
	response, err = mem.Sign(randreader, cb, hash)
	if err != nil {
		log.Fatal(err)
	}
	basepack.Packout(os.Stdout, response)
}
Exemple #3
0
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()
}
Exemple #4
0
func PackGroup(out io.Writer, g *bbssig.Group) {
	var pub []byte
	pub = g.Marshal()
	basepack.Packout(out, pub)
}