• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang edwards.NewAES128SHA256Ed25519函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/dedis/crypto/edwards.NewAES128SHA256Ed25519函数的典型用法代码示例。如果您正苦于以下问题:Golang NewAES128SHA256Ed25519函数的具体用法?Golang NewAES128SHA256Ed25519怎么用?Golang NewAES128SHA256Ed25519使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewAES128SHA256Ed25519函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestMUCommit

// Test for Marshalling and Unmarshalling Comit Messages
// Important: when making empty HashIds len should be set to HASH_SIZE
func TestMUCommit(t *testing.T) {
	var err error
	suite := edwards.NewAES128SHA256Ed25519(true)
	//suite := nist.NewAES128SHA256P256()
	rand := suite.Cipher([]byte("exampfsdjkhujgkjsgfjgle"))
	rand2 := suite.Cipher([]byte("examplsfhsjedgjhsge2"))

	cm := &sign.CommitmentMessage{}
	cm.V, _ = suite.Point().Pick(nil, rand)
	cm.V_hat, _ = suite.Point().Pick(nil, rand2)

	cm.MTRoot = make([]byte, hashid.Size)
	sm := sign.SigningMessage{Type: sign.Commitment, Com: cm}
	smBytes, err := sm.MarshalBinary()
	if err != nil {
		t.Error(err)
	}

	messg := &sign.SigningMessage{}
	err = messg.UnmarshalBinary(smBytes)
	cm2 := messg.Com

	// test for equality after marshal and unmarshal
	if !cm2.V.Equal(cm.V) ||
		!cm2.V_hat.Equal(cm.V_hat) ||
		bytes.Compare(cm2.MTRoot, cm.MTRoot) != 0 {
		t.Error("commit message MU failed")
	}

}
开发者ID:Liamsi,项目名称:cothority,代码行数:32,代码来源:signingMessages_test.go


示例2: TestMUChallenge

// Test for Marshalling and Unmarshalling Challenge Messages
// Important: when making empty HashIds len should be set to HASH_SIZE
func TestMUChallenge(t *testing.T) {
	nHashIds := 3

	var err error
	suite := edwards.NewAES128SHA256Ed25519(true)
	//suite := nist.NewAES128SHA256P256()
	rand := suite.Cipher([]byte("example"))

	cm := &sign.ChallengeMessage{}
	cm.C = suite.Secret().Pick(rand)
	cm.MTRoot = make([]byte, hashid.Size)
	cm.Proof = proof.Proof(make([]hashid.HashId, nHashIds))
	for i := 0; i < nHashIds; i++ {
		cm.Proof[i] = make([]byte, hashid.Size)
	}
	sm := &sign.SigningMessage{Type: sign.Challenge, Chm: cm}
	smBytes, err := sm.MarshalBinary()
	if err != nil {
		t.Error(err)
	}

	messg := &sign.SigningMessage{}
	err = messg.UnmarshalBinary(smBytes)
	cm2 := messg.Chm

	// test for equality after marshal and unmarshal
	if !cm2.C.Equal(cm.C) ||
		bytes.Compare(cm2.MTRoot, cm.MTRoot) != 0 ||
		!byteArrayEqual(cm2.Proof, cm.Proof) {
		t.Error("challenge message MU failed")
	}
}
开发者ID:Liamsi,项目名称:cothority,代码行数:34,代码来源:signingMessages_test.go


示例3: benchGenSigEd25519

func benchGenSigEd25519(nkeys int) []byte {
	suite := edwards.NewAES128SHA256Ed25519(false)
	rand := suite.Cipher([]byte("example"))
	return Sign(suite, rand, benchMessage,
		Set(benchPubEd25519[:nkeys]), nil,
		0, benchPriEd25519)
}
开发者ID:eftychis,项目名称:crypto-1,代码行数:7,代码来源:sig_test.go


示例4: TestSmallConfigHealthyNistQR512

