From 5c875b48c1187b88ec7f8db4fae8e6a4a9ae4c2a Mon Sep 17 00:00:00 2001 From: Warren He Date: Fri, 30 Aug 2024 16:07:37 -0700 Subject: [PATCH] api: include Oasis-style encryption envelope info --- api/spec/v1.yaml | 6 ++++++ storage/client/client.go | 12 ++++++++++++ storage/client/queries/queries.go | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/api/spec/v1.yaml b/api/spec/v1.yaml index 7b3e27b03..5ff9e7518 100644 --- a/api/spec/v1.yaml +++ b/api/spec/v1.yaml @@ -2855,6 +2855,12 @@ components: type: integer format: int32 description: The total byte size of the transaction. + oasis_encryption_envelope: + allOf: [$ref: '#/components/schemas/RuntimeTransactionEncryptionEnvelope'] + description: | + The data relevant to the Oasis-style encrypted transaction. + Note: The term "envelope" in this context refers to the [Oasis-style encryption envelopes](https://github.com/oasisprotocol/oasis-sdk/blob/c36a7ee194abf4ca28fdac0edbefe3843b39bf69/runtime-sdk/src/types/callformat.rs) + which differ slightly from [digital envelopes](hhttps://en.wikipedia.org/wiki/Hybrid_cryptosystem#Envelope_encryption). method: type: string description: | diff --git a/storage/client/client.go b/storage/client/client.go index 5ab91dc2b..bda8d9d95 100644 --- a/storage/client/client.go +++ b/storage/client/client.go @@ -1480,6 +1480,8 @@ func (c *StorageClient) RuntimeTransactions(ctx context.Context, p apiTypes.GetR t := RuntimeTransaction{ Error: &TxError{}, } + var oasisEncryptionEnvelope RuntimeTransactionEncryptionEnvelope + var oasisEncryptionEnvelopeFormat *common.CallFormat var evmEncryptionEnvelope RuntimeTransactionEncryptionEnvelope var evmEncryptionEnvelopeFormat *common.CallFormat var sender0PreimageContextIdentifier *string @@ -1509,6 +1511,12 @@ func (c *StorageClient) RuntimeTransactions(ctx context.Context, p apiTypes.GetR &t.GasUsed, &t.ChargedFee, &t.Size, + &oasisEncryptionEnvelopeFormat, + &oasisEncryptionEnvelope.PublicKey, + &oasisEncryptionEnvelope.DataNonce, + &oasisEncryptionEnvelope.Data, + &oasisEncryptionEnvelope.ResultNonce, + &oasisEncryptionEnvelope.Result, &t.Method, &t.Body, &t.To, @@ -1547,6 +1555,10 @@ func (c *StorageClient) RuntimeTransactions(ctx context.Context, p apiTypes.GetR t.Error.Code = *errorCode } } + if oasisEncryptionEnvelopeFormat != nil { // a rudimentary check to determine if the tx was encrypted + oasisEncryptionEnvelope.Format = *oasisEncryptionEnvelopeFormat + t.OasisEncryptionEnvelope = &oasisEncryptionEnvelope + } if evmEncryptionEnvelopeFormat != nil { // a rudimentary check to determine if the tx was encrypted evmEncryptionEnvelope.Format = *evmEncryptionEnvelopeFormat t.EncryptionEnvelope = &evmEncryptionEnvelope diff --git a/storage/client/queries/queries.go b/storage/client/queries/queries.go index c3cd12460..47f0d2ab8 100644 --- a/storage/client/queries/queries.go +++ b/storage/client/queries/queries.go @@ -447,6 +447,12 @@ const ( ELSE COALESCE(FLOOR(txs.fee / NULLIF(txs.gas_limit, 0)) * txs.gas_used, 0) -- charged_fee=gas_price * gas_used for EVM txs END AS charged_fee, txs.size, + txs.oasis_encrypted_format, + txs.oasis_encrypted_public_key, + txs.oasis_encrypted_data_nonce, + txs.oasis_encrypted_data_data, + txs.oasis_encrypted_result_nonce, + txs.oasis_encrypted_result_data, txs.method, txs.body, txs.to,