# deriveGroupKey

> **deriveGroupKey**(`signer`, `ref`, `options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`DerivedGroupKey`](/reference/filoz/keysmith/interfaces/derivedgroupkey/)\>

Defined in: [derive.ts:204](https://github.com/FilOzone/synapse-sdk/blob/ef6c62c2d5e01c004a5cdb1a12bfa58ab9ee1834/packages/keysmith/src/derive.ts#L204)

Sign for one group key and derive its key.

The signature is the root secret, and it never leaves this function: the
caller gets the group key and the public commitment, and has nothing
else to guard.

For a new group key this signs twice and compares, which catches a
non-deterministic signer before any data depends on it, at the cost of a second
wallet prompt. For an existing one, pass the commitment its dataset records
(`foc/kc`): it signs once, and the commitment catches the same faults. See
[DeriveGroupKeyOptions](/reference/filoz/keysmith/interfaces/derivegroupkeyoptions/).

With `options.password`, the key also depends on that password, so a
phished signature alone no longer yields it. Lose the password and the
group key is lost: nothing else can recover it. Only a recorded commitment
can tell a wrong password from a right one, so reopen a protected group key
with both `password` and `commitment`, and have the user confirm the
password when creating one: a typo there silently roots the group key under
the typo.

Only the owner's own wallet can sign: a key signed by any other wallet,
a session key included, is not the key the owner's wallet derives, and
nothing downstream could tell. Delegates receive a grant instead.

The result carries the group key descriptor, so an owner writes the same way
a delegate does — `writeTarget(descriptor, groupKey, group)` — with the group key
taken from what was actually signed.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `signer` | [`TypedDataSigner`](/reference/filoz/keysmith/interfaces/typeddatasigner/) |
| `ref` | [`GroupKeyRef`](/reference/filoz/keysmith/interfaces/groupkeyref/) |
| `options?` | [`DeriveGroupKeyOptions`](/reference/filoz/keysmith/interfaces/derivegroupkeyoptions/) |

## Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`DerivedGroupKey`](/reference/filoz/keysmith/interfaces/derivedgroupkey/)\>

## Throws

Before any signing, if `options.password` is empty or not well-formed
Unicode, or `options.commitment` is not a commitment in format v2. After signing,
if the signer is not deterministic, is not the owner, does not produce an ECDSA
signature, or derives a key that does not match `options.commitment` (with a
password, most often a wrong password).