-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Regression in 1.5.0 #45
Comments
These both also occasionally break in the same way: const signatureCopy = Buffer.from(signature.buffer, signature.byteOffset, signature.byteLength) const signatureCopy = Buffer.from(signature) |
`@noble/[email protected]` introduces a regression around signatures so pin to `1.4.0` while it is resolved. Refs: paulmillr/noble-ed25519#45
This is a problem because if you're doing things like writing sigs into protobufs as |
`@noble/[email protected]` introduces a regression around signatures so pin to `1.4.0` while it is resolved. Refs: paulmillr/noble-ed25519#45
Strange. Not sure how could this happen. |
|
Buffers are piece of shit. Besides them leaking private info [do Somehow it gets through our checks because
|
For the record: Uint8Array.slice() creates a copy, not a subarray. You cannot reason about anything if it's subarray. |
@achingbrain 1.5.1 will fix this, I still suggest to drop Buffers, they are dangerous and are not supported in browsers anyway. u8as are supported everywhere. |
Unfortunately I don't think it's that simple. Uint8Arrays also seem to use more memory to represent the same data so they're not perfect, or even a drop-in replacement thanks to the Anyway thanks for fixing the issue. |
Do you have any benchmarks? In recent nodes buffers are backed by uint8arrays. Also if you're cool with using temporary shared buffers (= what Buffer.from / allocUnsafe do), there's always an approach used in noble-hashes: You can create shared uint8arrays and be fast. |
const REPEAT = 100000
const size = 1024
let start = Date.now()
for (let i = 0; i < REPEAT; i++) {
new Uint8Array(size)
}
console.info(`new Uint8Array(${size})`, Date.now() - start, 'ms')
start = Date.now()
for (let i = 0; i < REPEAT; i++) {
Buffer.alloc(size)
}
console.info(`Buffer.alloc(${size})`, Date.now() - start, 'ms')
start = Date.now()
for (let i = 0; i < REPEAT; i++) {
Buffer.allocUnsafe(size)
}
console.info(`Buffer.allocUnsafe(${size})`, Date.now() - start, 'ms')
start = Date.now()
for (let i = 0; i < REPEAT; i++) {
Buffer.allocUnsafe(size).fill(0)
}
console.info(`Buffer.allocUnsafe(${size}).fill(0)`, Date.now() - start, 'ms') $ node index.js
new Uint8Array(1024) 86 ms
Buffer.alloc(1024) 83 ms
Buffer.allocUnsafe(1024) 36 ms
Buffer.allocUnsafe(1024).fill(0) 46 ms |
If you sign a piece of data with
@noble/ed25519
and make a copy of the signature using TypedArray.set, verification sometimes fails.Repro:
The above code with
1.4.0
:With
1.5.0
:Env:
The text was updated successfully, but these errors were encountered: