Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kangaroo12 draft -10 #431

Merged
merged 1 commit into from
May 3, 2023
Merged

Kangaroo12 draft -10 #431

merged 1 commit into from
May 3, 2023

Conversation

bwesterb
Copy link
Member

@bwesterb bwesterb commented Apr 18, 2023

On M2 Pro:

goos: darwin
goarch: arm64
pkg: github.com/cloudflare/circl/xof/k12
BenchmarkK12_100B-12    	 5237684	       225.1 ns/op	 444.26 MB/s
BenchmarkK12_10K-12     	  106761	     11281 ns/op	 886.45 MB/s
BenchmarkK12_100K-12    	   26758	     44659 ns/op	2239.19 MB/s
BenchmarkK12_1M-12      	    3723	    324025 ns/op	3086.18 MB/s
BenchmarkK12_10M-12     	     384	   3107586 ns/op	3217.93 MB/s
PASS
ok  	github.com/cloudflare/circl/xof/k12	7.254s

For comparison:

goos: darwin
goarch: arm64
pkg: github.com/cloudflare/circl/internal/sha3
BenchmarkPermutationFunctionTurbo-12    	 7788294	       145.3 ns/op	1376.86 MB/s
BenchmarkTurboShake128_1MiB-12          	    1159	   1027718 ns/op	1020.29 MB/s
BenchmarkTurboShake256_1MiB-12          	     945	   1255741 ns/op	 835.03 MB/s
PASS
ok  	github.com/cloudflare/circl/internal/sha3	4.068s

@bwesterb
Copy link
Member Author

bwesterb commented Apr 19, 2023

Without overhead, with the current code that uses the slow scalar keccak, we should be able to reach:

>>> 42 * 1024 / (145e-9 + 128*72e-9) / 1e6
4594.380942207029

Using pprof, I see 1/3 of the time is spent in writeX2/LittleEndian.Uint64: interleaving and XORing the data into the buffers isn't free.

@bwesterb bwesterb force-pushed the bas/k12 branch 4 times, most recently from cf87fe1 to f3bfa42 Compare April 19, 2023 11:56
@bwesterb
Copy link
Member Author

goos: darwin
goarch: amd64
pkg: github.com/cloudflare/circl/xof/k12
cpu: Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
BenchmarkK12_100B-8   	 3521196	       348.1 ns/op	 287.26 MB/s
BenchmarkK12_10K-8    	   63129	     18746 ns/op	 533.45 MB/s
BenchmarkK12_100K-8   	   13159	     90725 ns/op	1102.23 MB/s
BenchmarkK12_1M-8     	    2001	    591119 ns/op	1691.71 MB/s
BenchmarkK12_10M-8    	     206	   5876949 ns/op	1701.56 MB/s
PASS
ok  	github.com/cloudflare/circl/xof/k12	8.344s

Theoretical max is 2230 MB/s. Interleaving and XORing is still expensive, it's just less so compared to the speed of Keccak here.

@bwesterb bwesterb changed the title [WIP] Kangaroo12 draft -10 Kangaroo12 draft -10 Apr 19, 2023
internal/sha3/sha3.go Outdated Show resolved Hide resolved
xof/k12/k12.go Outdated Show resolved Hide resolved
xof/k12/k12.go Show resolved Hide resolved
s.offset = len(p)
}

return written, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

written is always len(p), and is never modified based on actual Write operations.
Also, let's propagate errors from Read/Write functions above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

written is always len(p)

True, but p is modified, so we need to store len(p).

Also, let's propagate errors from Read/Write functions above.

Read/Write don't error.

