Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

feat: Update Tink version, protobuf type #3413

Merged
merged 1 commit into from
Oct 25, 2022

Conversation

DRK3
Copy link
Contributor

@DRK3 DRK3 commented Oct 21, 2022

Updated the Tink version and our methods to use the newer protobuf type that it uses.

Reason for this change: the existing version of Tink makes use of a very large int in one particular place in the code, and this very large int prevents the gomobile tool from successfully generating Android bindings. This meant that aries-framework-go packages that used Tink could not be used in any code that you may want to generate Android bindings for. The updated version of Tink does not have that check anymore, which resolves the issue.

Due to a circular dependency between the main module and component/storage/edv (and the fact that both of them require Tink), there are some module/build issues with this commit. This will be resolved in the next commit.

Signed-off-by: Derek Trider [email protected]

@DRK3 DRK3 force-pushed the UpdateTinkVersion branch 12 times, most recently from c346ec0 to 0f76497 Compare October 25, 2022 01:38
@@ -278,14 +278,6 @@ func TestPublicKeyDataWithInvalidInput(t *testing.T) {

_, err = pkm.PublicKeyData(serializedKey)
require.Error(t, err, "expect an error when input is a modified serialized key")

// nil
_, err = pkm.PublicKeyData(nil)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer returns an error with the updated Tink version (pub key bytes in returned struct are just empty now)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove the whole test function since the main test is not applicable anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Baha-sk You mean remove TestPublicKeyDataWithInvalidInput? Are the other test cases in it not applicable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the whole test function's purpose was to test empty/nil cases, it seems Tink now panics on purpose in these cases... you can probably recover the panic here and make sure it does actually panic instead of removing these calls? that would be a good test case.

Copy link
Contributor Author

@DRK3 DRK3 Oct 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some other test cases in this function still that work the same as before (above the code I removed, in this same function). For these two particular test cases I removed, they just don't return an error anymore (i.e. are not an invalid test case anymore)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point re: catching the panic - I'll update the other places in this PR where I removed those tests that panic to catch it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some other test cases in this function still that work the same as before (above the code I removed, in this same function). For these two particular test cases I removed, they just don't return an error anymore (i.e. are not an invalid test case anymore)

I think you can use require.Panics() in this case, without having to set a value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two cases don't panic - they're not an error or panic

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ok.. I see.. no issues then.. it looks good.

require.Errorf(t, err, "expect an error when input is nil")

// empty slice
_, err = pkm.PublicKeyData([]byte{})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer returns an error with the updated Tink version (pub key bytes in returned struct are just empty now)

@@ -38,9 +38,6 @@ func Test_ExtractPrivKey(t *testing.T) {
require.EqualError(t, err, "extractPrivKey: can't extract unsupported private key 'type.googleapis.com/"+
"google.crypto.tink.AesGcmKey'")

_, err = extractPrivKey(&keyset.Handle{})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing an empty keyset handle causes Tink to do a panic now instead of throwing an error

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this is fine then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to check for the panic now using require.PanicsWithValue

@DRK3 DRK3 marked this pull request as ready for review October 25, 2022 14:26
@DRK3 DRK3 requested a review from baha-ai October 25, 2022 14:26
@Moopli
Copy link
Contributor

Moopli commented Oct 25, 2022

Why do we need a second PR for the second commit?
One PR with two commits should allow tests to pass once the PR is merged.

@DRK3 DRK3 force-pushed the UpdateTinkVersion branch 2 times, most recently from 4a9fae0 to 33c1634 Compare October 25, 2022 14:56
@DRK3
Copy link
Contributor Author

DRK3 commented Oct 25, 2022

@Moopli I don't have a valid commit I can use with go get until this is merged into the main branch of hyperledger/aries-framework-go. Unless you're talking about manually editing the go.mod file ahead of time with what go get would have done? In which case, I'm not sure how I would generate the date string (the entry would look something like v0.1.8-????????-33c163460841, and I'm sure the go.sum and other go modules in Aries would need to be updated anyway, and I think we need the go tools + the commit merged in for that). Let me know if you mean something else!

@baha-ai
Copy link
Contributor

baha-ai commented Oct 25, 2022

One PR with two commits should allow tests to pass once the PR is merged.

you can push a second commit within the same PR where you can use the commit hash of the first commit in go.mod of the second commit, @Moopli is right

n which case, I'm not sure how I would generate the date string (the entry would look something like v0.1.8-????????-33c163460841, and I'm sure the go.sum and other go modules in Aries would need to be updated anyway, and I think we need the go tools + the commit merged in for that). Let me know if you mean something else!

just replace the whole commit version with the sha hash of the first commit in go.mod then do go mod tidy, it will automatically update go.mod and go.sum for you with the right version

@baha-ai
Copy link
Contributor

baha-ai commented Oct 25, 2022

never mind my previous comment, git needs to query GH to fetch the commit, and it's not there till it's merged

Updated the Tink version and our methods to use the newer protobuf type that it uses.

Reason for this change: the existing version of Tink makes use of a very large int in one particular place in the code, and this very large int prevents the gomobile tool from successfully generating Android bindings. This meant that aries-framework-go packages that used Tink could not be used in any code that you may want to generate Android bindings for. The updated version of Tink does not have that check anymore, which resolves the issue.

Due to a circular dependency between the main module and component/storage/edv (and the fact that both of them require Tink), there are some module/build issues with this commit. This will be resolved in the next commit.

Signed-off-by: Derek Trider <[email protected]>
@DRK3 DRK3 force-pushed the UpdateTinkVersion branch from 33c1634 to 253124a Compare October 25, 2022 16:36
@fqutishat fqutishat merged commit b807371 into hyperledger-archives:main Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants