keyForEnvelope
keyForEnvelope(
node,envelopeMetadata,holder?):Uint8Array
Defined in: derive.ts:589
Derive a piece’s key from whichever node the caller holds.
A group key holder walks the piece’s whole group path. A group holder walks the rest of the path below its own group — which works only if its group is the piece’s group or an ancestor of it. A piece holder already has the key, and gets it back only for the piece whose salt it names.
Takes the metadata as FEE returns it (info.appMetadata),
unvalidated, and checks every field before using it (see readPieceMetadata).
Pass the grant that delivered the key as holding where you have it: then the
piece’s owner and group key are checked against the grant too, so a key from the
wrong group key fails here with a clear reason rather than later inside FEE. A descriptor’s v follows
holdingOf: absent, or exactly 2.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
node |
Uint8Array |
undefined |
envelopeMetadata |
PieceMetadataV2 | Readonly<Record<string, unknown>> | undefined |
undefined |
holder? |
GrantDescriptor | Holding |
'groupKey' |
Returns
Section titled “Returns”Throws
Section titled “Throws”If the piece is not format 2, belongs to another owner or group key than the grant, the held group does not contain the piece’s group, or the held piece is a different piece.