From 4fe1b4ba899eb9d170433791977eb1b30003fd63 Mon Sep 17 00:00:00 2001 From: pavel-raykov Date: Tue, 9 Jun 2026 11:33:07 +0200 Subject: [PATCH 1/5] Minor. --- keystore/go.mod | 2 +- keystore/go.sum | 4 ++-- keystore/ocr3/utils.go | 44 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 keystore/ocr3/utils.go 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/ocr3/utils.go b/keystore/ocr3/utils.go new file mode 100644 index 0000000000..bf6e76fb32 --- /dev/null +++ b/keystore/ocr3/utils.go @@ -0,0 +1,44 @@ +package ocr3 + +import ( + "github.com/smartcontractkit/libocr/offchainreporting2/types" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" + ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" +) + +// OnchainKeyring2Genericless 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 OnchainKeyring2ToGenericAdapter to use it as +// ocr3types.OnchainKeyring2. +type OnchainKeyring2Genericless 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{}] = &OnchainKeyring2ToGenericAdapter[struct{}]{} + +type OnchainKeyring2ToGenericAdapter[RI any] struct { + K OnchainKeyring2Genericless +} + +func (o *OnchainKeyring2ToGenericAdapter[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 *OnchainKeyring2ToGenericAdapter[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 *OnchainKeyring2ToGenericAdapter[RI]) Has(key ocrtypes.OnchainPublicKey) bool { + return o.K.Has(key) +} + +func (o *OnchainKeyring2ToGenericAdapter[RI]) MaxSignatureLength() int { + return o.K.MaxSignatureLength() +} + +func (o *OnchainKeyring2ToGenericAdapter[RI]) DebugIdentifier() string { + return o.K.DebugIdentifier() +} From 0b659faac69285155ff1c81645df08c2bbc54cee Mon Sep 17 00:00:00 2001 From: pavel-raykov Date: Tue, 9 Jun 2026 15:16:17 +0200 Subject: [PATCH 2/5] Minor. --- keystore/ocr3/utils.go | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/keystore/ocr3/utils.go b/keystore/ocr3/utils.go index bf6e76fb32..730d2c2050 100644 --- a/keystore/ocr3/utils.go +++ b/keystore/ocr3/utils.go @@ -9,7 +9,7 @@ import ( // OnchainKeyring2Genericless 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 OnchainKeyring2ToGenericAdapter to use it as // ocr3types.OnchainKeyring2. -type OnchainKeyring2Genericless interface { +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 @@ -17,28 +17,32 @@ type OnchainKeyring2Genericless interface { DebugIdentifier() string } -var _ ocr3types.OnchainKeyring2[struct{}] = &OnchainKeyring2ToGenericAdapter[struct{}]{} +var _ ocr3types.OnchainKeyring2[struct{}] = &onchainKeyring2[struct{}]{} -type OnchainKeyring2ToGenericAdapter[RI any] struct { - K OnchainKeyring2Genericless +type onchainKeyring2[RI any] struct { + k OnchainKeyring2 } -func (o *OnchainKeyring2ToGenericAdapter[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]) Sign(c ocrtypes.ConfigDigest, seqNr uint64, r ocr3types.ReportWithInfo[RI]) (signature []byte, err error) { + return o.k.Sign(c, seqNr, r.Report) } -func (o *OnchainKeyring2ToGenericAdapter[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]) 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 *OnchainKeyring2ToGenericAdapter[RI]) Has(key ocrtypes.OnchainPublicKey) bool { - return o.K.Has(key) +func (o *onchainKeyring2[RI]) Has(key ocrtypes.OnchainPublicKey) bool { + return o.k.Has(key) } -func (o *OnchainKeyring2ToGenericAdapter[RI]) MaxSignatureLength() int { - return o.K.MaxSignatureLength() +func (o *onchainKeyring2[RI]) MaxSignatureLength() int { + return o.k.MaxSignatureLength() } -func (o *OnchainKeyring2ToGenericAdapter[RI]) DebugIdentifier() string { - return o.K.DebugIdentifier() +func (o *onchainKeyring2[RI]) DebugIdentifier() string { + return o.k.DebugIdentifier() +} + +func AsOCR3OnchainKeyring2[RI any](k OnchainKeyring2) ocr3types.OnchainKeyring2[RI] { + return &onchainKeyring2[RI]{k} } From 1a33f0676c10a3f3cc9e13b8ddd45d9122e7dc64 Mon Sep 17 00:00:00 2001 From: pavel-raykov <165708424+pavel-raykov@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:04:33 +0200 Subject: [PATCH 3/5] Apply suggestion from @jmank88 Co-authored-by: Jordan Krage --- keystore/ocr3/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keystore/ocr3/utils.go b/keystore/ocr3/utils.go index 730d2c2050..f091d3d949 100644 --- a/keystore/ocr3/utils.go +++ b/keystore/ocr3/utils.go @@ -6,8 +6,8 @@ import ( ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" ) -// OnchainKeyring2Genericless 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 OnchainKeyring2ToGenericAdapter to use it as +// 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) From b0c9e79aa62c2d51d12fbedcecc4e9ef406cd7ce Mon Sep 17 00:00:00 2001 From: pavel-raykov <165708424+pavel-raykov@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:05:10 +0200 Subject: [PATCH 4/5] Apply suggestion from @jmank88 Co-authored-by: Jordan Krage --- keystore/ocr3/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keystore/ocr3/utils.go b/keystore/ocr3/utils.go index f091d3d949..0ad74bc25c 100644 --- a/keystore/ocr3/utils.go +++ b/keystore/ocr3/utils.go @@ -1,4 +1,4 @@ -package ocr3 +package ocr3util import ( "github.com/smartcontractkit/libocr/offchainreporting2/types" From 535409fad6dd07d4d8778e330b7df2f2e1779aa2 Mon Sep 17 00:00:00 2001 From: pavel-raykov Date: Tue, 9 Jun 2026 17:22:57 +0200 Subject: [PATCH 5/5] Minor. --- keystore/{ocr3 => ocr3util}/utils.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename keystore/{ocr3 => ocr3util}/utils.go (100%) diff --git a/keystore/ocr3/utils.go b/keystore/ocr3util/utils.go similarity index 100% rename from keystore/ocr3/utils.go rename to keystore/ocr3util/utils.go