]> git.codecow.com Git - nano25519.git/commitdiff
Fix output buffer copy.
authorChris Duncan <chris@zoso.dev>
Sat, 15 Aug 2026 07:57:46 +0000 (00:57 -0700)
committerChris Duncan <chris@zoso.dev>
Sat, 15 Aug 2026 07:57:46 +0000 (00:57 -0700)
src/lib/nano25519.ts

index 3d9945e71e277a106ebe7107b4249eaaff4f90b9..2f402b294113c96cdc3a8387ceeb1b2573a90db9 100644 (file)
@@ -93,9 +93,8 @@ export const nano25519_init = (bytes: number[]): { derive: typeof derive, sign:
                                }
                                return hex
                        } else if (isBytes(k) && out != null) {
-                               for (let i = 0; i < 32; i++) {
-                                       out[i] = publicKey[i]
-                               }
+                               out.set(publicKey)
+                               publicKey.fill(0)
                                return
                        } else {
                                return publicKey
@@ -103,7 +102,6 @@ export const nano25519_init = (bytes: number[]): { derive: typeof derive, sign:
                } finally {
                        clear(buffer)
                        privateKey.fill(0)
-                       publicKey.fill(0)
                }
        }
 
@@ -138,9 +136,8 @@ export const nano25519_init = (bytes: number[]): { derive: typeof derive, sign:
                                }
                                return hex
                        } else if (isBytes(k) && s != null) {
-                               for (let i = 0; i < 32; i++) {
-                                       s[i] = signature[i]
-                               }
+                               s.set(signature)
+                               signature.fill(0)
                                return
                        } else {
                                return signature
@@ -148,7 +145,6 @@ export const nano25519_init = (bytes: number[]): { derive: typeof derive, sign:
                } finally {
                        clear(buffer)
                        secretKey.fill(0)
-                       signature.fill(0)
                }
        }