core/crypto/x448: Initial import

This commit is contained in:
Yawning Angel
2024-08-20 12:03:04 +09:00
parent bb395aeb41
commit 9fdcc4e39a
6 changed files with 1542 additions and 0 deletions
@@ -14,6 +14,7 @@ import "core:crypto/chacha20poly1305"
import "core:crypto/ed25519"
import "core:crypto/poly1305"
import "core:crypto/x25519"
import "core:crypto/x448"
// Cryptographic primitive benchmarks.
@@ -237,6 +238,26 @@ benchmark_crypto :: proc(t: ^testing.T) {
time.duration_microseconds(elapsed) / iters,
)
}
{
point_str := "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
scalar_str := "cafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabe"
point, _ := hex.decode(transmute([]byte)(point_str), context.temp_allocator)
scalar, _ := hex.decode(transmute([]byte)(scalar_str), context.temp_allocator)
out: [x448.POINT_SIZE]byte = ---
iters :: 10000
start := time.now()
for i := 0; i < iters; i = i + 1 {
x448.scalarmult(out[:], scalar[:], point[:])
}
elapsed := time.since(start)
fmt.sbprintfln(&str,
"x448.scalarmult: ~%f us/op",
time.duration_microseconds(elapsed) / iters,
)
}
}
@(private)