<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "P256K",
  "identifier" : "/documentation/P256K/CopyableBytes",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "P256K"
    ],
    "preciseIdentifier" : "s:5P256K13CopyableBytesP"
  },
  "title" : "CopyableBytes"
}
-->

# CopyableBytes

A `ContiguousBytes` type that permits copying its byte material out of its
storage, opting into the `byteArray` convenience accessor.

```
protocol CopyableBytes
```

## Overview

The marker is the compile-time gate on `byteArray`:
the accessor is declared only for `Self: CopyableBytes`, so reading it on a
non-conforming type fails to build. `SecureBytes` deliberately does not conform — it holds
secret material (private keys, secret nonces, shared secrets) in storage
that `memset_s`-zeroes on deallocation, and materializing a fresh `[UInt8]`
copy would outlive the `withUnsafeBytes` scope and be freed without
zeroing. Secret material reaches libsecp256k1 through borrowed
`withUnsafeBytes` / `withUnsafeMutableBytes` pointers instead, and C
outputs land directly in `SecureBytes` storage via
`init(unsafeUninitializedCapacity:initializingWith:)`.

Conformances ship for the standard byte containers (`Foundation.Data`,
`Swift.Array`, `Swift.ArraySlice`) and for the library types whose public
API already exposes their byte material — digests, signatures, and public
nonces — plus [`SharedSecret`](/documentation/P256K/SharedSecret), whose `withUnsafeBytes` is the documented
extraction path ([`HashDigest`](/documentation/P256K/HashDigest), [`P256K.Signing.ECDSASignature`](/documentation/P256K/P256K/Signing/ECDSASignature),
[`P256K.Recovery.ECDSASignature`](/documentation/P256K/P256K/Recovery/ECDSASignature), [`P256K.Schnorr.SchnorrSignature`](/documentation/P256K/P256K/Schnorr/SchnorrSignature),
[`P256K.Schnorr.Nonce`](/documentation/P256K/P256K/Schnorr/Nonce), [`P256K.MuSig.Nonce`](/documentation/P256K/P256K/MuSig/Nonce),
[`P256K.MuSig.AggregateSignature`](/documentation/P256K/P256K/MuSig/AggregateSignature), [`P256K.Schnorr.PartialSignature`](/documentation/P256K/P256K/Schnorr/PartialSignature)).
Callers may conform their own `ContiguousBytes` types.