crypto: Upstream v0.35.x improvements (#9255)

* crypto: Use curve25519-voi

This switches the ed25519, sr25519 and merlin provider to curve25519-voi
and additionally adopts ZIP-215 semantics for ed25519 verification.

* crypto: Implement batch verification interface for ed25519 and sr25519

This commit adds the batch verification interface, but does not enable
it for anything.

* types: Use batch verification for verifying commits signatures
This commit is contained in:
Yawning Angel
2022-09-21 09:34:04 +02:00
committed by GitHub
parent c69ab68848
commit 2d1ada4d52
20 changed files with 1084 additions and 509 deletions
+2 -4
View File
@@ -7,7 +7,7 @@ import (
"testing"
gogotypes "github.com/cosmos/gogoproto/types"
"github.com/gtank/merlin"
"github.com/oasisprotocol/curve25519-voi/primitives/merlin"
"github.com/stretchr/testify/assert"
"golang.org/x/crypto/chacha20poly1305"
@@ -208,9 +208,7 @@ func (c *evilConn) signChallenge() []byte {
const challengeSize = 32
var challenge [challengeSize]byte
challengeSlice := transcript.ExtractBytes(labelSecretConnectionMac, challengeSize)
copy(challenge[:], challengeSlice[0:challengeSize])
transcript.ExtractBytes(challenge[:], labelSecretConnectionMac)
sendAead, err := chacha20poly1305.New(sendSecret[:])
if err != nil {
+7 -9
View File
@@ -14,8 +14,8 @@ import (
"time"
gogotypes "github.com/cosmos/gogoproto/types"
"github.com/gtank/merlin"
pool "github.com/libp2p/go-buffer-pool"
"github.com/oasisprotocol/curve25519-voi/primitives/merlin"
"golang.org/x/crypto/chacha20poly1305"
"golang.org/x/crypto/curve25519"
"golang.org/x/crypto/hkdf"
@@ -38,16 +38,16 @@ const (
aeadSizeOverhead = 16 // overhead of poly 1305 authentication tag
aeadKeySize = chacha20poly1305.KeySize
aeadNonceSize = chacha20poly1305.NonceSize
labelEphemeralLowerPublicKey = "EPHEMERAL_LOWER_PUBLIC_KEY"
labelEphemeralUpperPublicKey = "EPHEMERAL_UPPER_PUBLIC_KEY"
labelDHSecret = "DH_SECRET"
labelSecretConnectionMac = "SECRET_CONNECTION_MAC"
)
var (
ErrSmallOrderRemotePubKey = errors.New("detected low order point from remote peer")
labelEphemeralLowerPublicKey = []byte("EPHEMERAL_LOWER_PUBLIC_KEY")
labelEphemeralUpperPublicKey = []byte("EPHEMERAL_UPPER_PUBLIC_KEY")
labelDHSecret = []byte("DH_SECRET")
labelSecretConnectionMac = []byte("SECRET_CONNECTION_MAC")
secretConnKeyAndChallengeGen = []byte("TENDERMINT_SECRET_CONNECTION_KEY_AND_CHALLENGE_GEN")
)
@@ -132,9 +132,7 @@ func MakeSecretConnection(conn io.ReadWriteCloser, locPrivKey crypto.PrivKey) (*
const challengeSize = 32
var challenge [challengeSize]byte
challengeSlice := transcript.ExtractBytes(labelSecretConnectionMac, challengeSize)
copy(challenge[:], challengeSlice[0:challengeSize])
transcript.ExtractBytes(challenge[:], labelSecretConnectionMac)
sendAead, err := chacha20poly1305.New(sendSecret[:])
if err != nil {