Add() adds a tuple to the batch verifier
(pk PublicKeyI, publicKey, message, signature []byte)
| 67 | |
| 68 | // Add() adds a tuple to the batch verifier |
| 69 | func (b *BatchVerifier) Add(pk PublicKeyI, publicKey, message, signature []byte) (err error) { |
| 70 | // if no-op enabled |
| 71 | if b.noOp { |
| 72 | // exit |
| 73 | return nil |
| 74 | } |
| 75 | // initialize the batch tuple object and append to the proper list |
| 76 | t := BatchTuple{PublicKey: pk, Message: message, Signature: signature, index: b.count} |
| 77 | listIdx := b.count % 8 |
| 78 | // depending on the public key length |
| 79 | switch len(publicKey) { |
| 80 | case Ed25519PubKeySize: |
| 81 | b.ed25519[listIdx] = append(b.ed25519[listIdx], t) |
| 82 | case ETHSECP256K1PubKeySize, ETHSECP256K1PubKeySize + 1: |
| 83 | b.ethSecp256k1[listIdx] = append(b.ethSecp256k1[listIdx], t) |
| 84 | case SECP256K1PubKeySize: |
| 85 | b.secp256k1[listIdx] = append(b.secp256k1[listIdx], t) |
| 86 | case BLS12381PubKeySize: |
| 87 | b.bls12381[listIdx] = append(b.bls12381[listIdx], t) |
| 88 | default: |
| 89 | return fmt.Errorf("unrecognized public key format") |
| 90 | } |
| 91 | // increment the global count |
| 92 | b.count++ |
| 93 | // exit |
| 94 | return |
| 95 | } |
| 96 | |
| 97 | // Verify() returns the indices of bad signatures (if any) |
| 98 | func (b *BatchVerifier) Verify() (badIndices []int) { |