func TestSmallConfigHealthyNistQR512(t *testing.T) {
	//suite := nist.NewAES128SHA256QR512()
	suite := edwards.NewAES128SHA256Ed25519(true)
	RoundsPerView := 100
	if err := runTreeSmallConfig(sign.MerkleTree, RoundsPerView, suite, 0); err != nil {
		t.Fatal(err)
	}
}
开发者ID:Liamsi,项目名称:cothority,代码行数:8,代码来源:collectiveSigning_test.go


示例5: TestNewKeyPair

func TestNewKeyPair(t *testing.T) {
	suite := edwards.NewAES128SHA256Ed25519(false)
	keypair := config.NewKeyPair(suite)
	pub := suite.Point().Mul(nil, keypair.Secret)
	if !pub.Equal(keypair.Public) {
		t.Fatal("Public and private-key don't match")
	}
}
开发者ID:LegoShrimp,项目名称:crypto,代码行数:8,代码来源:key_test.go


示例6: All

// All Returns a map of all suites
func All() Suites {
	s := make(Suites)
	s.add(nist.NewAES128SHA256P256())
	s.add(nist.NewAES128SHA256QR512())
	s.add(ed25519.NewAES128SHA256Ed25519(false))
	s.add(edwards.NewAES128SHA256Ed25519(false))
	return s
}
开发者ID:LegoShrimp,项目名称:crypto,代码行数:9,代码来源:list.go


示例7: TestSmallConfigFaulty

func TestSmallConfigFaulty(t *testing.T) {
	faultyNodes := make([]int, 0)
	faultyNodes = append(faultyNodes, 2, 5)
	suite := edwards.NewAES128SHA256Ed25519(true)
	//suite := nist.NewAES128SHA256P256()
	RoundsPerView := 100
	if err := runTreeSmallConfig(sign.MerkleTree, RoundsPerView, suite, 1, faultyNodes...); err != nil {
		t.Fatal(err)
	}
}
开发者ID:Liamsi,项目名称:cothority,代码行数:10,代码来源:collectiveSigning_test.go


示例8: TestTcpNetwork

func TestTcpNetwork(t *testing.T) {
	clientHost := NewTcpHost("127.0.0.1")
	serverHost := NewTcpHost("127.0.0.1")
	suite := edwards.NewAES128SHA256Ed25519(false)
	Suite = suite
	clientPub := suite.Point().Base()
	serverPub := suite.Point().Add(suite.Point().Base(), suite.Point().Base())
	client := new(SimpleClient).Init(clientHost, clientPub)
	server := new(SimpleServer).Init(serverHost, serverPub, t)

	go server.Listen("127.0.0.1:5000", server.ExchangeWithClient)
	time.Sleep(1 * time.Second)
	client.ExchangeWithServer("127.0.0.1:5000", t)
}
开发者ID:mlncn,项目名称:cothority,代码行数:14,代码来源:net_test.go


示例9: TestNego

func TestNego(t *testing.T) {

	realSuites := []abstract.Suite{
		edwards.NewAES128SHA256Ed25519(true),
	}

	fakery := 10
	nentries := 10
	datalen := 16

	suites := make([]abstract.Suite, 0)
	for i := range realSuites {
		real := realSuites[i]
		for j := 0; j < fakery; j++ {
			suites = append(suites, &fakeSuite{real, j})
		}
	}

	nlevels := 5
	suiteLevel := make(map[abstract.Suite]int)
	entries := make([]Entry, 0)
	for i := range suites {
		suiteLevel[suites[i]] = nlevels
		nlevels++ // vary it a bit for testing

		// Create some entrypoints with this suite
		s := suites[i]
		for j := 0; j < nentries; j++ {
			pri := s.Scalar().Pick(random.Stream)
			pub := s.Point().Mul(nil, pri)
			data := make([]byte, datalen)
			entries = append(entries, Entry{s, pub, data})
		}
	}

	w := Writer{}
	_, err := w.Layout(suiteLevel, entries, nil)
	if err != nil {
		t.Log(err)
		t.FailNow()
	}
}
开发者ID:LegoShrimp,项目名称:crypto,代码行数:42,代码来源:nego_test.go


示例10: TestProofCollective

