Some checks are pending
docker-build-cometbft / vars (push) Waiting to run
docker-build-cometbft / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-cometbft / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-cometbft / merge-images (push) Blocked by required conditions
docker-build-e2e-node / vars (push) Waiting to run
docker-build-e2e-node / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-e2e-node / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-e2e-node / merge-images (push) Blocked by required conditions
35 lines
922 B
Go
35 lines
922 B
Go
package batch
|
|
|
|
import (
|
|
"git.cw.tr/mukan-network/mukan-consensus/crypto"
|
|
"git.cw.tr/mukan-network/mukan-consensus/crypto/ed25519"
|
|
"git.cw.tr/mukan-network/mukan-consensus/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 {
|
|
if pk == nil {
|
|
return false
|
|
}
|
|
switch pk.Type() {
|
|
case ed25519.KeyType, sr25519.KeyType:
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|