diff --git a/keystore/go.mod b/keystore/go.mod index c10dd5ea09..1ad5d19488 100644 --- a/keystore/go.mod +++ b/keystore/go.mod @@ -18,7 +18,7 @@ require ( github.com/lib/pq v1.10.9 github.com/mr-tron/base58 v1.2.0 github.com/smartcontractkit/chainlink-common v0.11.2-0.20260422075950-29f37fa83c8a - github.com/smartcontractkit/libocr v0.0.0-20251027221354-bdc84e1ed858 + github.com/smartcontractkit/libocr v0.0.0-20260529134643-c101335a64cd github.com/smartcontractkit/smdkg v0.0.0-20251029093710-c38905e58aeb github.com/smartcontractkit/wsrpc v0.8.5-0.20250502134807-c57d3d995945 github.com/spf13/cobra v1.9.1 diff --git a/keystore/go.sum b/keystore/go.sum index 58e860502f..a1dfd878ab 100644 --- a/keystore/go.sum +++ b/keystore/go.sum @@ -647,8 +647,8 @@ github.com/smartcontractkit/chainlink-protos/linking-service/go v0.0.0-202510021 github.com/smartcontractkit/chainlink-protos/linking-service/go v0.0.0-20251002192024-d2ad9222409b/go.mod h1:qSTSwX3cBP3FKQwQacdjArqv0g6QnukjV4XuzO6UyoY= github.com/smartcontractkit/freeport v0.1.3-0.20250716200817-cb5dfd0e369e h1:Hv9Mww35LrufCdM9wtS9yVi/rEWGI1UnjHbcKKU0nVY= github.com/smartcontractkit/freeport v0.1.3-0.20250716200817-cb5dfd0e369e/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU= -github.com/smartcontractkit/libocr v0.0.0-20251027221354-bdc84e1ed858 h1:dz+lxAW+B+PUq32ODppSq5UKw06+EF6+EO6kk684bcQ= -github.com/smartcontractkit/libocr v0.0.0-20251027221354-bdc84e1ed858/go.mod h1:oJkBKVn8zoBQm7Feah9CiuEHyCqAhnp1LJBzrvloQtM= +github.com/smartcontractkit/libocr v0.0.0-20260529134643-c101335a64cd h1:ksFjz3ytjK4kH5HFHpLKzDS0/9gmeSuvii1rs8FlxrI= +github.com/smartcontractkit/libocr v0.0.0-20260529134643-c101335a64cd/go.mod h1:PLdNK6GlqfxIWXzziPkU7dCAVlVFeYkyyW7AQY0R+4Q= github.com/smartcontractkit/smdkg v0.0.0-20251029093710-c38905e58aeb h1:kLHdQQkijaPGsBbtV2rJgpzVpQ96e7T10pzjNlWfK8U= github.com/smartcontractkit/smdkg v0.0.0-20251029093710-c38905e58aeb/go.mod h1:4s5hj/nlMF9WV+T5Uhy4n9IYpRpzfJzT+vTKkNT7T+Y= github.com/smartcontractkit/wsrpc v0.8.5-0.20250502134807-c57d3d995945 h1:zxcODLrFytOKmAd8ty8S/XK6WcIEJEgRBaL7sY/7l4Y= diff --git a/keystore/ocr3util/utils.go b/keystore/ocr3util/utils.go new file mode 100644 index 0000000000..0ad74bc25c --- /dev/null +++ b/keystore/ocr3util/utils.go @@ -0,0 +1,48 @@ +package ocr3util + +import ( + "github.com/smartcontractkit/libocr/offchainreporting2/types" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" + ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" +) + +// OnchainKeyring2 is a genericless counterpart of ocr3types.OnchainKeyring2. If generic RI does not matter, +// then it is more convenient to implement this interface and then use AsOCR3OnchainKeyring2 to use it as +// ocr3types.OnchainKeyring2. +type OnchainKeyring2 interface { + Sign(configDigest ocrtypes.ConfigDigest, seqNr uint64, report types.Report) (signature []byte, err error) + Verify(publicKey ocrtypes.OnchainPublicKey, configDigest ocrtypes.ConfigDigest, seqNr uint64, report types.Report, signature []byte) bool + Has(publicKey ocrtypes.OnchainPublicKey) bool + MaxSignatureLength() int + DebugIdentifier() string +} + +var _ ocr3types.OnchainKeyring2[struct{}] = &onchainKeyring2[struct{}]{} + +type onchainKeyring2[RI any] struct { + k OnchainKeyring2 +} + +func (o *onchainKeyring2[RI]) Sign(c ocrtypes.ConfigDigest, seqNr uint64, r ocr3types.ReportWithInfo[RI]) (signature []byte, err error) { + return o.k.Sign(c, seqNr, r.Report) +} + +func (o *onchainKeyring2[RI]) Verify(pk ocrtypes.OnchainPublicKey, c ocrtypes.ConfigDigest, seqNr uint64, r ocr3types.ReportWithInfo[RI], signature []byte) bool { + return o.k.Verify(pk, c, seqNr, r.Report, signature) +} + +func (o *onchainKeyring2[RI]) Has(key ocrtypes.OnchainPublicKey) bool { + return o.k.Has(key) +} + +func (o *onchainKeyring2[RI]) MaxSignatureLength() int { + return o.k.MaxSignatureLength() +} + +func (o *onchainKeyring2[RI]) DebugIdentifier() string { + return o.k.DebugIdentifier() +} + +func AsOCR3OnchainKeyring2[RI any](k OnchainKeyring2) ocr3types.OnchainKeyring2[RI] { + return &onchainKeyring2[RI]{k} +}