From 169d06f4c2615749c205361c3246cf991fd91202 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Sun, 26 Mar 2023 23:48:16 +0200 Subject: [PATCH] Add file '.spi.yml' to let SwiftPackageIndex.com host documentation. (#31) --- .spi.yml | 4 ++++ Sources/K1/Support/FFI/API/ECDSA/FFI+ECDSA.swift | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .spi.yml diff --git a/.spi.yml b/.spi.yml new file mode 100644 index 0000000..7a34dd2 --- /dev/null +++ b/.spi.yml @@ -0,0 +1,4 @@ +version: 1 +builder: + configs: + - documentation_targets: [K1] \ No newline at end of file diff --git a/Sources/K1/Support/FFI/API/ECDSA/FFI+ECDSA.swift b/Sources/K1/Support/FFI/API/ECDSA/FFI+ECDSA.swift index e631259..b2b8c01 100644 --- a/Sources/K1/Support/FFI/API/ECDSA/FFI+ECDSA.swift +++ b/Sources/K1/Support/FFI/API/ECDSA/FFI+ECDSA.swift @@ -85,9 +85,14 @@ extension K1.ECDSA.SigningOptions.NonceFunction { _: UInt32 // In: how many iterations we have tried to find a nonce. This will almost always be 0, but different attempt values are required to result in a different nonce. ) -> Int32 /* Returns: 1 if a nonce was successfully generated. 0 will cause signing to fail. */ in - SecureBytes(count: Curve.Field.byteCount).withUnsafeBytes { - nonce32?.assign(from: $0.baseAddress!.assumingMemoryBound(to: UInt8.self), count: $0.count) - } + let count = Curve.Field.byteCount + let secureBytes = SecureBytes(count: count) + + #if swift(>=5.8) + nonce32?.update(from: secureBytes.bytes, count: count) + #else + nonce32?.assign(from: secureBytes.bytes, count: count) + #endif // Returns: 1 if a nonce was successfully generated. 0 will cause signing to fail. return 1