本文整理汇总了Golang中github.com/dedis/crypto/edwards.NewAES128SHA256Ed25519函数的典型用法代码示例。如果您正苦于以下问题:Golang NewAES128SHA256Ed25519函数的具体用法?Golang NewAES128SHA256Ed25519怎么用?Golang NewAES128SHA256Ed25519使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewAES128SHA256Ed25519函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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")
}
}
示例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")
}
}
示例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)
}
示例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)
}
}
示例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")
}
}
示例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
}
示例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)
}
}
示例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)
}
示例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()
}
}
示例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)
}
}
示例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
}
示例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
}
示例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
}
示例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
}
示例15: BenchmarkSign100Ed25519
func BenchmarkSign100Ed25519(b *testing.B) {
benchSign(edwards.NewAES128SHA256Ed25519(false),
benchPubEd25519[:100], benchPriEd25519, b.N)
}