func TestProofCollective(t *testing.T) {

	suite := edwards.NewAES128SHA256Ed25519(false)

	// 1st set of base points
	g1, _ := suite.Point().Pick([]byte("G1"), random.Stream)
	h1, _ := suite.Point().Pick([]byte("H1"), random.Stream)

	// 1st secret value
	x := suite.Scalar().Pick(random.Stream)

	// 2nd set of base points
	g2, _ := suite.Point().Pick([]byte("G2"), random.Stream)
	h2, _ := suite.Point().Pick([]byte("H2"), random.Stream)

	// 2nd secret value
	y := suite.Scalar().Pick(random.Stream)

	// Create proof
	g := []abstract.Point{g1, g2}
	h := []abstract.Point{h1, h2}
	p, err := randhound.NewProof(suite, g, h, nil)
	log.ErrFatal(err)

	xG, xH, err := p.SetupCollective(x, y)
	log.ErrFatal(err)

	// Verify proof
	q, err := randhound.NewProof(suite, g, h, p.Core)
	log.ErrFatal(err)

	_, bad, err := q.Verify(xG, xH)
	log.ErrFatal(err)

	if len(bad) != 0 {
		log.Fatalf("Some proofs failed: %v", bad)
	}

}
开发者ID:dedis,项目名称:cothority,代码行数:39,代码来源:proof_test.go


示例11: NewServer

func NewServer(port1 int, id int, servers []string, FSMode bool) *Server {
	suite := edwards.NewAES128SHA256Ed25519(false)
	rand := suite.Cipher(abstract.RandomKey)
	sk := suite.Scalar().Pick(rand)
	pk := suite.Point().Mul(nil, sk)
	pkBin := MarshalPoint(pk)
	ephSecret := suite.Scalar().Pick(rand)

	rounds := make([]*Round, MaxRounds)

	for i := range rounds {
		r := Round{
			allBlocks: nil,

			reqChan2:     nil,
			requestsChan: nil,
			reqHashes:    nil,
			reqHashesRdy: nil,

			ublockChan2: nil,
			shuffleChan: make(chan []Block), //collect all uploads together
			upHashesRdy: nil,

			upHashes:    nil,
			dblocksChan: make(chan []Block),
			blocksRdy:   nil,
			xorsChan:    make([]map[int](chan Block), len(servers)),
		}
		rounds[i] = &r
	}

	s := Server{
		port1:      port1,
		id:         id,
		servers:    servers,
		regLock:    []*sync.Mutex{new(sync.Mutex), new(sync.Mutex)},
		regChan:    make(chan bool, TotalClients),
		regDone:    make(chan bool),
		running:    make(chan bool),
		secretLock: new(sync.Mutex),

		suite:      suite,
		g:          suite,
		sk:         sk,
		pk:         pk,
		pkBin:      pkBin,
		pks:        make([]abstract.Point, len(servers)),
		nextPks:    make([]abstract.Point, len(servers)),
		nextPksBin: make([][]byte, len(servers)),
		ephSecret:  ephSecret,

		pi:             nil,
		keys:           nil,
		keysRdy:        nil,
		auxProofChan:   make([]chan AuxKeyProof, len(servers)),
		keyUploadChan:  nil,
		keyShuffleChan: make(chan InternalKey),

		clientMap:    make(map[int]int),
		numClients:   0,
		totalClients: 0,
		maskss:       nil,
		secretss:     nil,

		rounds: rounds,

		FSMode: FSMode,

		memProf: nil,
	}

	for i := range s.auxProofChan {
		s.auxProofChan[i] = make(chan AuxKeyProof, len(servers))
	}

	return &s
}
开发者ID:Xyroe,项目名称:riffle,代码行数:77,代码来源:server.go


示例12: NewClient

