Go bindings for the Falcon post-quantum digital signature scheme. This implementation provides a CGo wrapper around the reference C implementation of Falcon.
The C implementation used in this project is sourced from the official Falcon reference implementation available at https://falcon-sign.info/impl/falcon.h.html.
- Full implementation of Falcon-512 and Falcon-1024
- Support for all signature formats (compressed, padded, constant-time)
- Thread-safe
- Comprehensive test suite and benchmarks
- CGo bindings for optimal performance
Requires:
- Go 1.19 or newer
- GCC or Clang
- Make
go get github.com/zhenfeizhang/falcon-go
package main
import (
"fmt"
"log"
"github.com/zhenfeizhang/falcon-go/falcon"
)
func main() {
// Generate a Falcon-512 key pair
keyPair, err := falcon.GenerateKeyPair(9) // Use 10 for Falcon-1024
if err != nil {
log.Fatal(err)
}
// Sign a message
message := []byte("Hello, Falcon!")
signature, err := falcon.Sign(message, keyPair.PrivateKey, falcon.SigCompressed)
if err != nil {
log.Fatal(err)
}
// Verify the signature
err = falcon.Verify(signature, message, keyPair.PublicKey, falcon.SigCompressed)
if err != nil {
log.Fatal(err)
}
fmt.Println("Signature verified successfully!")
}
func GenerateKeyPair(logN uint) (*KeyPair, error)
logN
: 9 for Falcon-512, 10 for Falcon-1024- Returns: Public and private key pair
func Sign(message, privateKey []byte, sigType int) ([]byte, error)
sigType
: One ofSigCompressed
,SigPadded
, orSigCT
- Returns: Signature bytes
func Verify(signature, message, publicKey []byte, sigType int) error
- Returns: nil if signature is valid, error otherwise
Performance measured on AMD Ryzen 9 7950X3D running Linux:
Operation | Falcon-512 | Falcon-1024 | ||||
---|---|---|---|---|---|---|
C(SHAKE) | Go(SHAKE) | Go(Keccak) | C (SHAKE) | Go(SHAKE) | Go(Keccak) | |
Sign Dynamic (µs) | 170.21 | 166.79 | 166.91 | 342.45 | 330.37 | 340.39 |
Sign Dynamic CT (µs) | 177.11 | 169.03 | 162.09 | 352.78 | 351.21 | 355.44 |
Sign Tree (µs) | 103.07 | - | - | 203.83 | - | - |
Sign Tree CT (µs) | 109.76 | - | - | 216.83 | - | - |
Verify (µs) | 14.85 | 15.03 | 14.54 | 30.50 | 31.04 | 31.24 |
Verify CT (µs) | 23.94 | 25.78 | 24.51 | 51.58 | 50.56 | 48.55 |
Notes:
- CT = Constant Time operations
- Sign Dynamic = Standard signing operation
- Sign Tree = Signing with expanded private key (Go wrapper coming soon)
- Security levels:
- Falcon-512: NIST Level 1
- Falcon-1024: NIST Level 5
Run the benchmarks yourself:
make bench_go # Run Go benchmarks
make bench_c # Run C benchmarks
This implementation:
- Uses the official Falcon reference implementation
- Supports constant-time operations via
SigCT
- Follows secure coding practices for cryptographic software
Contributions welcome! Please:
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Run tests:
make test
Run benchmarks:
make bench_go # Go benchmarks
make bench_c # C benchmarks
MIT License - see LICENSE for details.
The Falcon implementation is released under the MIT License by the Falcon Project.
- Falcon Project - For the reference implementation
- Thomas Pornin - Original Falcon implementation