-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
keyring.go
50 lines (39 loc) · 1.43 KB
/
keyring.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
46
47
48
49
50
package evm
import (
"github.com/smartcontractkit/libocr/offchainreporting2/types"
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
"github.com/smartcontractkit/chainlink-automation/pkg/v3/plugin"
)
var _ ocr3types.OnchainKeyring[plugin.AutomationReportInfo] = &onchainKeyringV3Wrapper{}
type onchainKeyringV3Wrapper struct {
core types.OnchainKeyring
}
func NewOnchainKeyringV3Wrapper(keyring types.OnchainKeyring) *onchainKeyringV3Wrapper {
return &onchainKeyringV3Wrapper{
core: keyring,
}
}
func (w *onchainKeyringV3Wrapper) PublicKey() types.OnchainPublicKey {
return w.core.PublicKey()
}
func (w *onchainKeyringV3Wrapper) MaxSignatureLength() int {
return w.core.MaxSignatureLength()
}
func (w *onchainKeyringV3Wrapper) Sign(digest types.ConfigDigest, seqNr uint64, r ocr3types.ReportWithInfo[plugin.AutomationReportInfo]) (signature []byte, err error) {
rCtx := types.ReportContext{
ReportTimestamp: types.ReportTimestamp{
ConfigDigest: digest,
Epoch: uint32(seqNr),
},
}
return w.core.Sign(rCtx, r.Report)
}
func (w *onchainKeyringV3Wrapper) Verify(key types.OnchainPublicKey, digest types.ConfigDigest, seqNr uint64, r ocr3types.ReportWithInfo[plugin.AutomationReportInfo], signature []byte) bool {
rCtx := types.ReportContext{
ReportTimestamp: types.ReportTimestamp{
ConfigDigest: digest,
Epoch: uint32(seqNr),
},
}
return w.core.Verify(key, rCtx, r.Report, signature)
}