# CryptoKeyBinding

`import { CryptoKeyBinding } from "destack:crypto/binding";`

Key binding family.

```ds title="CryptoKeyBinding"
export interface CryptoKeyBinding {
    generateSecretKey(store: CryptoStoreHandle, shape: &'a readonly CryptoKeyShape, policy: &'b readonly CryptoKeyPolicy): Result<CryptoKeyHandle, HostError>;
    generateKeyPair(store: CryptoStoreHandle, shape: &'a readonly CryptoKeyShape, policy: &'b readonly CryptoKeyPolicy): Result<CryptoKeyPair, HostError>;
    importKey(store: CryptoStoreHandle, request: &'b readonly CryptoKeyImport<'a>, bytes: &'c readonly [uint8]): Result<CryptoKeyHandle, HostError>;
    exportPublicKey(key: CryptoKeyHandle, format: CryptoKeyFormat): Result<uint8[], HostError>;
    exportPrivateKey(key: CryptoKeyHandle, request: &'b readonly CryptoPrivateKeyExport<'a>): Result<uint8[], HostError>;
    exportSecretKey(key: CryptoKeyHandle, format: CryptoKeyFormat): Result<uint8[], HostError>;
    describeKey(key: CryptoKeyHandle): Result<CryptoKeyDescriptor, HostError>;
    signWithKey(key: CryptoKeyHandle, parameters: &'a readonly CryptoSignatureParameters, payload: &'b readonly [uint8]): Result<uint8[], HostError>;
    verifyWithKey(key: CryptoKeyHandle, parameters: &'a readonly CryptoSignatureParameters, payload: &'b readonly [uint8], signature: &'c readonly [uint8]): Result<boolean, HostError>;
    encryptWithKey(key: CryptoKeyHandle, parameters: &'b readonly CryptoAsymmetricEncryptionParameters<'a>, payload: &'c readonly [uint8]): Result<uint8[], HostError>;
    decryptWithKey(key: CryptoKeyHandle, parameters: &'b readonly CryptoAsymmetricEncryptionParameters<'a>, payload: &'c readonly [uint8]): Result<uint8[], HostError>;
    wrapKey(wrappingKey: CryptoKeyHandle, keyToWrap: CryptoKeyHandle, format: CryptoKeyFormat, parameters: &'b readonly CryptoKeyWrapParameters<'a>): Result<uint8[], HostError>;
    unwrapKey(store: CryptoStoreHandle, wrappingKey: CryptoKeyHandle, wrappedKey: &'a readonly [uint8], parameters: &'c readonly CryptoKeyWrapParameters<'b>, importRequest: &'e readonly CryptoKeyImport<'d>): Result<CryptoKeyHandle, HostError>;
    deleteKey(key: CryptoKeyHandle): Result<void, HostError>;
}
```

[language/library/src/crypto/binding/key.ds:193:376](https://github.com/destack-sh/destack/blob/main/language/library/src/crypto/binding/key.ds#L193-L376)

## Members

### `generateSecretKey(store: CryptoStoreHandle, shape: &'a readonly CryptoKeyShape, policy: &'b readonly CryptoKeyPolicy): Result<CryptoKeyHandle, HostError>`

Generate one secret key.

### `generateKeyPair(store: CryptoStoreHandle, shape: &'a readonly CryptoKeyShape, policy: &'b readonly CryptoKeyPolicy): Result<CryptoKeyPair, HostError>`

Generate one asymmetric key pair.

### `importKey(store: CryptoStoreHandle, request: &'b readonly CryptoKeyImport<'a>, bytes: &'c readonly [uint8]): Result<CryptoKeyHandle, HostError>`

Import one key.

### `exportPublicKey(key: CryptoKeyHandle, format: CryptoKeyFormat): Result<uint8[], HostError>`

Export one public key.

### `exportPrivateKey(key: CryptoKeyHandle, request: &'b readonly CryptoPrivateKeyExport<'a>): Result<uint8[], HostError>`

Export one private key.

### `exportSecretKey(key: CryptoKeyHandle, format: CryptoKeyFormat): Result<uint8[], HostError>`

Export one secret key.

### `describeKey(key: CryptoKeyHandle): Result<CryptoKeyDescriptor, HostError>`

Describe one key.

### `signWithKey(key: CryptoKeyHandle, parameters: &'a readonly CryptoSignatureParameters, payload: &'b readonly [uint8]): Result<uint8[], HostError>`

Sign one payload.

### `verifyWithKey(key: CryptoKeyHandle, parameters: &'a readonly CryptoSignatureParameters, payload: &'b readonly [uint8], signature: &'c readonly [uint8]): Result<boolean, HostError>`

Verify one signature.

### `encryptWithKey(key: CryptoKeyHandle, parameters: &'b readonly CryptoAsymmetricEncryptionParameters<'a>, payload: &'c readonly [uint8]): Result<uint8[], HostError>`

Encrypt one payload with one asymmetric key.

### `decryptWithKey(key: CryptoKeyHandle, parameters: &'b readonly CryptoAsymmetricEncryptionParameters<'a>, payload: &'c readonly [uint8]): Result<uint8[], HostError>`

Decrypt one payload with one asymmetric key.

### `wrapKey(wrappingKey: CryptoKeyHandle, keyToWrap: CryptoKeyHandle, format: CryptoKeyFormat, parameters: &'b readonly CryptoKeyWrapParameters<'a>): Result<uint8[], HostError>`

Wrap one key.

### `unwrapKey(store: CryptoStoreHandle, wrappingKey: CryptoKeyHandle, wrappedKey: &'a readonly [uint8], parameters: &'c readonly CryptoKeyWrapParameters<'b>, importRequest: &'e readonly CryptoKeyImport<'d>): Result<CryptoKeyHandle, HostError>`

Unwrap one key.

### `deleteKey(key: CryptoKeyHandle): Result<void, HostError>`

Delete one key.
