https://github.com/primefactor-io/xchacha20-poly1305
100% RFC compliant implementations of ChaCha20-Poly1305 and XChaCha20-Poly1305
https://github.com/primefactor-io/xchacha20-poly1305
chacha20 chacha20-poly1305 cryptography cryptography-algorithms poly1305
Last synced: 12 days ago
JSON representation
100% RFC compliant implementations of ChaCha20-Poly1305 and XChaCha20-Poly1305
- Host: GitHub
- URL: https://github.com/primefactor-io/xchacha20-poly1305
- Owner: primefactor-io
- License: apache-2.0
- Created: 2024-09-03T10:41:41.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-04-29T07:15:41.000Z (29 days ago)
- Last Synced: 2025-05-11T08:11:08.612Z (16 days ago)
- Topics: chacha20, chacha20-poly1305, cryptography, cryptography-algorithms, poly1305
- Language: Go
- Homepage:
- Size: 68.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XChaCha20-Poly1305
A fully [RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439) and [RFC draft-irtf-cfrg-xchacha-03](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha-03) compliant implementation of the [XChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) AEAD algorithm.
[XChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) combines the [ChaCha20](https://muens.io/chacha20) stream cipher with the [Poly1305](https://muens.io/poly1305) message authentication code (MAC).
Both components and their extensions were implemented as self-contained units, so you can e.g. use [ChaCha20](https://muens.io/chacha20) without [Poly1305](https://muens.io/poly1305) if you want to.
Looking into the tests you'll find full coverage of all RFC test vectors which makes this implementation compliant with both RFCs.
**Note:** While you could in theory use these implementations as drop-in replacements, you probably shouldn't. The code was written for educational purposes and is therefore neither optimized (e.g. to combat timing attacks), nor audited.
## Setup
1. `git clone `
2. `asdf install`
3. `go test -race ./...`
4. `go run ./cmd/cli/main.go`## Primitives
### Stream Cipher
The [ChaCha20](./pkg/chacha20/) stream cipher and its variant [XChaCha20](./pkg/xchacha20/) (with [HChaCha20](./pkg/xchacha20/)).
### Message Authenticate Code
The [Poly1305](./pkg/poly1305/) message authentication code (MAC).
### Authenticated Encryption with Associated Data
The [ChaCha20-Poly1305](./pkg/chacha20poly1305/) AEAD construction alongside its variant [XChaCha20-Poly1305](./pkg/xchacha20poly1305/).
## Useful Commands
```sh
go run
go build []go test [][/...] [-v] [-cover] [-race] [-parallel ]
go test -bench=. [] [-count ] [-benchmem] [-benchtime 2s] [-memprofile ]go test -coverprofile []
go tool cover -html
go tool cover -funcgo doc []
go fmt []
go vet []go mod init []
go mod tidy
go mod vendor
go mod downloadgo work init [ [] [...]]
go work use [ [] [...]]
go work sync# Adjust dependencies in `go.mod`.
go get [@]# Build and install commands.
go install [@]go list -m [all]
```## Useful Resources
- [Go - Learn](https://go.dev/learn)
- [Go - Documentation](https://go.dev/doc)
- [Go - A Tour of Go](https://go.dev/tour)
- [Go - Effective Go](https://go.dev/doc/effective_go)
- [Go - Playground](https://go.dev/play)
- [Go by Example](https://gobyexample.com)
- [100 Go Mistakes and How to Avoid Them](https://100go.co)