From f8b64f44777b7c31117b428d9073c8536ee40f0b Mon Sep 17 00:00:00 2001 From: stchrysa Date: Tue, 30 Jan 2024 22:50:12 +0100 Subject: [PATCH] Add ocr3 decryption plugin Signed-off-by: stchrysa --- .github/workflows/go.yaml | 2 +- go/go.work | 6 +- go/go.work.sum | 100 +++- .../decryptionplugin/config/config.go | 0 .../config/config_types.pb.go | 0 .../config/config_types.proto | 0 .../config/mocks/config_parser.go | 0 go/{ocr2 => ocr2plus}/decryptionplugin/go.mod | 14 +- go/{ocr2 => ocr2plus}/decryptionplugin/go.sum | 33 +- .../decryptionplugin/go_generate.go | 2 + .../decryptionplugin/ocr2}/decryption.go | 50 +- .../decryptionplugin/ocr2}/decryption_test.go | 75 +-- go/ocr2plus/decryptionplugin/ocr2_types.pb.go | 151 +++++ go/ocr2plus/decryptionplugin/ocr2_types.proto | 11 + .../decryptionplugin/ocr3/decryption.go | 515 ++++++++++++++++++ .../decryptionplugin/ocr3/decryption_test.go | 1 + go/ocr2plus/decryptionplugin/ocr3_types.pb.go | 151 +++++ go/ocr2plus/decryptionplugin/ocr3_types.proto | 13 + .../decryptionplugin/queue.go | 8 +- .../decryptionplugin/types.pb.go | 87 +-- .../decryptionplugin/types.proto | 4 - 21 files changed, 1049 insertions(+), 174 deletions(-) rename go/{ocr2 => ocr2plus}/decryptionplugin/config/config.go (100%) rename go/{ocr2 => ocr2plus}/decryptionplugin/config/config_types.pb.go (100%) rename go/{ocr2 => ocr2plus}/decryptionplugin/config/config_types.proto (100%) rename go/{ocr2 => ocr2plus}/decryptionplugin/config/mocks/config_parser.go (100%) rename go/{ocr2 => ocr2plus}/decryptionplugin/go.mod (52%) rename go/{ocr2 => ocr2plus}/decryptionplugin/go.sum (54%) rename go/{ocr2 => ocr2plus}/decryptionplugin/go_generate.go (58%) rename go/{ocr2/decryptionplugin => ocr2plus/decryptionplugin/ocr2}/decryption.go (91%) rename go/{ocr2/decryptionplugin => ocr2plus/decryptionplugin/ocr2}/decryption_test.go (89%) create mode 100644 go/ocr2plus/decryptionplugin/ocr2_types.pb.go create mode 100644 go/ocr2plus/decryptionplugin/ocr2_types.proto create mode 100644 go/ocr2plus/decryptionplugin/ocr3/decryption.go create mode 100644 go/ocr2plus/decryptionplugin/ocr3/decryption_test.go create mode 100644 go/ocr2plus/decryptionplugin/ocr3_types.pb.go create mode 100644 go/ocr2plus/decryptionplugin/ocr3_types.proto rename go/{ocr2 => ocr2plus}/decryptionplugin/queue.go (68%) rename go/{ocr2 => ocr2plus}/decryptionplugin/types.pb.go (82%) rename go/{ocr2 => ocr2plus}/decryptionplugin/types.proto (84%) diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index 82727e4..63832a5 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -49,7 +49,7 @@ jobs: go-version: '1.20' - name: Build and test OCR2 plugin - working-directory: ./go/ocr2/decryptionplugin + working-directory: ./go/ocr2plus/decryptionplugin run: | go build -v ./... go test -v ./... -coverpkg=./... -coverprofile=ocr2_decryptionplugin_coverage.txt diff --git a/go/go.work b/go/go.work index ae05aef..56c01ac 100644 --- a/go/go.work +++ b/go/go.work @@ -1,6 +1,8 @@ -go 1.19 +go 1.21 + +toolchain go1.21.0 use ( - ./ocr2/decryptionplugin + ./ocr2plus/decryptionplugin ./tdh2 ) diff --git a/go/go.work.sum b/go/go.work.sum index 44a132b..4f671d0 100644 --- a/go/go.work.sum +++ b/go/go.work.sum @@ -1,15 +1,111 @@ filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= +github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= +github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= +github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo= +github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw= +github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.13.8/go.mod h1:sc48XYQxCzH3fG9BcrXCOOgQk2JfZzNAmIKnceogzsA= +github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= +github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/gtank/ristretto255 v0.1.3-0.20210930101514-6bb39798585c/go.mod h1:tDPFhGdt3hJWqtKwx57i9baiB1Cj0yAg22VOPUqm5vY= -github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= +github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= +github.com/influxdata/influxdb-client-go/v2 v2.4.0/go.mod h1:vLNHdxTJkIf2mSLvGrpj8TCcISApPoXkaxP8g9uRlW8= +github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leanovate/gopter v0.2.10-0.20210127095200-9abe2343507a/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= +github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/go/ocr2/decryptionplugin/config/config.go b/go/ocr2plus/decryptionplugin/config/config.go similarity index 100% rename from go/ocr2/decryptionplugin/config/config.go rename to go/ocr2plus/decryptionplugin/config/config.go diff --git a/go/ocr2/decryptionplugin/config/config_types.pb.go b/go/ocr2plus/decryptionplugin/config/config_types.pb.go similarity index 100% rename from go/ocr2/decryptionplugin/config/config_types.pb.go rename to go/ocr2plus/decryptionplugin/config/config_types.pb.go diff --git a/go/ocr2/decryptionplugin/config/config_types.proto b/go/ocr2plus/decryptionplugin/config/config_types.proto similarity index 100% rename from go/ocr2/decryptionplugin/config/config_types.proto rename to go/ocr2plus/decryptionplugin/config/config_types.proto diff --git a/go/ocr2/decryptionplugin/config/mocks/config_parser.go b/go/ocr2plus/decryptionplugin/config/mocks/config_parser.go similarity index 100% rename from go/ocr2/decryptionplugin/config/mocks/config_parser.go rename to go/ocr2plus/decryptionplugin/config/mocks/config_parser.go diff --git a/go/ocr2/decryptionplugin/go.mod b/go/ocr2plus/decryptionplugin/go.mod similarity index 52% rename from go/ocr2/decryptionplugin/go.mod rename to go/ocr2plus/decryptionplugin/go.mod index 33698d0..5a92b8f 100644 --- a/go/ocr2/decryptionplugin/go.mod +++ b/go/ocr2plus/decryptionplugin/go.mod @@ -4,20 +4,20 @@ go 1.20 require ( github.com/google/go-cmp v0.5.9 - github.com/smartcontractkit/libocr v0.0.0-20230503222226-29f534b2de1a + github.com/smartcontractkit/libocr v0.0.0-20240112202000-6359502d2ff1 github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230616062456-5c32c95fc166 - github.com/stretchr/testify v1.3.0 - google.golang.org/protobuf v1.30.0 + github.com/stretchr/testify v1.7.0 + google.golang.org/protobuf v1.31.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/sirupsen/logrus v1.6.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/stretchr/objx v0.1.0 // indirect - golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect - golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912 // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/sys v0.15.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/go/ocr2/decryptionplugin/go.sum b/go/ocr2plus/decryptionplugin/go.sum similarity index 54% rename from go/ocr2/decryptionplugin/go.sum rename to go/ocr2plus/decryptionplugin/go.sum index e4126b0..806916b 100644 --- a/go/ocr2/decryptionplugin/go.sum +++ b/go/ocr2plus/decryptionplugin/go.sum @@ -5,31 +5,32 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/smartcontractkit/libocr v0.0.0-20230503222226-29f534b2de1a h1:NFTlIAjSwx9vBYZeUerd0DDsvg+zZ5TSESw4dPNdwJk= -github.com/smartcontractkit/libocr v0.0.0-20230503222226-29f534b2de1a/go.mod h1:5JnCHuYgmIP9ZyXzgAfI5Iwu0WxBtBKp+ApeT5o1Cjw= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/smartcontractkit/libocr v0.0.0-20240112202000-6359502d2ff1 h1:3y9WsXkZ5lxFrmfH7DQHs/q308lylKId5l/3VC0QAdM= +github.com/smartcontractkit/libocr v0.0.0-20240112202000-6359502d2ff1/go.mod h1:kC0qmVPUaVkFqGiZMNhmRmjdphuUmeyLEdlWFOQzFWI= github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230616062456-5c32c95fc166 h1:cNH0nQjRfmWj173L8exDkQratcFVQ8AAj8RZ8a+suaI= github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230616062456-5c32c95fc166/go.mod h1:G5Sd/yzHWf26rQ+X0nG9E0buKPqRGPMJAfk2gwCzOOw= github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= -golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912 h1:uCLL3g5wH2xjxVREVuAbP9JM5PPKjRbXKRa6IBjkzmU= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go/ocr2/decryptionplugin/go_generate.go b/go/ocr2plus/decryptionplugin/go_generate.go similarity index 58% rename from go/ocr2/decryptionplugin/go_generate.go rename to go/ocr2plus/decryptionplugin/go_generate.go index 293f461..abdbbf5 100644 --- a/go/ocr2/decryptionplugin/go_generate.go +++ b/go/ocr2plus/decryptionplugin/go_generate.go @@ -1,4 +1,6 @@ //go:generate protoc -I. --go_out=. types.proto //go:generate protoc -I. --go_out=./config ./config/config_types.proto +//go:generate protoc -I. --go_out=. ocr2_types.proto +//go:generate protoc -I. --go_out=. ocr3_types.proto package decryptionplugin diff --git a/go/ocr2/decryptionplugin/decryption.go b/go/ocr2plus/decryptionplugin/ocr2/decryption.go similarity index 91% rename from go/ocr2/decryptionplugin/decryption.go rename to go/ocr2plus/decryptionplugin/ocr2/decryption.go index cde69ef..4e2e5b4 100644 --- a/go/ocr2/decryptionplugin/decryption.go +++ b/go/ocr2plus/decryptionplugin/ocr2/decryption.go @@ -1,4 +1,4 @@ -package decryptionplugin +package ocr2decryptionplugin import ( "bytes" @@ -8,13 +8,14 @@ import ( "github.com/smartcontractkit/libocr/commontypes" "github.com/smartcontractkit/libocr/offchainreporting2/types" + "github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin" "github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin/config" "github.com/smartcontractkit/tdh2/go/tdh2/tdh2easy" "google.golang.org/protobuf/proto" ) type DecryptionReportingPluginFactory struct { - DecryptionQueue DecryptionQueuingService + DecryptionQueue decryptionplugin.DecryptionQueuingService ConfigParser config.ConfigParser PublicKey *tdh2easy.PublicKey PrivKeyShare *tdh2easy.PrivateShare @@ -24,7 +25,7 @@ type DecryptionReportingPluginFactory struct { type decryptionPlugin struct { logger commontypes.Logger - decryptionQueue DecryptionQueuingService + decryptionQueue decryptionplugin.DecryptionQueuingService publicKey *tdh2easy.PublicKey privKeyShare *tdh2easy.PrivateShare oracleToKeyShare map[commontypes.OracleID]int @@ -88,7 +89,7 @@ func (dp *decryptionPlugin) Query(ctx context.Context, ts types.ReportTimestamp) int(dp.specificConfig.Config.RequestTotalBytesLimit), ) - queryProto := Query{} + queryProto := decryptionplugin.Query{} ciphertextIDs := make(map[string]bool) allIDs := []string{} for _, request := range decryptionRequests { @@ -102,14 +103,14 @@ func (dp *decryptionPlugin) Query(ctx context.Context, ts types.ReportTimestamp) ciphertext := &tdh2easy.Ciphertext{} if err := ciphertext.UnmarshalVerify(request.Ciphertext, dp.publicKey); err != nil { - dp.decryptionQueue.SetResult(request.CiphertextId, nil, ErrUnmarshalling) + dp.decryptionQueue.SetResult(request.CiphertextId, nil, decryptionplugin.ErrUnmarshalling) dp.logger.Error("DecryptionReporting Query: cannot unmarshal the ciphertext, skipping it", commontypes.LogFields{ "error": err, "ciphertextID": request.CiphertextId.String(), }) continue } - queryProto.DecryptionRequests = append(queryProto.GetDecryptionRequests(), &CiphertextWithID{ + queryProto.DecryptionRequests = append(queryProto.GetDecryptionRequests(), &decryptionplugin.CiphertextWithID{ CiphertextId: request.CiphertextId, Ciphertext: request.Ciphertext, }) @@ -138,16 +139,16 @@ func (dp *decryptionPlugin) Observation(ctx context.Context, ts types.ReportTime "round": ts.Round, }) - queryProto := &Query{} + queryProto := &decryptionplugin.Query{} if err := proto.Unmarshal(query, queryProto); err != nil { return nil, fmt.Errorf("cannot unmarshal query: %w", err) } - observationProto := Observation{} + observationProto := decryptionplugin.Observation{} ciphertextIDs := make(map[string]bool) decryptedIDs := []string{} for _, request := range queryProto.DecryptionRequests { - ciphertextId := CiphertextId(request.CiphertextId) + ciphertextId := decryptionplugin.CiphertextId(request.CiphertextId) if _, ok := ciphertextIDs[string(ciphertextId)]; ok { dp.logger.Error("DecryptionReporting Observation: duplicate request in the same query, the leader is faulty", commontypes.LogFields{ "ciphertextID": ciphertextId.String(), @@ -167,7 +168,7 @@ func (dp *decryptionPlugin) Observation(ctx context.Context, ts types.ReportTime } if dp.specificConfig.Config.RequireLocalRequestCheck { queueCiphertextBytes, err := dp.decryptionQueue.GetCiphertext(ciphertextId) - if err != nil && errors.Is(err, ErrNotFound) { + if err != nil && errors.Is(err, decryptionplugin.ErrNotFound) { dp.logger.Warn("DecryptionReporting Observation: cannot find ciphertext locally, skipping it", commontypes.LogFields{ "error": err, "ciphertextID": ciphertextId.String(), @@ -190,7 +191,7 @@ func (dp *decryptionPlugin) Observation(ctx context.Context, ts types.ReportTime decryptionShare, err := tdh2easy.Decrypt(ciphertext, dp.privKeyShare) if err != nil { - dp.decryptionQueue.SetResult(ciphertextId, nil, ErrDecryption) + dp.decryptionQueue.SetResult(ciphertextId, nil, decryptionplugin.ErrDecryption) dp.logger.Error("DecryptionReporting Observation: cannot decrypt the ciphertext with the private key share", commontypes.LogFields{ "error": err, "ciphertextID": ciphertextId.String(), @@ -205,7 +206,7 @@ func (dp *decryptionPlugin) Observation(ctx context.Context, ts types.ReportTime }) continue } - observationProto.DecryptionShares = append(observationProto.DecryptionShares, &DecryptionShareWithID{ + observationProto.DecryptionShares = append(observationProto.DecryptionShares, &decryptionplugin.DecryptionShareWithID{ CiphertextId: ciphertextId, DecryptionShare: decryptionShareBytes, }) @@ -234,13 +235,13 @@ func (dp *decryptionPlugin) Report(ctx context.Context, ts types.ReportTimestamp "nObservations": len(obs), }) - queryProto := &Query{} + queryProto := &decryptionplugin.Query{} if err := proto.Unmarshal(query, queryProto); err != nil { return false, nil, fmt.Errorf("cannot unmarshal query: %w ", err) } ciphertexts := make(map[string]*tdh2easy.Ciphertext) for _, request := range queryProto.DecryptionRequests { - ciphertextId := CiphertextId(request.CiphertextId) + ciphertextId := decryptionplugin.CiphertextId(request.CiphertextId) ciphertext := &tdh2easy.Ciphertext{} if err := ciphertext.UnmarshalVerify(request.Ciphertext, dp.publicKey); err != nil { dp.logger.Error("DecryptionReporting Report: cannot unmarshal and verify the ciphertext, the leader is faulty", commontypes.LogFields{ @@ -254,7 +255,7 @@ func (dp *decryptionPlugin) Report(ctx context.Context, ts types.ReportTimestamp validDecryptionShares := make(map[string][]*tdh2easy.DecryptionShare) for _, ob := range obs { - observationProto := &Observation{} + observationProto := &decryptionplugin.Observation{} if err := proto.Unmarshal(ob.Observation, observationProto); err != nil { dp.logger.Error("DecryptionReporting Report: cannot unmarshal observation, skipping it", commontypes.LogFields{ "error": err, @@ -265,7 +266,7 @@ func (dp *decryptionPlugin) Report(ctx context.Context, ts types.ReportTimestamp ciphertextIDs := make(map[string]bool) for _, decryptionShareWithID := range observationProto.DecryptionShares { - ciphertextId := CiphertextId(decryptionShareWithID.CiphertextId) + ciphertextId := decryptionplugin.CiphertextId(decryptionShareWithID.CiphertextId) ciphertextIdRawStr := string(ciphertextId) if _, ok := ciphertextIDs[ciphertextIdRawStr]; ok { dp.logger.Error("DecryptionReporting Report: the observation has multiple decryption shares for the same ciphertext id", commontypes.LogFields{ @@ -307,9 +308,9 @@ func (dp *decryptionPlugin) Report(ctx context.Context, ts types.ReportTimestamp } } - reportProto := Report{} + reportProto := decryptionplugin.Report{} for _, request := range queryProto.DecryptionRequests { - ciphertextId := CiphertextId(request.CiphertextId) + ciphertextId := decryptionplugin.CiphertextId(request.CiphertextId) ciphertextIdRawStr := string(ciphertextId) decrShares, ok := validDecryptionShares[ciphertextIdRawStr] if !ok { @@ -336,7 +337,7 @@ func (dp *decryptionPlugin) Report(ctx context.Context, ts types.ReportTimestamp plaintext, err := tdh2easy.Aggregate(ciphertext, decrShares, dp.genericConfig.N) if err != nil { - dp.decryptionQueue.SetResult(ciphertextId, nil, ErrAggregation) + dp.decryptionQueue.SetResult(ciphertextId, nil, decryptionplugin.ErrAggregation) dp.logger.Error("DecryptionReporting Report: cannot aggregate decryption shares", commontypes.LogFields{ "error": err, "ciphertextID": ciphertextId.String(), @@ -349,10 +350,11 @@ func (dp *decryptionPlugin) Report(ctx context.Context, ts types.ReportTimestamp "round": ts.Round, "ciphertextID": ciphertextId.String(), }) - reportProto.ProcessedDecryptedRequests = append(reportProto.ProcessedDecryptedRequests, &ProcessedDecryptionRequest{ - CiphertextId: ciphertextId, - Plaintext: plaintext, - }) + reportProto.ProcessedDecryptedRequests = append(reportProto.ProcessedDecryptedRequests, + &decryptionplugin.ProcessedDecryptionRequest{ + CiphertextId: ciphertextId, + Plaintext: plaintext, + }) } dp.logger.Debug("DecryptionReporting Report: end", commontypes.LogFields{ @@ -403,7 +405,7 @@ func (dp *decryptionPlugin) ShouldAcceptFinalizedReport(ctx context.Context, ts "round": ts.Round, }) - reportProto := &Report{} + reportProto := &decryptionplugin.Report{} if err := proto.Unmarshal(report, reportProto); err != nil { return false, fmt.Errorf("cannot unmarshal report: %w", err) } diff --git a/go/ocr2/decryptionplugin/decryption_test.go b/go/ocr2plus/decryptionplugin/ocr2/decryption_test.go similarity index 89% rename from go/ocr2/decryptionplugin/decryption_test.go rename to go/ocr2plus/decryptionplugin/ocr2/decryption_test.go index 66235fc..44af672 100644 --- a/go/ocr2/decryptionplugin/decryption_test.go +++ b/go/ocr2plus/decryptionplugin/ocr2/decryption_test.go @@ -1,10 +1,11 @@ -package decryptionplugin +package ocr2decryptionplugin import ( "bytes" "context" "errors" "fmt" + "github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin" "reflect" "sort" "testing" @@ -34,11 +35,11 @@ func (l dummyLogger) Critical(msg string, fields commontypes.LogFields) {} // queue implements the DecryptionQueuingService interface. type queue struct { - q []DecryptionRequest + q []decryptionplugin.DecryptionRequest res [][]byte } -func (q *queue) GetRequests(requestCountLimit int, totalBytesLimit int) []DecryptionRequest { +func (q *queue) GetRequests(requestCountLimit int, totalBytesLimit int) []decryptionplugin.DecryptionRequest { stop := 0 for i, tot := 0, 0; i < len(q.q) && i < requestCountLimit; i++ { tot += len(q.q[i].Ciphertext) @@ -52,7 +53,7 @@ func (q *queue) GetRequests(requestCountLimit int, totalBytesLimit int) []Decryp return out } -func (q *queue) GetCiphertext(ciphertextId CiphertextId) ([]byte, error) { +func (q *queue) GetCiphertext(ciphertextId decryptionplugin.CiphertextId) ([]byte, error) { if bytes.Equal([]byte("please fail"), ciphertextId) { return nil, fmt.Errorf("some error") } @@ -61,10 +62,10 @@ func (q *queue) GetCiphertext(ciphertextId CiphertextId) ([]byte, error) { return e.Ciphertext, nil } } - return nil, ErrNotFound + return nil, decryptionplugin.ErrNotFound } -func (q *queue) SetResult(ciphertextId CiphertextId, plaintext []byte, err error) { +func (q *queue) SetResult(ciphertextId decryptionplugin.CiphertextId, plaintext []byte, err error) { q.res = append(q.res, ciphertextId) q.res = append(q.res, plaintext) } @@ -249,7 +250,7 @@ func TestQuery(t *testing.T) { if err != nil { t.Fatalf("GenerateKeys: %v", err) } - ctxts := []*CiphertextWithID{} + ctxts := []*decryptionplugin.CiphertextWithID{} for i := 0; i < 10; i++ { id := []byte(fmt.Sprintf("%d", i)) c, err := tdh2easy.Encrypt(pk, id) @@ -260,15 +261,15 @@ func TestQuery(t *testing.T) { if err != nil { t.Fatalf("Marshal: %v", err) } - ctxts = append(ctxts, &CiphertextWithID{ + ctxts = append(ctxts, &decryptionplugin.CiphertextWithID{ CiphertextId: id, Ciphertext: raw, }) } for _, tc := range []struct { name string - in []*CiphertextWithID - want []*CiphertextWithID + in []*decryptionplugin.CiphertextWithID + want []*decryptionplugin.CiphertextWithID }{ { name: "empty", @@ -285,7 +286,7 @@ func TestQuery(t *testing.T) { }, { name: "one wrong", - in: append(ctxts, &CiphertextWithID{ + in: append(ctxts, &decryptionplugin.CiphertextWithID{ CiphertextId: []byte("1"), Ciphertext: []byte("broken"), }), @@ -300,7 +301,7 @@ func TestQuery(t *testing.T) { t.Run(tc.name, func(t *testing.T) { q := &queue{} for _, e := range tc.in { - q.q = append(q.q, DecryptionRequest{ + q.q = append(q.q, decryptionplugin.DecryptionRequest{ CiphertextId: e.CiphertextId, Ciphertext: e.Ciphertext, }) @@ -320,11 +321,11 @@ func TestQuery(t *testing.T) { if err != nil { t.Fatalf("Query: %v", err) } - got := Query{} + got := decryptionplugin.Query{} if err := proto.Unmarshal(b, &got); err != nil { t.Fatalf("Unmarshal: %v", err) } - if d := cmp.Diff(got.DecryptionRequests, tc.want, cmpopts.IgnoreUnexported(CiphertextWithID{})); d != "" { + if d := cmp.Diff(got.DecryptionRequests, tc.want, cmpopts.IgnoreUnexported(decryptionplugin.CiphertextWithID{})); d != "" { t.Errorf("got/want diff=%v", d) } }) @@ -332,8 +333,8 @@ func TestQuery(t *testing.T) { } func TestShouldAcceptFinalizedReport(t *testing.T) { - r := &Report{ - ProcessedDecryptedRequests: []*ProcessedDecryptionRequest{ + r := &decryptionplugin.Report{ + ProcessedDecryptedRequests: []*decryptionplugin.ProcessedDecryptionRequest{ { CiphertextId: []byte("id1"), Plaintext: []byte("p1"), @@ -394,9 +395,9 @@ func TestShouldAcceptFinalizedReport(t *testing.T) { } } -func makeQuery(t *testing.T, c []*CiphertextWithID) []byte { +func makeQuery(t *testing.T, c []*decryptionplugin.CiphertextWithID) []byte { t.Helper() - b, err := proto.Marshal(&Query{ + b, err := proto.Marshal(&decryptionplugin.Query{ DecryptionRequests: c, }) if err != nil { @@ -417,7 +418,7 @@ func TestObservation(t *testing.T) { } q := &queue{} ctxts := []*ctxtWithId{} - ctxtsRaw := []*CiphertextWithID{} + ctxtsRaw := []*decryptionplugin.CiphertextWithID{} for i := 0; i < 10; i++ { id := []byte(fmt.Sprintf("%d", i)) c, err := tdh2easy.Encrypt(pk, id) @@ -428,13 +429,13 @@ func TestObservation(t *testing.T) { if err != nil { t.Fatalf("Marshal: %v", err) } - ctxtsRaw = append(ctxtsRaw, &CiphertextWithID{ + ctxtsRaw = append(ctxtsRaw, &decryptionplugin.CiphertextWithID{ CiphertextId: id, Ciphertext: raw, }) // add only 5 to the queue if i < 5 { - q.q = append(q.q, DecryptionRequest{ + q.q = append(q.q, decryptionplugin.DecryptionRequest{ CiphertextId: id, Ciphertext: raw, }) @@ -448,7 +449,7 @@ func TestObservation(t *testing.T) { name string query []byte local bool - queue DecryptionQueuingService + queue decryptionplugin.DecryptionQueuingService err error want []*ctxtWithId }{ @@ -487,7 +488,7 @@ func TestObservation(t *testing.T) { }, { name: "queue failing", - query: makeQuery(t, append(ctxtsRaw[:5], &CiphertextWithID{ + query: makeQuery(t, append(ctxtsRaw[:5], &decryptionplugin.CiphertextWithID{ CiphertextId: []byte("please fail"), Ciphertext: ctxtsRaw[5].Ciphertext, })), @@ -497,7 +498,7 @@ func TestObservation(t *testing.T) { }, { name: "queued ciphertext mismatch", - query: makeQuery(t, append(ctxtsRaw[:4], &CiphertextWithID{ + query: makeQuery(t, append(ctxtsRaw[:4], &decryptionplugin.CiphertextWithID{ CiphertextId: ctxtsRaw[4].CiphertextId, Ciphertext: ctxtsRaw[5].Ciphertext, })), @@ -507,7 +508,7 @@ func TestObservation(t *testing.T) { }, { name: "broken ciphertext", - query: makeQuery(t, append(ctxtsRaw[:3], &CiphertextWithID{ + query: makeQuery(t, append(ctxtsRaw[:3], &decryptionplugin.CiphertextWithID{ CiphertextId: []byte("id"), Ciphertext: []byte("broken"), })), @@ -537,7 +538,7 @@ func TestObservation(t *testing.T) { } else if err != nil { return } - var got Observation + var got decryptionplugin.Observation if err := proto.Unmarshal(b, &got); err != nil { t.Fatalf("Unmarshal: %v", err) } @@ -568,14 +569,14 @@ func makeObservations(t *testing.T, oracle2ids map[int][]string, id2shares map[s t.Helper() var out []types.AttributedObservation for oracle, ids := range oracle2ids { - decShares := []*DecryptionShareWithID{} + decShares := []*decryptionplugin.DecryptionShareWithID{} for _, id := range ids { - decShares = append(decShares, &DecryptionShareWithID{ + decShares = append(decShares, &decryptionplugin.DecryptionShareWithID{ CiphertextId: []byte(id), DecryptionShare: id2shares[id][oracle], }) } - ob, err := proto.Marshal(&Observation{ + ob, err := proto.Marshal(&decryptionplugin.Observation{ DecryptionShares: decShares, }) if err != nil { @@ -595,8 +596,8 @@ func TestReport(t *testing.T) { if err != nil { t.Fatalf("GenerateKeys: %v", err) } - want := []*ProcessedDecryptionRequest{} - ctxts := []*CiphertextWithID{} + want := []*decryptionplugin.ProcessedDecryptionRequest{} + ctxts := []*decryptionplugin.CiphertextWithID{} shares := map[string][][]byte{} // generate id-plaintext pairs, "id0"->"0", "id1"->"1", "id2"->"2" for i := 0; i < 3; i++ { @@ -610,11 +611,11 @@ func TestReport(t *testing.T) { if err != nil { t.Fatalf("Marshal: %v", err) } - ctxts = append(ctxts, &CiphertextWithID{ + ctxts = append(ctxts, &decryptionplugin.CiphertextWithID{ CiphertextId: id, Ciphertext: raw, }) - want = append(want, &ProcessedDecryptionRequest{ + want = append(want, &decryptionplugin.ProcessedDecryptionRequest{ CiphertextId: id, Plaintext: plain, }) @@ -636,7 +637,7 @@ func TestReport(t *testing.T) { obs []types.AttributedObservation err error wantProcessed bool - want []*ProcessedDecryptionRequest + want []*decryptionplugin.ProcessedDecryptionRequest }{ { name: "empty", @@ -649,7 +650,7 @@ func TestReport(t *testing.T) { }, { name: "broken ciphertext", - query: makeQuery(t, append(ctxts, &CiphertextWithID{ + query: makeQuery(t, append(ctxts, &decryptionplugin.CiphertextWithID{ CiphertextId: []byte("id"), Ciphertext: []byte("broken"), })), @@ -783,7 +784,7 @@ func TestReport(t *testing.T) { // make sure Report() output is deterministic _, secondReportBytes, _ := dp.Report(context.Background(), types.ReportTimestamp{}, tc.query, tc.obs) require.Equal(t, reportBytes, secondReportBytes) - var report Report + var report decryptionplugin.Report if err := proto.Unmarshal(reportBytes, &report); err != nil { t.Errorf("Unmarshal: %v", err) } @@ -792,7 +793,7 @@ func TestReport(t *testing.T) { sort.Slice(got, func(i, j int) bool { return string(got[i].CiphertextId) < string(got[j].CiphertextId) }) - if d := cmp.Diff(got, tc.want, cmpopts.IgnoreUnexported(ProcessedDecryptionRequest{})); d != "" { + if d := cmp.Diff(got, tc.want, cmpopts.IgnoreUnexported(decryptionplugin.ProcessedDecryptionRequest{})); d != "" { t.Errorf("got/want diff=%v", d) } }) diff --git a/go/ocr2plus/decryptionplugin/ocr2_types.pb.go b/go/ocr2plus/decryptionplugin/ocr2_types.pb.go new file mode 100644 index 0000000..c361e04 --- /dev/null +++ b/go/ocr2plus/decryptionplugin/ocr2_types.pb.go @@ -0,0 +1,151 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.20.0 +// source: ocr2_types.proto + +package decryptionplugin + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Report struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProcessedDecryptedRequests []*ProcessedDecryptionRequest `protobuf:"bytes,1,rep,name=processedDecryptedRequests,proto3" json:"processedDecryptedRequests,omitempty"` +} + +func (x *Report) Reset() { + *x = Report{} + if protoimpl.UnsafeEnabled { + mi := &file_ocr2_types_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Report) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Report) ProtoMessage() {} + +func (x *Report) ProtoReflect() protoreflect.Message { + mi := &file_ocr2_types_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Report.ProtoReflect.Descriptor instead. +func (*Report) Descriptor() ([]byte, []int) { + return file_ocr2_types_proto_rawDescGZIP(), []int{0} +} + +func (x *Report) GetProcessedDecryptedRequests() []*ProcessedDecryptionRequest { + if x != nil { + return x.ProcessedDecryptedRequests + } + return nil +} + +var File_ocr2_types_proto protoreflect.FileDescriptor + +var file_ocr2_types_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x6f, 0x63, 0x72, 0x32, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0a, 0x6f, 0x63, 0x72, 0x32, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x1a, 0x0b, + 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6b, 0x0a, 0x06, 0x52, + 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x61, 0x0a, 0x1a, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, + 0x65, 0x64, 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x44, 0x65, 0x63, 0x72, 0x79, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x1a, 0x70, 0x72, + 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x3b, 0x64, + 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_ocr2_types_proto_rawDescOnce sync.Once + file_ocr2_types_proto_rawDescData = file_ocr2_types_proto_rawDesc +) + +func file_ocr2_types_proto_rawDescGZIP() []byte { + file_ocr2_types_proto_rawDescOnce.Do(func() { + file_ocr2_types_proto_rawDescData = protoimpl.X.CompressGZIP(file_ocr2_types_proto_rawDescData) + }) + return file_ocr2_types_proto_rawDescData +} + +var file_ocr2_types_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_ocr2_types_proto_goTypes = []interface{}{ + (*Report)(nil), // 0: ocr2_types.Report + (*ProcessedDecryptionRequest)(nil), // 1: types.ProcessedDecryptionRequest +} +var file_ocr2_types_proto_depIdxs = []int32{ + 1, // 0: ocr2_types.Report.processedDecryptedRequests:type_name -> types.ProcessedDecryptionRequest + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_ocr2_types_proto_init() } +func file_ocr2_types_proto_init() { + if File_ocr2_types_proto != nil { + return + } + file_types_proto_init() + if !protoimpl.UnsafeEnabled { + file_ocr2_types_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Report); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_ocr2_types_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_ocr2_types_proto_goTypes, + DependencyIndexes: file_ocr2_types_proto_depIdxs, + MessageInfos: file_ocr2_types_proto_msgTypes, + }.Build() + File_ocr2_types_proto = out.File + file_ocr2_types_proto_rawDesc = nil + file_ocr2_types_proto_goTypes = nil + file_ocr2_types_proto_depIdxs = nil +} diff --git a/go/ocr2plus/decryptionplugin/ocr2_types.proto b/go/ocr2plus/decryptionplugin/ocr2_types.proto new file mode 100644 index 0000000..b0bb9a4 --- /dev/null +++ b/go/ocr2plus/decryptionplugin/ocr2_types.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +option go_package = "./;decryptionplugin"; + +package ocr2_types; + +import "types.proto"; + +message Report { + repeated types.ProcessedDecryptionRequest processedDecryptedRequests = 1; +} \ No newline at end of file diff --git a/go/ocr2plus/decryptionplugin/ocr3/decryption.go b/go/ocr2plus/decryptionplugin/ocr3/decryption.go new file mode 100644 index 0000000..e052f28 --- /dev/null +++ b/go/ocr2plus/decryptionplugin/ocr3/decryption.go @@ -0,0 +1,515 @@ +package ocr3decryptionplugin + +import ( + "bytes" + "context" + "errors" + "fmt" + + "github.com/smartcontractkit/libocr/commontypes" + "github.com/smartcontractkit/libocr/offchainreporting2/types" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" + "github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin" + "github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin/config" + "github.com/smartcontractkit/tdh2/go/tdh2/tdh2easy" + "google.golang.org/protobuf/proto" +) + +type DecryptionReportingPluginFactory struct { + DecryptionQueue decryptionplugin.DecryptionQueuingService + ConfigParser config.ConfigParser + PublicKey *tdh2easy.PublicKey + PrivKeyShare *tdh2easy.PrivateShare + OracleToKeyShare map[commontypes.OracleID]int + Logger commontypes.Logger +} + +type decryptionPlugin struct { + logger commontypes.Logger + decryptionQueue decryptionplugin.DecryptionQueuingService + publicKey *tdh2easy.PublicKey + privKeyShare *tdh2easy.PrivateShare + oracleToKeyShare map[commontypes.OracleID]int + genericConfig *types.ReportingPluginConfig + specificConfig *config.ReportingPluginConfigWrapper +} + +type ReportInfo struct{} + +// NewReportingPlugin complies with ReportingPluginFactory. +func (f DecryptionReportingPluginFactory) NewReportingPlugin(rpConfig types.ReportingPluginConfig) (ocr3types.ReportingPlugin[ReportInfo], ocr3types.ReportingPluginInfo, error) { + pluginConfig, err := f.ConfigParser.ParseConfig(rpConfig.OffchainConfig) + if err != nil { + return nil, + ocr3types.ReportingPluginInfo{}, + fmt.Errorf("unable to decode reporting plugin config: %w", err) + } + + // The number of decryption shares K needed to reconstruct the plaintext should satisfy F 2*rpConfig.F+1 { + return nil, + ocr3types.ReportingPluginInfo{}, + fmt.Errorf("invalid configuration with K=%d and F=%d: decryption threshold K must satisfy F < K <= 2F+1", pluginConfig.Config.K, rpConfig.F) + } + + info := ocr3types.ReportingPluginInfo{ + Name: "ThresholdDecryption", + Limits: ocr3types.ReportingPluginLimits{ + MaxQueryLength: int(pluginConfig.Config.GetMaxQueryLengthBytes()), + MaxObservationLength: int(pluginConfig.Config.GetMaxObservationLengthBytes()), + MaxOutcomeLength: int(pluginConfig.Config.GetMaxReportLengthBytes()), + MaxReportLength: int(pluginConfig.Config.GetMaxReportLengthBytes()), + MaxReportCount: int(pluginConfig.Config.GetRequestCountLimit()), + }, + } + + plugin := decryptionPlugin{ + f.Logger, + f.DecryptionQueue, + f.PublicKey, + f.PrivKeyShare, + f.OracleToKeyShare, + &rpConfig, + pluginConfig, + } + + return &plugin, info, nil +} + +// Query creates a query with the oldest pending decryption requests. +func (dp *decryptionPlugin) Query(ctx context.Context, outctx ocr3types.OutcomeContext) (types.Query, error) { + dp.logger.Debug("DecryptionReporting Query: start", commontypes.LogFields{ + "seqNr": outctx.SeqNr, + }) + + decryptionRequests := dp.decryptionQueue.GetRequests( + int(dp.specificConfig.Config.RequestCountLimit), + int(dp.specificConfig.Config.RequestTotalBytesLimit), + ) + + queryProto := decryptionplugin.Query{} + ciphertextIDs := make(map[string]bool) + allIDs := []string{} + for _, request := range decryptionRequests { + if _, ok := ciphertextIDs[string(request.CiphertextId)]; ok { + dp.logger.Error("DecryptionReporting Query: duplicate request, skipping it", commontypes.LogFields{ + "ciphertextID": request.CiphertextId.String(), + }) + continue + } + ciphertextIDs[string(request.CiphertextId)] = true + + ciphertext := &tdh2easy.Ciphertext{} + if err := ciphertext.UnmarshalVerify(request.Ciphertext, dp.publicKey); err != nil { + dp.decryptionQueue.SetResult(request.CiphertextId, nil, decryptionplugin.ErrUnmarshalling) + dp.logger.Error("DecryptionReporting Query: cannot unmarshal the ciphertext, skipping it", commontypes.LogFields{ + "error": err, + "ciphertextID": request.CiphertextId.String(), + }) + continue + } + queryProto.DecryptionRequests = append(queryProto.GetDecryptionRequests(), &decryptionplugin.CiphertextWithID{ + CiphertextId: request.CiphertextId, + Ciphertext: request.Ciphertext, + }) + allIDs = append(allIDs, request.CiphertextId.String()) + } + + dp.logger.Debug("DecryptionReporting Query: end", commontypes.LogFields{ + "seqNr": outctx.SeqNr, + "queryLen": len(queryProto.DecryptionRequests), + "ciphertextIDs": allIDs, + }) + queryProtoBytes, err := proto.Marshal(&queryProto) + if err != nil { + return nil, fmt.Errorf("cannot marshal query: %w", err) + } + return queryProtoBytes, nil +} + +// Observation creates a decryption share for each request in the query. +// If dp.specificConfig.Config.LocalRequest is true, then the oracle +// only creates a decryption share for the decryption requests which it has locally. +func (dp *decryptionPlugin) Observation(ctx context.Context, outctx ocr3types.OutcomeContext, query types.Query) (types.Observation, error) { + dp.logger.Debug("DecryptionReporting Observation: start", commontypes.LogFields{ + "seqNr": outctx.SeqNr, + }) + + ciphertexts, err := dp.getCiphertexts(query) + if err != nil { + return nil, fmt.Errorf("cannot process the query: %w", err) + } + + ciphertextIDs := make(map[string]bool) + observationProto := decryptionplugin.Observation{} + decryptedIDs := []string{} + + for ciphertextIdRawStr, ciphertext := range ciphertexts { + if _, ok := ciphertextIDs[ciphertextIdRawStr]; ok { + dp.logger.Error("DecryptionReporting Observation: duplicate request in the same query, the leader is faulty", commontypes.LogFields{ + "ciphertextID": ciphertext.ciphertextId.String(), + }) + return nil, fmt.Errorf("duplicate request in the same query") + } + ciphertextIDs[ciphertextIdRawStr] = true + + if dp.specificConfig.Config.RequireLocalRequestCheck { + queueCiphertextBytes, err := dp.decryptionQueue.GetCiphertext(ciphertext.ciphertextId) + if err != nil && errors.Is(err, decryptionplugin.ErrNotFound) { + dp.logger.Warn("DecryptionReporting Observation: cannot find ciphertext locally, skipping it", commontypes.LogFields{ + "error": err, + "ciphertextID": ciphertext.ciphertextId.String(), + }) + continue + } else if err != nil { + dp.logger.Error("DecryptionReporting Observation: failed when looking for ciphertext locally, skipping it", commontypes.LogFields{ + "error": err, + "ciphertextID": ciphertext.ciphertextId.String(), + }) + continue + } + if !bytes.Equal(queueCiphertextBytes, ciphertext.ciphertextBytes) { + dp.logger.Error("DecryptionReporting Observation: local ciphertext does not match the query ciphertext, skipping it", commontypes.LogFields{ + "ciphertextID": ciphertext.ciphertextId.String(), + }) + continue + } + } + + decryptionShare, err := tdh2easy.Decrypt(ciphertext.ciphertext, dp.privKeyShare) + if err != nil { + dp.decryptionQueue.SetResult(ciphertext.ciphertextId, nil, decryptionplugin.ErrDecryption) + dp.logger.Error("DecryptionReporting Observation: cannot decrypt the ciphertext with the private key share", commontypes.LogFields{ + "error": err, + "ciphertextID": ciphertext.ciphertextId.String(), + }) + continue + } + decryptionShareBytes, err := decryptionShare.Marshal() + if err != nil { + dp.logger.Error("DecryptionReporting Observation: cannot marshal the decryption share, skipping it", commontypes.LogFields{ + "error": err, + "ciphertextID": ciphertext.ciphertextId.String(), + }) + continue + } + observationProto.DecryptionShares = append(observationProto.DecryptionShares, &decryptionplugin.DecryptionShareWithID{ + CiphertextId: ciphertext.ciphertextId, + DecryptionShare: decryptionShareBytes, + }) + decryptedIDs = append(decryptedIDs, ciphertext.ciphertextId.String()) + } + + dp.logger.Debug("DecryptionReporting Observation: end", commontypes.LogFields{ + "seqNr": outctx.SeqNr, + "decryptedRequests": len(observationProto.DecryptionShares), + "totalRequests": len(ciphertexts), + "ciphertextIDs": decryptedIDs, + }) + observationProtoBytes, err := proto.Marshal(&observationProto) + if err != nil { + return nil, fmt.Errorf("cannot marshal observation: %w", err) + } + return observationProtoBytes, nil +} + +func (dp *decryptionPlugin) ValidateObservation(outctx ocr3types.OutcomeContext, query types.Query, ao types.AttributedObservation) error { + dp.logger.Debug("DecryptionReporting ValidateObservation: start", commontypes.LogFields{ + "seqNr": outctx.SeqNr, + }) + + observationProto := &decryptionplugin.Observation{} + if err := proto.Unmarshal(ao.Observation, observationProto); err != nil { + return fmt.Errorf("cannot unmarshal observation from observer %d: %w", ao.Observer, err) + } + + ciphertexts, err := dp.getCiphertexts(query) + if err != nil { + return fmt.Errorf("cannot process query: %w", err) + } + + ciphertextIDs := make(map[string]bool) + for _, decryptionShareWithID := range observationProto.DecryptionShares { + ciphertextId := decryptionplugin.CiphertextId(decryptionShareWithID.CiphertextId) + ciphertextIdRawStr := string(ciphertextId) + if _, ok := ciphertextIDs[ciphertextIdRawStr]; ok { + return fmt.Errorf("the observation has multiple decryption shares for the same ciphertext id %s", ciphertextId.String()) + } + ciphertextIDs[ciphertextIdRawStr] = true + + ciphertext, ok := ciphertexts[ciphertextIdRawStr] + if !ok { + fmt.Errorf("there is not ciphertext in the query with matching id %s", ciphertextId.String()) + } + + _, err := dp.getValidDecryptionShare(ao.Observer, + ciphertext.ciphertext, decryptionShareWithID.DecryptionShare) + if err != nil { + return fmt.Errorf("invalid decryption share for ciphertext id %s: %w", ciphertextId.String(), err) + } + } + + dp.logger.Debug("DecryptionReporting ValidateObservation: end", commontypes.LogFields{ + "seqNr": outctx.SeqNr, + }) + + return nil +} + +// ObservationQuorum returns the number of decryption shares K needed to reconstruct the plaintext should satisfy F dp.genericConfig.F+1 { + return 0, fmt.Errorf("invalid configuration with K=%d and F=%d: decryption threshold K must satisfy F < K <= 2F+1", dp.specificConfig.Config.K, dp.genericConfig.F) + } + return ocr3types.Quorum(dp.specificConfig.Config.K + 1), nil +} + +// Outcome aggregates decryption shares from Observations to derive the plaintext. +func (dp *decryptionPlugin) Outcome(outctx ocr3types.OutcomeContext, query types.Query, aos []types.AttributedObservation) (ocr3types.Outcome, error) { + dp.logger.Debug("DecryptionReporting Outcome: start", commontypes.LogFields{ + "seqNr": outctx.SeqNr, + "nObservations": len(aos), + }) + + ciphertexts, err := dp.getCiphertexts(query) + if err != nil { + return nil, fmt.Errorf("cannot process query: %w", err) + } + + validDecryptionShares := make(map[string][]*tdh2easy.DecryptionShare) + for _, ob := range aos { + observationProto := &decryptionplugin.Observation{} + if err := proto.Unmarshal(ob.Observation, observationProto); err != nil { + dp.logger.Error("DecryptionReporting Outcome: cannot unmarshal observation, skipping it", commontypes.LogFields{ + "error": err, + "observer": ob.Observer, + }) + continue + } + + ciphertextIDs := make(map[string]bool) + for _, decryptionShareWithID := range observationProto.DecryptionShares { + ciphertextId := decryptionplugin.CiphertextId(decryptionShareWithID.CiphertextId) + ciphertextIdRawStr := string(ciphertextId) + if _, ok := ciphertextIDs[ciphertextIdRawStr]; ok { + dp.logger.Error("DecryptionReporting Outcome: the observation has multiple decryption shares for the same ciphertext id", commontypes.LogFields{ + "ciphertextID": ciphertextId.String(), + "observer": ob.Observer, + }) + continue + } + ciphertextIDs[ciphertextIdRawStr] = true + + ciphertext, ok := ciphertexts[ciphertextIdRawStr] + if !ok { + dp.logger.Error("DecryptionReporting Outcome: there is not ciphertext in the query with matching id", commontypes.LogFields{ + "ciphertextID": ciphertextId.String(), + "observer": ob.Observer, + }) + continue + } + + validDecryptionShare, err := dp.getValidDecryptionShare(ob.Observer, + ciphertext.ciphertext, decryptionShareWithID.DecryptionShare) + if err != nil { + dp.logger.Error("DecryptionReporting Outcome: invalid decryption share", commontypes.LogFields{ + "error": err, + "ciphertextID": ciphertextId.String(), + "observer": ob.Observer, + }) + continue + } + + if len(validDecryptionShares[ciphertextIdRawStr]) < int(dp.specificConfig.Config.K) { + validDecryptionShares[ciphertextIdRawStr] = append(validDecryptionShares[ciphertextIdRawStr], validDecryptionShare) + } else { + dp.logger.Trace("DecryptionReporting Outcome: we have already k valid decryption shares", commontypes.LogFields{ + "ciphertextID": ciphertextId.String(), + "observer": ob.Observer, + }) + } + } + } + + outcomeProto := decryptionplugin.Outcome{} + for ciphertextIdRawStr, ciphertext := range ciphertexts { + decrShares, ok := validDecryptionShares[ciphertextIdRawStr] + if !ok { + // Request not included in any observation in the current round. + dp.logger.Debug("DecryptionReporting Outcome: ciphertextID was not included in any observation in the current round", commontypes.LogFields{ + "ciphertextID": ciphertext.ciphertextId.String(), + }) + continue + } + ciphertext, ok := ciphertexts[ciphertextIdRawStr] + if !ok { + dp.logger.Error("DecryptionReporting Outcome: there is not ciphertext in the query with matching id, skipping aggregation of decryption shares", commontypes.LogFields{ + "ciphertextID": ciphertext.ciphertextId.String(), + }) + continue + } + + if len(decrShares) < int(dp.specificConfig.Config.K) { + dp.logger.Debug("DecryptionReporting Outcome: not enough valid decryption shares after processing all observations, skipping aggregation of decryption shares", commontypes.LogFields{ + "ciphertextID": ciphertext.ciphertextId.String(), + }) + continue + } + + plaintext, err := tdh2easy.Aggregate(ciphertext.ciphertext, decrShares, dp.genericConfig.N) + if err != nil { + dp.decryptionQueue.SetResult(ciphertext.ciphertextId, nil, decryptionplugin.ErrAggregation) + dp.logger.Error("DecryptionReporting Outcome: cannot aggregate decryption shares", commontypes.LogFields{ + "error": err, + "ciphertextID": ciphertext.ciphertextId.String(), + }) + continue + } + + dp.logger.Debug("DecryptionReporting Outcome: plaintext aggregated successfully", commontypes.LogFields{ + "seqNr": outctx.SeqNr, + "ciphertextID": ciphertext.ciphertextId.String(), + }) + outcomeProto.ProcessedDecryptedRequests = append(outcomeProto.ProcessedDecryptedRequests, &decryptionplugin.ProcessedDecryptionRequest{ + CiphertextId: ciphertext.ciphertextId, + Plaintext: plaintext, + }) + } + + dp.logger.Debug("DecryptionReporting Outcome: end", commontypes.LogFields{ + "seqNr": outctx.SeqNr, + "aggregatedDecryptionShares": len(outcomeProto.ProcessedDecryptedRequests), + "reporting": len(outcomeProto.ProcessedDecryptedRequests) > 0, + }) + + outcomeBytes, err := proto.Marshal(&outcomeProto) + if err != nil { + return nil, fmt.Errorf("cannot marshal report: %w", err) + } + return outcomeBytes, nil +} + +func (dp *decryptionPlugin) Reports(seqNr uint64, rawOutcome ocr3types.Outcome) ([]ocr3types.ReportWithInfo[ReportInfo], error) { + dp.logger.Debug("DecryptionReporting Reports: start", commontypes.LogFields{ + "seqNr": seqNr, + }) + + var outcome decryptionplugin.Outcome + if err := proto.Unmarshal(rawOutcome, &outcome); err != nil { + return nil, fmt.Errorf("error unmarshalling outcome: %w", err) + } + + rwis := []ocr3types.ReportWithInfo[ReportInfo]{} + for _, processedDecryptiondRequest := range outcome.ProcessedDecryptedRequests { + reportBytes, err := proto.Marshal(processedDecryptiondRequest) + if err != nil { + return nil, fmt.Errorf("cannot marshal report: %w", err) + } + rwis = append(rwis, + ocr3types.ReportWithInfo[ReportInfo]{ + reportBytes, + ReportInfo{}, + }) + } + + dp.logger.Debug("DecryptionReporting Reports: end", commontypes.LogFields{ + "seqNr": seqNr, + "nReports": len(rwis), + }) + + return rwis, nil +} + +// ShouldAcceptAttestedReport updates the decryption queue. +// Returns always false as the report will not be transmitted on-chain. +func (dp *decryptionPlugin) ShouldAcceptAttestedReport(ctx context.Context, seqNr uint64, rwi ocr3types.ReportWithInfo[ReportInfo]) (bool, error) { + dp.logger.Debug("DecryptionReporting ShouldAcceptFinalizedReport: start", commontypes.LogFields{ + "SeqNr": seqNr, + }) + + reportProto := &decryptionplugin.Report{} + if err := proto.Unmarshal(rwi.Report, reportProto); err != nil { + return false, fmt.Errorf("cannot unmarshal report: %w", err) + } + + for _, item := range reportProto.ProcessedDecryptedRequests { + dp.decryptionQueue.SetResult(item.CiphertextId, item.Plaintext, nil) + } + + dp.logger.Debug("DecryptionReporting ShouldAcceptFinalizedReport: end", commontypes.LogFields{ + "SeqNr": seqNr, + "accepting": false, + }) + + return false, nil +} + +// ShouldTransmitAcceptedReport is a no-op +func (dp *decryptionPlugin) ShouldTransmitAcceptedReport(ctx context.Context, seqNr uint64, r ocr3types.ReportWithInfo[ReportInfo]) (bool, error) { + return false, nil +} + +type ciphertextStruct struct { + ciphertextId decryptionplugin.CiphertextId + ciphertextBytes []byte + ciphertext *tdh2easy.Ciphertext +} + +func (dp *decryptionPlugin) getCiphertexts(query types.Query) (map[string]ciphertextStruct, error) { + ciphertexts := make(map[string]ciphertextStruct) + queryProto := &decryptionplugin.Query{} + if err := proto.Unmarshal(query, queryProto); err != nil { + return nil, fmt.Errorf("cannot unmarshal query: %w ", err) + } + for _, request := range queryProto.DecryptionRequests { + ciphertextId := decryptionplugin.CiphertextId(request.CiphertextId) + ciphertext := &tdh2easy.Ciphertext{} + if err := ciphertext.UnmarshalVerify(request.Ciphertext, dp.publicKey); err != nil { + dp.logger.Error("DecryptionReporting: cannot unmarshall and verify the ciphertexts, the leader is faulty", commontypes.LogFields{ + "error": err, + "ciphertextID": string(ciphertextId), + }) + return nil, fmt.Errorf("cannot unmarshal and verify the ciphertext: %w", err) + } + ciphertexts[string(ciphertextId)] = ciphertextStruct{ + ciphertextId, + request.Ciphertext, + ciphertext, + } + } + return ciphertexts, nil +} + +func (dp *decryptionPlugin) getValidDecryptionShare(observer commontypes.OracleID, + ciphertext *tdh2easy.Ciphertext, decryptionShareBytes []byte) (*tdh2easy.DecryptionShare, error) { + decryptionShare := &tdh2easy.DecryptionShare{} + if err := decryptionShare.Unmarshal(decryptionShareBytes); err != nil { + return nil, fmt.Errorf("cannot unmarshal decryption share: %w", err) + } + + expectedKeyShareIndex, ok := dp.oracleToKeyShare[observer] + if !ok { + return nil, fmt.Errorf("invalid observer ID") + } + + if expectedKeyShareIndex != decryptionShare.Index() { + return nil, fmt.Errorf("invalid decryption share index: expected %d and got %d", expectedKeyShareIndex, decryptionShare.Index()) + } + + if err := tdh2easy.VerifyShare(ciphertext, dp.publicKey, decryptionShare); err != nil { + return nil, fmt.Errorf("decryption share verification failed: %w", err) + } + return decryptionShare, nil +} + +// Close complies with ReportingPlugin +func (dp *decryptionPlugin) Close() error { + dp.logger.Debug("DecryptionReporting Close", nil) + return nil +} diff --git a/go/ocr2plus/decryptionplugin/ocr3/decryption_test.go b/go/ocr2plus/decryptionplugin/ocr3/decryption_test.go new file mode 100644 index 0000000..008d4cb --- /dev/null +++ b/go/ocr2plus/decryptionplugin/ocr3/decryption_test.go @@ -0,0 +1 @@ +package ocr3decryptionplugin diff --git a/go/ocr2plus/decryptionplugin/ocr3_types.pb.go b/go/ocr2plus/decryptionplugin/ocr3_types.pb.go new file mode 100644 index 0000000..023b289 --- /dev/null +++ b/go/ocr2plus/decryptionplugin/ocr3_types.pb.go @@ -0,0 +1,151 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.20.0 +// source: ocr3_types.proto + +package decryptionplugin + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Outcome struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProcessedDecryptedRequests []*ProcessedDecryptionRequest `protobuf:"bytes,1,rep,name=processedDecryptedRequests,proto3" json:"processedDecryptedRequests,omitempty"` +} + +func (x *Outcome) Reset() { + *x = Outcome{} + if protoimpl.UnsafeEnabled { + mi := &file_ocr3_types_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Outcome) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Outcome) ProtoMessage() {} + +func (x *Outcome) ProtoReflect() protoreflect.Message { + mi := &file_ocr3_types_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Outcome.ProtoReflect.Descriptor instead. +func (*Outcome) Descriptor() ([]byte, []int) { + return file_ocr3_types_proto_rawDescGZIP(), []int{0} +} + +func (x *Outcome) GetProcessedDecryptedRequests() []*ProcessedDecryptionRequest { + if x != nil { + return x.ProcessedDecryptedRequests + } + return nil +} + +var File_ocr3_types_proto protoreflect.FileDescriptor + +var file_ocr3_types_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0a, 0x6f, 0x63, 0x72, 0x33, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x1a, 0x0b, + 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6c, 0x0a, 0x07, 0x4f, + 0x75, 0x74, 0x63, 0x6f, 0x6d, 0x65, 0x12, 0x61, 0x0a, 0x1a, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, + 0x73, 0x65, 0x64, 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x74, 0x79, 0x70, + 0x65, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x44, 0x65, 0x63, 0x72, + 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x1a, 0x70, + 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, + 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x3b, + 0x64, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_ocr3_types_proto_rawDescOnce sync.Once + file_ocr3_types_proto_rawDescData = file_ocr3_types_proto_rawDesc +) + +func file_ocr3_types_proto_rawDescGZIP() []byte { + file_ocr3_types_proto_rawDescOnce.Do(func() { + file_ocr3_types_proto_rawDescData = protoimpl.X.CompressGZIP(file_ocr3_types_proto_rawDescData) + }) + return file_ocr3_types_proto_rawDescData +} + +var file_ocr3_types_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_ocr3_types_proto_goTypes = []interface{}{ + (*Outcome)(nil), // 0: ocr3_types.Outcome + (*ProcessedDecryptionRequest)(nil), // 1: types.ProcessedDecryptionRequest +} +var file_ocr3_types_proto_depIdxs = []int32{ + 1, // 0: ocr3_types.Outcome.processedDecryptedRequests:type_name -> types.ProcessedDecryptionRequest + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_ocr3_types_proto_init() } +func file_ocr3_types_proto_init() { + if File_ocr3_types_proto != nil { + return + } + file_types_proto_init() + if !protoimpl.UnsafeEnabled { + file_ocr3_types_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Outcome); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_ocr3_types_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_ocr3_types_proto_goTypes, + DependencyIndexes: file_ocr3_types_proto_depIdxs, + MessageInfos: file_ocr3_types_proto_msgTypes, + }.Build() + File_ocr3_types_proto = out.File + file_ocr3_types_proto_rawDesc = nil + file_ocr3_types_proto_goTypes = nil + file_ocr3_types_proto_depIdxs = nil +} diff --git a/go/ocr2plus/decryptionplugin/ocr3_types.proto b/go/ocr2plus/decryptionplugin/ocr3_types.proto new file mode 100644 index 0000000..4c0c579 --- /dev/null +++ b/go/ocr2plus/decryptionplugin/ocr3_types.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +option go_package = "./;decryptionplugin"; + +package ocr3_types; + +import "types.proto"; + +message Outcome { + repeated types.ProcessedDecryptionRequest processedDecryptedRequests = 1; +} + + diff --git a/go/ocr2/decryptionplugin/queue.go b/go/ocr2plus/decryptionplugin/queue.go similarity index 68% rename from go/ocr2/decryptionplugin/queue.go rename to go/ocr2plus/decryptionplugin/queue.go index 0425574..f2bb292 100644 --- a/go/ocr2/decryptionplugin/queue.go +++ b/go/ocr2plus/decryptionplugin/queue.go @@ -6,10 +6,10 @@ import ( ) var ( - ErrNotFound = fmt.Errorf("not found") - ErrUnmarshalling = fmt.Errorf("cannot unmarshal the ciphertext in the query plugin function") - ErrDecryption = fmt.Errorf("cannot decrypt the ciphertext with the private key share in observation plugin function") - ErrAggregation = fmt.Errorf("cannot aggregate valid decryption shares in report plugn function") + ErrNotFound = fmt.Errorf("not found") + ErrUnmarshalling = fmt.Errorf("cannot unmarshal the ciphertext in the query plugin function") + ErrDecryption = fmt.Errorf("cannot decrypt the ciphertext with the private key share in observation plugin function") + ErrAggregation = fmt.Errorf("cannot aggregate valid decryption shares in report plugn function") ) type CiphertextId []byte diff --git a/go/ocr2/decryptionplugin/types.pb.go b/go/ocr2plus/decryptionplugin/types.pb.go similarity index 82% rename from go/ocr2/decryptionplugin/types.pb.go rename to go/ocr2plus/decryptionplugin/types.pb.go index 87c2d60..02ecf22 100644 --- a/go/ocr2/decryptionplugin/types.pb.go +++ b/go/ocr2plus/decryptionplugin/types.pb.go @@ -279,53 +279,6 @@ func (x *ProcessedDecryptionRequest) GetPlaintext() []byte { return nil } -type Report struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ProcessedDecryptedRequests []*ProcessedDecryptionRequest `protobuf:"bytes,1,rep,name=processedDecryptedRequests,proto3" json:"processedDecryptedRequests,omitempty"` -} - -func (x *Report) Reset() { - *x = Report{} - if protoimpl.UnsafeEnabled { - mi := &file_types_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Report) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Report) ProtoMessage() {} - -func (x *Report) ProtoReflect() protoreflect.Message { - mi := &file_types_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Report.ProtoReflect.Descriptor instead. -func (*Report) Descriptor() ([]byte, []int) { - return file_types_proto_rawDescGZIP(), []int{5} -} - -func (x *Report) GetProcessedDecryptedRequests() []*ProcessedDecryptionRequest { - if x != nil { - return x.ProcessedDecryptedRequests - } - return nil -} - var File_types_proto protoreflect.FileDescriptor var file_types_proto_rawDesc = []byte{ @@ -359,15 +312,9 @@ var file_types_proto_rawDesc = []byte{ 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x6c, 0x61, 0x69, 0x6e, - 0x74, 0x65, 0x78, 0x74, 0x22, 0x6b, 0x0a, 0x06, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x61, - 0x0a, 0x1a, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x44, 0x65, 0x63, 0x72, 0x79, - 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, - 0x73, 0x73, 0x65, 0x64, 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x1a, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, - 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x73, 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x3b, 0x64, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x78, 0x74, 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x3b, 0x64, 0x65, 0x63, 0x72, 0x79, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -382,24 +329,22 @@ func file_types_proto_rawDescGZIP() []byte { return file_types_proto_rawDescData } -var file_types_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_types_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_types_proto_goTypes = []interface{}{ (*CiphertextWithID)(nil), // 0: types.CiphertextWithID (*Query)(nil), // 1: types.Query (*DecryptionShareWithID)(nil), // 2: types.DecryptionShareWithID (*Observation)(nil), // 3: types.Observation (*ProcessedDecryptionRequest)(nil), // 4: types.ProcessedDecryptionRequest - (*Report)(nil), // 5: types.Report } var file_types_proto_depIdxs = []int32{ 0, // 0: types.Query.decryption_requests:type_name -> types.CiphertextWithID 2, // 1: types.Observation.decryption_shares:type_name -> types.DecryptionShareWithID - 4, // 2: types.Report.processedDecryptedRequests:type_name -> types.ProcessedDecryptionRequest - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_types_proto_init() } @@ -468,18 +413,6 @@ func file_types_proto_init() { return nil } } - file_types_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Report); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -487,7 +420,7 @@ func file_types_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_types_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/go/ocr2/decryptionplugin/types.proto b/go/ocr2plus/decryptionplugin/types.proto similarity index 84% rename from go/ocr2/decryptionplugin/types.proto rename to go/ocr2plus/decryptionplugin/types.proto index 8968692..587f88f 100644 --- a/go/ocr2/decryptionplugin/types.proto +++ b/go/ocr2plus/decryptionplugin/types.proto @@ -24,8 +24,4 @@ message Observation { message ProcessedDecryptionRequest { bytes ciphertext_id = 1; bytes plaintext = 2; -} - -message Report { - repeated ProcessedDecryptionRequest processedDecryptedRequests = 1; } \ No newline at end of file