mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-10 23:10:59 +00:00
* 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
33 lines
867 B
Go
33 lines
867 B
Go
package batch
|
|
|
|
import (
|
|
"github.com/tendermint/tendermint/crypto"
|
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
|
"github.com/tendermint/tendermint/crypto/sr25519"
|
|
)
|
|
|
|
// CreateBatchVerifier checks if a key type implements the batch verifier interface.
|
|
// Currently only ed25519 & sr25519 supports batch verification.
|
|
func CreateBatchVerifier(pk crypto.PubKey) (crypto.BatchVerifier, bool) {
|
|
switch pk.Type() {
|
|
case ed25519.KeyType:
|
|
return ed25519.NewBatchVerifier(), true
|
|
case sr25519.KeyType:
|
|
return sr25519.NewBatchVerifier(), true
|
|
}
|
|
|
|
// case where the key does not support batch verification
|
|
return nil, false
|
|
}
|
|
|
|
// SupportsBatchVerifier checks if a key type implements the batch verifier
|
|
// interface.
|
|
func SupportsBatchVerifier(pk crypto.PubKey) bool {
|
|
switch pk.Type() {
|
|
case ed25519.KeyType, sr25519.KeyType:
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|