func NewClient(servers []string, myServer string, FSMode bool) *Client {
	suite := edwards.NewAES128SHA256Ed25519(false)

	myServerIdx := -1
	rpcServers := make([]*rpc.Client, len(servers))
	for i := range rpcServers {
		if servers[i] == myServer {
			myServerIdx = i
		}
		rpcServer, err := rpc.Dial("tcp", servers[i])
		if err != nil {
			log.Fatal("Cannot establish connection:", err)
		}
		rpcServers[i] = rpcServer
	}

	pks := make([]abstract.Point, len(servers))
	var wg sync.WaitGroup
	for i, rpcServer := range rpcServers {
		wg.Add(1)
		go func(i int, rpcServer *rpc.Client) {
			defer wg.Done()
			pk := make([]byte, SecretSize)
			err := rpcServer.Call("Server.GetPK", 0, &pk)
			if err != nil {
				log.Fatal("Couldn't get server's pk:", err)
			}
			pks[i] = UnmarshalPoint(suite, pk)
		}(i, rpcServer)
	}
	wg.Wait()

	rounds := make([]*Round, MaxRounds)

	for i := range rounds {
		r := Round{
			reqLock:  new(sync.Mutex),
			upLock:   new(sync.Mutex),
			downLock: new(sync.Mutex),

			reqHashesChan: make(chan [][]byte),
			dhashChan:     make(chan []byte),
			upHashesChan:  make(chan [][]byte),
		}
		rounds[i] = &r
	}

	//id comes from servers
	c := Client{
		id:           -1,
		servers:      servers,
		rpcServers:   rpcServers,
		myServer:     myServerIdx,
		totalClients: -1,

		FSMode: FSMode,

		files:   make(map[string]*File),
		osFiles: make(map[string]*os.File),

		testPieces: make(map[string][]byte),

		suite: suite,
		g:     suite,
		pks:   pks,

		keys:    make([][]byte, len(servers)),
		ephKeys: make([]abstract.Point, len(servers)),

		dhashes:  make(chan []byte, MaxRounds),
		maskss:   nil,
		secretss: nil,

		rounds: rounds,
	}

	return &c
}
开发者ID:Xyroe,项目名称:riffle,代码行数:78,代码来源:client.go


示例13: TestSetup

	"time"

	"testing"

	"afs/client"
	"afs/lib"
	"afs/server"

	"github.com/dedis/crypto/edwards"
)

var servers []*server.Server = nil
var clients []*client.Client = nil

var ServerAddrs []string = []string{"127.0.0.1:8000", "127.0.0.1:8001"}
var Suite = edwards.NewAES128SHA256Ed25519(false)

const NumClients = 3
const NumServers = 2

func TestSetup(t *testing.T) {
	//nothing goes on here
}

