For the complete documentation index, see llms.txt. This page is also available as Markdown.

atKey Reference

Learn how to create atKeys for your chosen platform

Flutter / Dart

Package Installation

The at_commons package contains common elements used in a number of Atsign's Flutter and Dart packages. This package needs to be included in the application in order to create atKeys.

First add the package to your project:

flutter pub add at_commons

Usage

See below for how to create the various types of atKeys.

Public atKey

To create a public atKey, first use the AtKey.public builder to configure it, then call .build to create it.

AtKey.public signature
static PublicKeyBuilder public(String key,
    {String? namespace, String sharedBy = ''})

The build method on PublicKeyBuilder takes no parameters.

Example

public:phone.wavi@alice

AtKey myPublicID = AtKey.public('phone', namespace: 'wavi', sharedBy: '@alice').build();

Self atKey

To create a self atkeyD, first use the AtKey.self builder to configure it, then call .build to create it.

The build method on SelfKeyBuilder takes no parameters.

Example

phone.wavi@alice

Shared atKey

To create a shared atKey, first use the AtKey.shared builder to configure it, then call .build to create it.

The build method on SharedKeyBuilder takes no parameters.

Example

@bob:phone.wavi@alice

Caching shared atKeys

To cache a shared atKey, you can do a cascade call on SharedKeyBuilder.cache.

API Docs

You can find the API reference for the entire package available on pub.

The AtKey class API reference is available here.

C

You can find all these examples also on our GitHub.

Introduction

There are three kinds of atKeys:

Public atKey holds public (and non-encrypted) data, available for any Atsign to get from you.

Self atKey holds self encrypted data, only available for your own Atsign to get.

Shared atKey holds encrypted data that is only decipherable by you and the intended recipient.

Every atKey has metadata, which is free for you to also control (to an extent). Not all metadata should be handled by the developer. Some metadata is managed by the SDK itself. Check out our documentation on metadata to find out which metadata is worth your time handling.

Before running any of the examples, be sure to include atkey.h

Public atKey

This is how you create a Public atKey.

First, create the atkey struct.

Next, call the atclient_atkey_create_public_key function.

Don't forget to call atclient_atkey_free at the end of the intended life-time of your atkey struct.

Example Application

Self atKey

This is how you create a Self atKey.

First, create the atclient_atkey struct

Next, call the atclient_atkey_create_self_key function.

Don't forget to call atclient_atkey_free at the end of the intended life-time of your atkey struct.

Example Application

Shared atKey

This is how you create a Shared atKey.

First, create the atclient_atkey struct.

Next, call the atclient_atkey_create_shared_key function.

Don't forget to call atclient_atkey_free at the end of the intended life-time of your atkey struct.

Example Application

Metadata

This is how you modify the metadata of any atKey. For the sake of this example, we will modify the metadata of a Shared atKey.

First, create your atKey as usual.

Next, let's create a pointer to the atKey's metadata. We can feel safe reading the atclient_atkey's inner metadata field because we have previously called atclient_atkey_init.

Call a atclient_atkey_metadata_set_* function. For the sake of this example, we will call atclient_atkey_metadata_set_ttl which sets the atKey's lifespan, specified in milliseconds.

We can check if that was set and is safe to read by using the atclient_atkey_metadata_is_ttl_initialized(metadata) function. It is important to check that ttl was initialized. If this function returns true, we can feel safe knowing that the the internal initialized bit was set to true previously and that we are not reading garbage data.

Example Application

x

Last updated