当前位置: 首页>>代码示例>>Golang>>正文


Golang Group.Unmarshal方法代码示例

本文整理汇总了Golang中github.com/agl/pond/bbssig.Group.Unmarshal方法的典型用法代码示例。如果您正苦于以下问题:Golang Group.Unmarshal方法的具体用法?Golang Group.Unmarshal怎么用?Golang Group.Unmarshal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/agl/pond/bbssig.Group的用法示例。


在下文中一共展示了Group.Unmarshal方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
	}
}
开发者ID:wbl,项目名称:ringauth,代码行数:35,代码来源:verify.go

示例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()
}
开发者ID:wbl,项目名称:ringauth,代码行数:51,代码来源:addpart.go

示例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")
	}
}
开发者ID:wbl,项目名称:ringauth,代码行数:14,代码来源:obj.go

示例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))
}
开发者ID:wbl,项目名称:ringauth,代码行数:49,代码来源:revoke.go

示例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))
	}
}
开发者ID:wbl,项目名称:ringauth,代码行数:40,代码来源:blame.go


注:本文中的github.com/agl/pond/bbssig.Group.Unmarshal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。