tink icon indicating copy to clipboard operation
tink copied to clipboard

Tink javascript-typescript missing the getPublicKeysetHandle function

Open Generic35 opened this issue 3 years ago • 1 comments

Is your feature request related to a problem?

Not sure if it's a missing feature or a bug.

The javascript/typescript version of tink, for the Hybrid encryption primitive, does not have a getPublicKeysetHandle function available.

The tink documentation suggests to refer to the Java documentation and example. I am following this Java, Hybrid encryption example, I found all the corresponding methods in the Javascript/typescript tink library, except the getPublicKeysetHandle of this example.

Is there an equivalent way to obtain the public keyset handle in the javascript/typescript tink library?

Describe the solution you'd like

I need a way to obtain the public keyset from the private keyset handle, to then get the hybrid encryption primitive like in this example: https://github.com/google/tink/blob/master/docs/JAVA-HOWTO.md#hybrid-encryption

For example, if i try to use it as so:

 tink.hybrid.register(); 
 privateKeysetHandle = await tink.generateNewKeysetHandle(
          tink.hybrid.eciesP256HkdfHmacSha256Aes128GcmKeyTemplate()
        );
 const primitiveSet = await privateKeysetHandle.getPrimitive<tink.hybrid.HybridEncrypt>(
          tink.hybrid.HybridEncrypt
        );

I get this error: >>> error encrypting/decrypting SecurityException: Requested primitive type which is not supported by this key manager.

Looking at the java example I mentioned in introduction, getPrimitive for encryption is expecting the public key, and is obtained from the private key. Looking at the code from where the exception is thrown also rhymes with this.

Finally, the same get primitive call for Decrypting works just fine, so does not throw an error.

But I do need the public key, for encrypting.

Generic35 avatar Apr 14 '21 14:04 Generic35

Hi, I was wondering if there is any update on this issue and or if there is a alternative meanwhile?

GuillaumeVachon avatar Apr 20 '21 14:04 GuillaumeVachon

We intent to Remove Tink for JavaScript/TypeScript, see https://github.com/google/tink/issues/689.

So I will close this.

juergw avatar May 17 '23 14:05 juergw