# Registry

> [!NOTE]
> This page describes an area that undergoes a major redesign at the moment. The status depends on the programming language used.

Starting with the basics, here is an informal definition of Registry:

> [!IMPORTANT]
> **Key Term:** **Registry** is a global entity in Tink that knows how to generate new keys and primitives.

But:

> [!WARNING]
> **Warning:** This class is intended to be used only by internal interfaces. You should NOT call its methods directly, but instead access them through higher level APIs like KeysetHandle.

> [!WARNING]
> **Warning:** This class is going to be removed.

That being said, it may be useful to understand this class in order to work
with Tink efficiently for the time being.

What happens when you call `getPrimitive()` on a keyset handle? It forwards your
call to the Registry^[1](https://developers.google.com/tink/design/registry#fn1)^, which contains objects with concrete methods to create
keys and [*primitives*](https://developers.google.com/tink/design/primitives_and_interfaces), such as an
AesGcm key or a ChunkedMac instance. The Registry's task is to forward the call
to the correct object. This only works if the object is registered, which is why
**it's important to always register the primitives you are going to use**.

## But what if I use a library that already registered the primitives I need?

That's precisely the problem. And one of the reasons Registry is being removed.
Because in this case your code works only until the library authors decide to
not register that primitive anymore. At this point your code breaks, and the
reason is non-obvious and confusing. So **always register what you
use**. For example, if you intend you use MAC in your Java code, you should do
the following in the setup phase:

```java
MacConfig.register()
```

This code ensures that all the necessary objects are registered in the
necessary places for you to use the MAC primitive.

There is one more side to this problem. Some of your dependencies may register
things you actually don't need and would prefer to not depend on. This is
another reason to remove the global Registry.

*** ** * ** ***

1. to the global singleton instance of the class Registry, to be precise. We use the name "Registry" for both, the class and the singleton, interchangeably. [↩](https://developers.google.com/tink/design/registry#fnref1)