xof/k12/k12.go Show resolved Hide resolved
Comment on lines +342 to +348
for len(remainingBuf) > 0 {
h := sha3.NewTurboShake128(0x0B)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reuse the hashfn?

Suggested change
for len(remainingBuf) > 0 {
h := sha3.NewTurboShake128(0x0B)
h := sha3.NewTurboShake128(0x0B)
for len(remainingBuf) > 0 {
h.Reset()

xof/k12/k12.go Outdated Show resolved Hide resolved
xof/k12/k12.go Show resolved Hide resolved
xof/k12/k12_test.go Show resolved Hide resolved
xof/k12/k12_test.go Outdated Show resolved Hide resolved
@armfazh armfazh requested a review from cjpatton May 1, 2023 23:38
@armfazh armfazh added the new feature New functionality or module label May 1, 2023
@bwesterb
Copy link
Member Author

bwesterb commented May 2, 2023

@armfazh I addressed all your comments. Please have another look.

@bwesterb bwesterb merged commit caa4d7b into main May 3, 2023
@bwesterb bwesterb deleted the bas/k12 branch May 3, 2023 21:26
jooola referenced this pull request in hetznercloud/terraform-provider-hcloud Jan 9, 2024
…834)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [github.com/cloudflare/circl](https://github.com/cloudflare/circl) |
`v1.3.3` -> `v1.3.7` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fcloudflare%2fcircl/v1.3.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fcloudflare%2fcircl/v1.3.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fcloudflare%2fcircl/v1.3.3/v1.3.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fcloudflare%2fcircl/v1.3.3/v1.3.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

### GitHub Vulnerability Alerts

####
[GHSA-9763-4f94-gfch](https://github.com/cloudflare/circl/security/advisories/GHSA-9763-4f94-gfch)

### Impact
On some platforms, when an attacker can time decapsulation of Kyber on
forged cipher texts, they could possibly learn (parts of) the secret
key.

Does not apply to ephemeral usage, such as when used in the regular way
in TLS.

### Patches
Patched in 1.3.7.

### References
- [kyberslash.cr.yp.to](https://kyberslash.cr.yp.to/)

---

### Release Notes

<details>
<summary>cloudflare/circl (github.com/cloudflare/circl)</summary>

###
[`v1.3.7`](https://github.com/cloudflare/circl/releases/tag/v1.3.7):
CIRCL v1.3.7

[Compare
Source](https://github.com/cloudflare/circl/compare/v1.3.6...v1.3.7)

#### CIRCL v1.3.7

##### What's Changed

- build(deps): bump golang.org/x/crypto from
0.3.1-0.20221117191849-2c476679df9a to 0.17.0 by
[@&#8203;dependabot](https://github.com/dependabot) in
[https://github.com/cloudflare/circl/pull/467](https://github.com/cloudflare/circl/pull/467)
- kyber: remove division by q in ciphertext compression by
[@&#8203;bwesterb](https://github.com/bwesterb) in
[https://github.com/cloudflare/circl/pull/468](https://github.com/cloudflare/circl/pull/468)
- Releasing CIRCL v1.3.7 by
[@&#8203;armfazh](https://github.com/armfazh) in
[https://github.com/cloudflare/circl/pull/469](https://github.com/cloudflare/circl/pull/469)

##### New Contributors

- [@&#8203;dependabot](https://github.com/dependabot) made their first
contribution in
[https://github.com/cloudflare/circl/pull/467](https://github.com/cloudflare/circl/pull/467)

**Full Changelog**:
cloudflare/circl@v1.3.6...v1.3.7

###
[`v1.3.6`](https://github.com/cloudflare/circl/releases/tag/v1.3.6):
CIRCL v1.3.6

[Compare
Source](https://github.com/cloudflare/circl/compare/v1.3.5...v1.3.6)

#### CIRCL v1.3.6

##### What's Changed

- internal: add TurboShake{128,256} by
[@&#8203;bwesterb](https://github.com/bwesterb) in
[https://github.com/cloudflare/circl/pull/430](https://github.com/cloudflare/circl/pull/430)
- Kangaroo12 draft -10 by
[@&#8203;bwesterb](https://github.com/bwesterb) in
[https://github.com/cloudflare/circl/pull/431](https://github.com/cloudflare/circl/pull/431)
- Add K12 as XOF by [@&#8203;bwesterb](https://github.com/bwesterb) in
[https://github.com/cloudflare/circl/pull/437](https://github.com/cloudflare/circl/pull/437)
- xof/k12: Fix a typo in the package documentation by
[@&#8203;cjpatton](https://github.com/cjpatton) in
[https://github.com/cloudflare/circl/pull/438](https://github.com/cloudflare/circl/pull/438)
- Set CIRCL version for generated assembler code. by
[@&#8203;armfazh](https://github.com/armfazh) in
[https://github.com/cloudflare/circl/pull/440](https://github.com/cloudflare/circl/pull/440)
- Add tkn20 benchmarks by
[@&#8203;tanyav2](https://github.com/tanyav2) in
[https://github.com/cloudflare/circl/pull/442](https://github.com/cloudflare/circl/pull/442)
- Add partially blind RSA implementation by
[@&#8203;chris-wood](https://github.com/chris-wood) in
[https://github.com/cloudflare/circl/pull/445](https://github.com/cloudflare/circl/pull/445)
- Update doc.go by
[@&#8203;nadimkobeissi](https://github.com/nadimkobeissi) in
[https://github.com/cloudflare/circl/pull/447](https://github.com/cloudflare/circl/pull/447)
- tss/rsa: key generation for threshold RSA (safe primes) by
[@&#8203;armfazh](https://github.com/armfazh) in
[https://github.com/cloudflare/circl/pull/450](https://github.com/cloudflare/circl/pull/450)
- Bumping Go version for CI jobs. by
[@&#8203;armfazh](https://github.com/armfazh) in
[https://github.com/cloudflare/circl/pull/457](https://github.com/cloudflare/circl/pull/457)
- Spelling by [@&#8203;jsoref](https://github.com/jsoref) in
[https://github.com/cloudflare/circl/pull/456](https://github.com/cloudflare/circl/pull/456)
- blindrsa: updating blindrsa to be compliant with RFC9474 by
[@&#8203;armfazh](https://github.com/armfazh) in
[https://github.com/cloudflare/circl/pull/464](https://github.com/cloudflare/circl/pull/464)
- Releasing CIRCL v1.3.6 by
[@&#8203;armfazh](https://github.com/armfazh) in
[https://github.com/cloudflare/circl/pull/465](https://github.com/cloudflare/circl/pull/465)

##### New Contributors

- [@&#8203;nadimkobeissi](https://github.com/nadimkobeissi) made their
first contribution in
[https://github.com/cloudflare/circl/pull/447](https://github.com/cloudflare/circl/pull/447)
- [@&#8203;jsoref](https://github.com/jsoref) made their first
contribution in
[https://github.com/cloudflare/circl/pull/456](https://github.com/cloudflare/circl/pull/456)

**Full Changelog**:
cloudflare/circl@v1.3.3...v1.3.6

###
[`v1.3.5`](https://github.com/cloudflare/circl/compare/v1.3.4...v1.3.5)

[Compare
Source](https://github.com/cloudflare/circl/compare/v1.3.4...v1.3.5)

###
[`v1.3.4`](https://github.com/cloudflare/circl/compare/v1.3.3...v1.3.4)

[Compare
Source](https://github.com/cloudflare/circl/compare/v1.3.3...v1.3.4)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "" (UTC), Automerge - At any time (no
schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/hetznercloud/terraform-provider-hcloud).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjcuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New functionality or module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants