Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aead, ecdh, skademlia: replaced Schnorr signatures for assembly-optim…
…ized EdDSA, and remove dependency on Kyber internal/edwards25519: add a scalar-point mul func GeScalarMult(), and use constant time compare on signature verification
- Loading branch information
1 parent
4f7caeb
commit b697165
Showing
13 changed files
with
180 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
module github.com/perlin-network/noise | ||
|
||
require ( | ||
github.com/golang/mock v1.2.0 | ||
github.com/huin/goupnp v1.0.0 | ||
github.com/jackpal/go-nat-pmp v1.0.1 | ||
github.com/pkg/errors v0.8.1 | ||
github.com/rs/zerolog v1.11.0 | ||
github.com/stretchr/testify v1.3.0 | ||
go.dedis.ch/kyber/v3 v3.0.0-pre2 | ||
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b | ||
golang.org/x/sys v0.0.0-20190124100055-b90733256f2e // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,42 @@ | ||
package ecdh | ||
|
||
import ( | ||
"github.com/perlin-network/noise/crypto" | ||
"go.dedis.ch/kyber/v3" | ||
"crypto/sha512" | ||
"github.com/perlin-network/noise/internal/edwards25519" | ||
) | ||
|
||
func computeSharedKey(suite crypto.EllipticSuite, nodePrivateKey kyber.Scalar, remotePublicKey kyber.Point) kyber.Point { | ||
return suite.Point().Mul(nodePrivateKey, remotePublicKey) | ||
func computeSharedKey(nodePrivateKey edwards25519.PrivateKey, remotePublicKey edwards25519.PublicKey) []byte { | ||
var nodeSecretKeyBuf, remotePublicKeyBuf, sharedKeyBuf [32]byte | ||
copy(nodeSecretKeyBuf[:], deriveSecretKey(nodePrivateKey)) | ||
copy(remotePublicKeyBuf[:], remotePublicKey[:]) | ||
|
||
var sharedKeyElement, publicKeyElement edwards25519.ExtendedGroupElement | ||
publicKeyElement.FromBytes(&remotePublicKeyBuf) | ||
|
||
edwards25519.GeScalarMult(&sharedKeyElement, &nodeSecretKeyBuf, &publicKeyElement) | ||
|
||
sharedKeyElement.ToBytes(&sharedKeyBuf) | ||
|
||
return sharedKeyBuf[:] | ||
} | ||
|
||
func deriveSecretKey(privateKey edwards25519.PrivateKey) []byte { | ||
digest := sha512.Sum512(privateKey[:32]) | ||
digest[0] &= 248 | ||
digest[31] &= 127 | ||
digest[31] |= 64 | ||
|
||
return digest[:32] | ||
} | ||
|
||
func isEd25519GroupElement(buf []byte) bool { | ||
if len(buf) != edwards25519.PublicKeySize { | ||
return false | ||
} | ||
|
||
var buff [32]byte | ||
copy(buff[:], buf) | ||
|
||
var A edwards25519.ExtendedGroupElement | ||
return A.FromBytes(&buff) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.