Protocol
CopyableBytes
A ContiguousBytes type that permits copying its byte material out of its storage, opting into the byteArray convenience accessor.
protocol CopyableBytes
Mentioned In
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, whose withUnsafeBytes is the documented extraction path (HashDigest, P256K.Signing.ECDSASignature, P256K.Recovery.ECDSASignature, P256K.Schnorr.SchnorrSignature, P256K.Schnorr.Nonce, P256K.MuSig.Nonce, P256K.MuSig.AggregateSignature, P256K.Schnorr.PartialSignature). Callers may conform their own ContiguousBytes types.
Relationships
Conforming Types