Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Alternatively, look at the [Cloudflare Go](https://github.com/cloudflare/go/tree
[RFC-9496]: https://doi.org/10.17487/RFC9496
[RFC-9497]: https://doi.org/10.17487/RFC9497
[FIPS 202]: https://doi.org/10.6028/NIST.FIPS.202
[FIPS 204]: https://doi.org/10.6028/NIST.FIPS.204
[FIPS 205]: https://doi.org/10.6028/NIST.FIPS.205
[FIPS 186-5]: https://doi.org/10.6028/NIST.FIPS.186-5
[BLS12-381]: https://electriccoin.co/blog/new-snark-curve/
[ia.cr/2015/267]: https://ia.cr/2015/267
Expand Down Expand Up @@ -91,7 +93,8 @@ Alternatively, look at the [Cloudflare Go](https://github.com/cloudflare/go/tree
|:---:|

- [Dilithium](./sign/dilithium): modes 2, 3, 5 ([Dilithium](https://pq-crystals.org/dilithium/)).
- [ML-DSA](./sign/mldsa): modes 44, 65, 87 ([FIPS 204](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.204.pdf)).
- [ML-DSA](./sign/mldsa): modes 44, 65, 87 ([FIPS 204]).
- [SLH-DSA](./sign/slhdsa): twelve parameter sets, pure and pre-hash signing ([FIPS 205]).

### Zero-knowledge Proofs

Expand Down
25 changes: 25 additions & 0 deletions internal/test/test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package test

import (
"bytes"
"encoding"
"errors"
"fmt"
"strings"
Expand Down Expand Up @@ -58,3 +60,26 @@ func CheckPanic(f func()) error {
f()
return hasPanicked
}

func CheckMarshal(
t *testing.T,
x, y interface {
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
},
) {
t.Helper()

want, err := x.MarshalBinary()
CheckNoErr(t, err, fmt.Sprintf("cannot marshal %T = %v", x, x))

err = y.UnmarshalBinary(want)
CheckNoErr(t, err, fmt.Sprintf("cannot unmarshal %T from %x", y, want))

got, err := y.MarshalBinary()
CheckNoErr(t, err, fmt.Sprintf("cannot marshal %T = %v", y, y))

if !bytes.Equal(got, want) {
ReportError(t, got, want, x, y)
}
}
23 changes: 19 additions & 4 deletions sign/schemes/schemes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@
// Ed448
// Ed25519-Dilithium2
// Ed448-Dilithium3
// Dilithium
// ML-DSA
// SLH-DSA
package schemes

import (
"strings"

"github.com/cloudflare/circl/sign"
dilithium2 "github.com/cloudflare/circl/sign/dilithium/mode2"
dilithium3 "github.com/cloudflare/circl/sign/dilithium/mode3"
dilithium5 "github.com/cloudflare/circl/sign/dilithium/mode5"
"github.com/cloudflare/circl/sign/ed25519"
"github.com/cloudflare/circl/sign/ed448"
"github.com/cloudflare/circl/sign/eddilithium2"
"github.com/cloudflare/circl/sign/eddilithium3"

dilithium2 "github.com/cloudflare/circl/sign/dilithium/mode2"
dilithium3 "github.com/cloudflare/circl/sign/dilithium/mode3"
dilithium5 "github.com/cloudflare/circl/sign/dilithium/mode5"
"github.com/cloudflare/circl/sign/mldsa/mldsa44"
"github.com/cloudflare/circl/sign/mldsa/mldsa65"
"github.com/cloudflare/circl/sign/mldsa/mldsa87"
"github.com/cloudflare/circl/sign/slhdsa"
)

var allSchemes = [...]sign.Scheme{
Expand All @@ -36,6 +39,18 @@ var allSchemes = [...]sign.Scheme{
mldsa44.Scheme(),
mldsa65.Scheme(),
mldsa87.Scheme(),
slhdsa.SHA2_128s.Scheme(),
slhdsa.SHAKE_128s.Scheme(),
slhdsa.SHA2_128f.Scheme(),
slhdsa.SHAKE_128f.Scheme(),
slhdsa.SHA2_192s.Scheme(),
slhdsa.SHAKE_192s.Scheme(),
slhdsa.SHA2_192f.Scheme(),
slhdsa.SHAKE_192f.Scheme(),
slhdsa.SHA2_256s.Scheme(),
slhdsa.SHAKE_256s.Scheme(),
slhdsa.SHA2_256f.Scheme(),
slhdsa.SHAKE_256f.Scheme(),
}

var allSchemeNames map[string]sign.Scheme
Expand Down
12 changes: 12 additions & 0 deletions sign/schemes/schemes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ func Example() {
// ML-DSA-44
// ML-DSA-65
// ML-DSA-87
// SLH-DSA-SHA2-128s
// SLH-DSA-SHAKE-128s
// SLH-DSA-SHA2-128f
// SLH-DSA-SHAKE-128f
// SLH-DSA-SHA2-192s
// SLH-DSA-SHAKE-192s
// SLH-DSA-SHA2-192f
// SLH-DSA-SHAKE-192f
// SLH-DSA-SHA2-256s
// SLH-DSA-SHAKE-256s
// SLH-DSA-SHA2-256f
// SLH-DSA-SHAKE-256f
}

func BenchmarkGenerateKeyPair(b *testing.B) {
Expand Down
Loading