func TestFileShare(t *testing.T) {
	for s := range servers {
		servers[s].FSMode = true
	}
	for c := range clients {
		clients[c].FSMode = true
	}
开发者ID:Consequences,项目名称:riffle,代码行数:31,代码来源:afs_test.go


示例14: init

// Set up some global variables such as the different messages used during
// this protocol and the general suite to be used
func init() {
	suite = edwards.NewAES128SHA256Ed25519(false)
	net.Suite = suite
}
开发者ID:mlncn,项目名称:cothority,代码行数:6,代码来源:peer.go


示例15: BenchmarkSign100Ed25519

func BenchmarkSign100Ed25519(b *testing.B) {
	benchSign(edwards.NewAES128SHA256Ed25519(false),
		benchPubEd25519[:100], benchPriEd25519, b.N)
}
开发者ID:eftychis,项目名称:crypto-1,代码行数:4,代码来源:sig_test.go


示例16: RunServer

func RunServer(conf *app.ConfigShamir) {
	flags := app.RunFlags
	s := edwards.NewAES128SHA256Ed25519(false)
	n := len(conf.Hosts)

	info := poly.Threshold{
		N: n,
		R: n,
		T: n,
	}
	indexPeer := -1
	for i, h := range conf.Hosts {
		if h == flags.Hostname {
			indexPeer = i
			break
		}
	}
	if indexPeer == -1 {
		log.Fatal("Peer", flags.Hostname, "(", flags.PhysAddr, ") did not find any match for its name.Abort")
	}

	dbg.Lvl3("Creating new peer", flags.Hostname, "(", flags.PhysAddr, ") ...")
	// indexPeer == 0 <==> peer is root
	p := NewPeer(indexPeer, flags.Hostname, s, info, indexPeer == 0)

	// make it listen
	setup := monitor.NewMeasure("setup")
	dbg.Lvl3("Peer", flags.Hostname, "is now listening for incoming connections")
	go p.Listen()

	// then connect it to its successor in the list
	for _, h := range conf.Hosts[indexPeer+1:] {
		dbg.Lvl3("Peer", flags.Hostname, "will connect to", h)
		// will connect and SYN with the remote peer
		p.ConnectTo(h)
	}
	// Wait until this peer is connected / SYN'd with each other peer
	p.WaitSYNs()

	// Setup the schnorr system amongst peers
	p.SetupDistributedSchnorr()
	p.SendACKs()
	p.WaitACKs()
	dbg.Lvl3(p.String(), "completed Schnorr setup")

	// send setup time if we're root
	if p.IsRoot() {
		setup.Measure()
	}

	roundm := monitor.NewMeasure("round")
	for round := 1; round <= conf.Rounds; round++ {
		calc := monitor.NewMeasure("calc")
		// Then issue a signature !
		//sys, usr := app.GetRTime()
		msg := "hello world"

		// Only root calculates if it's OK and sends a log-message
		if p.IsRoot() {
			dbg.Lvl1("Starting round", round)
			sig := p.SchnorrSigRoot([]byte(msg))
			calc.Measure()
			verify := monitor.NewMeasure("verify")
			err := p.VerifySchnorrSig(sig, []byte(msg))
			if err != nil {
				dbg.Fatal(p.String(), "could not verify schnorr signature:/", err)
			}
			verify.Measure()
			roundm.Measure()
			dbg.Lvl3(p.String(), "verified the schnorr sig !")
		} else {
			// Compute the partial sig and send it to the root
			p.SchnorrSigPeer([]byte(msg))
		}
	}

	p.WaitFins()
	dbg.Lvl3(p.String(), "is leaving ...")

	if p.IsRoot() {
		monitor.End()
	}
}
开发者ID:mlncn,项目名称:cothority,代码行数:83,代码来源:server.go


示例17: NewSigningMessage

	Type         MessageType
	Am           *AnnouncementMessage
	Com          *CommitmentMessage
	Chm          *ChallengeMessage
	Rm           *ResponseMessage
	Cureq        *CatchUpRequest
	Curesp       *CatchUpResponse
	Vrm          *VoteRequestMessage
	Gcm          *GroupChangedMessage
	Err          *ErrorMessage
	From         string
	View         int
	LastSeenVote int // highest vote ever seen and commited in log, used for catch-up
}

var msgSuite abstract.Suite = edwards.NewAES128SHA256Ed25519(true)

//var msgSuite abstract.Suite = nist.NewAES128SHA256P256()

func NewSigningMessage() interface{} {
	return &SigningMessage{}
}

func (sm *SigningMessage) MarshalBinary() ([]byte, error) {
	return protobuf.Encode(sm)
}

func (sm *SigningMessage) UnmarshalBinary(data []byte) error {
	var cons = make(protobuf.Constructors)
	var point abstract.Point
	var secret abstract.Secret
开发者ID:Liamsi,项目名称:cothority,代码行数:31,代码来源:signingMessages.go


示例18: benchGenKeysEd25519

func benchGenKeysEd25519(nkeys int) ([]abstract.Point, abstract.Secret) {
	return benchGenKeys(edwards.NewAES128SHA256Ed25519(false), nkeys)
}
开发者ID:eftychis,项目名称:crypto-1,代码行数:3,代码来源:sig_test.go


示例19: TestBiffle

func TestBiffle(t *testing.T) {
	BiffleTest(edwards.NewAES128SHA256Ed25519(false), 1)
}
开发者ID:eftychis,项目名称:crypto-1,代码行数:3,代码来源:shuffle_test.go


示例20: Benchmark100PairShuffleEd25519

func Benchmark100PairShuffleEd25519(b *testing.B) {
	TestShuffle(edwards.NewAES128SHA256Ed25519(false), 100, b.N)
}
开发者ID:eftychis,项目名称:crypto-1,代码行数:3,代码来源:shuffle_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang ed25519.NewAES128SHA256Ed25519函数代码示例发布时间:2022-05-23
下一篇:
Golang config.KeyPair类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap