Noncopyable / moveonly `PrivateKey` API?
- Dominant language
- Assembly
- Stars
- 1.7k
- Forks
- 223
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 7
Description
### New API Proposal: Noncopyable PrivateKey
#### Motivation:
For the past six years I've been working with cryptography and Swift and I've been missing some kind of compiler help regarding my usage of private keys. Rust's powerful ownership model is most likely a strong reason why many crypto project chose Rust as a go to language. With Swift 5.9 we have noncopyable types, along `consume`/`borrow` which seem like a nice fit for swift-crypto!
What is Apple's thoughts on including a new API layer to each curve that ships with swift-crypto where the private keys are `~Copyable`? I imagine it would be a new namespace, similar to how `P256` and `SecureEnclave.P256` namespaces exists in parallell. It could be `Safe.P26.Signing.PrivateKey`, the corresponding PublicKey need not be `~Copyable`. An alternative would be to put the non copyable variant in `P256.Signing.Safe.PrivateKey` or let the type itself be prefix with "Safe", i.e. `P256.Signing.SafePrivateKey`.
#### Importance:
> Does this API unlock entirely new use-case
YES, it unlocks an entire new use-case for the developer writing the code! Just how `async`/`await` offers an entire new way and safer way to write concurrency code in Swift, `~Copyable` offers the users of swift-crypto - and CryptoKit - an entire new and safer way of using private keys!
Contributor guide
Research direction
Start by reading the proposed API alternatives and the Swift 5.9 noncopyable, consume, and borrow concepts cited in the issue. Done would require an agreed API shape for noncopyable private keys and a concrete scope for the curves and namespaces affected; the issue names no files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- cryptography, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100