-
Notifications
You must be signed in to change notification settings - Fork 36
/
sigverifier.go
45 lines (36 loc) · 1.36 KB
/
sigverifier.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package components
import (
"crypto/ecdsa"
"fmt"
"github.com/ten-protocol/go-ten/go/enclave/storage"
gethcommon "github.com/ethereum/go-ethereum/common"
)
type SignatureValidator struct {
attestedKey *ecdsa.PublicKey
storage storage.Storage
}
func NewSignatureValidator(storage storage.Storage) (*SignatureValidator, error) {
// todo (#718) - sequencer identities should be retrieved from the L1 management contract
return &SignatureValidator{
storage: storage,
attestedKey: nil,
}, nil
}
// CheckSequencerSignature - verifies the signature against the registered sequencer
func (sigChecker *SignatureValidator) CheckSequencerSignature(_ gethcommon.Hash, sig []byte) error {
if sig == nil {
return fmt.Errorf("missing signature on batch")
}
// todo (@matt) disabling sequencer signature verification for now while we transition to EnclaveIDs
// This must be re-enabled once sequencer enclaveIDs are available from the management contract
//if sigChecker.attestedKey == nil {
// attestedKey, err := sigChecker.storage.FetchAttestedKey(sigChecker.SequencerID)
// if err != nil {
// return fmt.Errorf("could not retrieve attested key for aggregator %s. Cause: %w", sigChecker.SequencerID, err)
// }
// sigChecker.attestedKey = attestedKey
//}
//
// return signature.VerifySignature(sigChecker.attestedKey, headerHash.Bytes(), sig)
return nil
}