oktz-curve25519
v0.0.10
Published
curve25519-js replacement — XEdDSA sign/verify native Rust, X25519 node:crypto
Readme
oktz-curve25519
A native Rust XEdDSA binding for Node.js, exposed through CommonJS.
XEdDSA is the Ed25519-over-Curve25519 signature scheme Signal uses to sign
identities. node:crypto has no XEdDSA — it has X25519 and it has Ed25519,
and they are not the same thing. This package supplies the missing primitive
as a Rust cdylib behind napi-rs, and supplies nothing else: the X25519
keygen and Diffie-Hellman that Node already has natively are called straight
through to node:crypto, so there is no second implementation of anything
that did not need to exist.
- Two functions are Rust:
signandverify. - Four are
node:crypto:generateKeyPair,sharedKey, and thesignMessage/openMessagepair built on top ofsign/verify. - Six exports, total. See docs/api.md.
⚠️ Read this first: what changed at 0.0.6
As of 0.0.6, the published package and this directory are the same
artifact. Everything below this point describes 0.0.6, and 0.0.6 is what
gets installed. There is no second layout in this README.
This was not true of what came before, and the reason the older versions are still worth describing:
| | [email protected] on npm | [email protected] — this directory |
|---|---|---|
| files | ["index.cjs", "curve25519.linux-x64-gnu.node"] | ["index.cjs", "native-loader.cjs"] |
| optionalDependencies | none | 4, all oktz-curve25519-* |
| binaries in the tarball | curve25519.linux-x64-gnu.node | none — they come from the platform packages |
| how the addon is loaded | require('./curve25519.linux-x64-gnu.node'), hard-coded, at the top of index.cjs | require('./native-loader.cjs'), which dispatches on platform |
| tarball contents | 3 files, 734 523 bytes unpacked | — |
| works off linux-x64 | no: the require is unconditional, so require() throws | yes — the platform package is installed and its .node is loaded |
0.0.4's index.cjs:16 was the whole difference — this is that line,
verbatim, from the 0.0.4 tarball, not from this tree:
// [email protected] — not the shipped line as of 0.0.6
const native = require('./curve25519.linux-x64-gnu.node');against this directory's index.cjs:16, which is what 0.0.6 ships:
const native = require('./native-loader.cjs');What changed, in the order it matters to a consumer:
- 0.0.6 carries a real native binding. It is the first release of this
package that publishes a working
.node. The four@oktz/curve25519-linux-{x64,arm64}-{gnu,musl}packages are published and resolvable, and they are declared asoptionalDependenciesat0.0.6inpackage.json. Before that,0.0.5shipped this loader against fouroptionalDependenciesthat did not exist on the registry, so an install resolved no native binding at all andrequire()threw. 0.0.6is the first release that carries the library fixes — the strictverifyequation, the CSPRNG nonce, the zeroizing andclamp_scalarwork, and the known-answer vectors. Two of them change observable behaviour, which is why the version moved rather than0.0.4being republished. The full list is in CHANGELOG.md.- Only
0.0.4and0.0.5had a different artifact from this tree. If you have a lockfile pinning either, upgrade; the loader, the export names andmainare otherwise unchanged, so nothing in your call sites moves.
Everything this README says about the loader, the exports and the platform
matrix is about 0.0.6, which is the npm artifact. The registry also serves
[email protected], which is the old single-platform layout; that layout
is 0.0.4's, described above, and it is not what 0.0.6 installs.
Install
npm install oktz-curve25519There are no runtime dependencies. The optionalDependencies in
package.json are the platform packages, and the install behaviour is npm's,
not this package's:
- npm installs the one whose
os/cpu/libcmatch the host and skips the rest without an error, because they are optional. - If no platform package matches,
npm installstill succeeds. The failure comes later, atrequire()time, asCannot find native binding— with the individualMODULE_NOT_FOUNDerrors attached aserror.cause(native-loader.cjs:701-712). - If the install is broken by something other than the host — a partial
node_modules, a stale lockfile that still points at0.0.4or0.0.5— you get the second case too, which is the state every install was in before0.0.6.
Platform matrix
Declared targets are the four in napi.config.json and the four in
optionalDependencies at 0.0.6; the Android target below is built and
packaged by CI but is deliberately kept out of both. Nothing else is declared,
built, or supported.
| Target | Platform package | Published at 0.0.6? | Binary loaded on this host? |
|---|---|---|---|
| x86_64-unknown-linux-gnu | @oktz/curve25519-linux-x64-gnu | yes | yes — built and loaded here, tests run against it |
| x86_64-unknown-linux-musl | @oktz/curve25519-linux-x64-musl | yes | compile result only; never loaded |
| aarch64-unknown-linux-gnu | @oktz/curve25519-linux-arm64-gnu | yes | compile result only; never loaded |
| aarch64-unknown-linux-musl | @oktz/curve25519-linux-arm64-musl | yes | compile result only; never loaded |
| aarch64-linux-android | oktz-curve25519-android-arm64 | no — gated, see below | compile result only; never loaded |
- macOS: not built, not published, not supported. No
darwintarget appears innapi.config.json, inoptionalDependencies, or in either workflow. - Windows: not built, not published, not supported. Same.
- Android/Termux: cross-compiled in CI, deliberately not published.
release.ymlgates the publish on aworkflow_dispatchboolean namedtermux_test_passedthat no CI run ever sets. On Termux you get the JS wrapper and no.node— build it yourself.
The four "compile result only" rows are not a hedge, and publishing them did
not change it. ci.yml builds them and uploads them, release.yml publishes
the four Linux ones, and its step summary says which were built — but no runner
in any workflow executes one of those binaries. The workload that would prove
them needs the matching hardware or an emulator. Treat them as untested: three
of the five .node files a consumer can now install have never been loaded.
native-loader.cjs covers more platforms than this package publishes
The generated loader has branches for win32, darwin, freebsd and
openharmony (native-loader.cjs:118-530). Those are @napi-rs/cli
boilerplate for a full platform matrix. No corresponding package exists,
so on those platforms the loader tries a name that is not on npm and then
throws. It is not a portability promise.
There is one escape hatch, and it is the loader's first check
(native-loader.cjs:67-81): set NAPI_RS_NATIVE_LIBRARY_PATH to the path of
a .node file and it is required instead of any platform package. Verified
here — with it set to a locally built binary, require('oktz-curve25519')
loads and signs, and the loader stamps the artifact it resolved as
__napiBindingTarget === 'native'.
Reading the error when no prebuild matches
The failure is at require() time, and the message is misleading in a way
worth knowing about. Measured on this host with process.platform and
process.arch overridden:
Error: Cannot find native binding. npm has a bug related to optional
dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i`
again after removing both package-lock.json and node_modules directory.
cause: Cannot find module 'oktz-curve25519-wasm32-wasi'That is what you get on darwin-x64, win32-x64, freebsd-x64 and
linux-riscv64 — and the same on linux-x64 if the platform package is
absent, which is what every install looked like before 0.0.6. Two things to
know:
- The
causenames the WASI package (oktz-curve25519-wasm32-wasi, the loader's last fallback atnative-loader.cjs:634-655), not the platform package that was actually missing.error.causeis a chained summary of every attempt, and the last one is the WASI fallback. The platform attempts are in there too. - The advice is wrong for this failure mode. It is npm's generic message for
"no optional dependency installed"; on a host
0.0.6supports that means the platform package was skipped or removed, not that none of them exist on the registry, so reinstalling without clearingnode_modulesmay not help.
Usage
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const curve = require('oktz-curve25519');
const { public: publicKey, private: secretKey } = curve.generateKeyPair(new Uint8Array(32));
const message = Buffer.from('hello, XEdDSA');
const signature = curve.sign(secretKey, message);
console.log('signature:', Buffer.from(signature).toString('hex'));
assert.equal(signature.length, 64);
assert.equal(curve.verify(publicKey, message, signature), true);
const corrupted = Buffer.from(signature);
corrupted[0] ^= 0x01;
assert.equal(curve.verify(publicKey, message, corrupted), false);
console.log('verified, and rejected a one-bit corruption');Every js run block above writes the package specifier a consumer would
write, and docs/verify.mjs rewrites that one specifier to this directory's
index.cjs before running it. The rewrite is load-bearing today: the
enclosing Onigi repository has [email protected] in its
node_modules — the single-platform artifact described in the first section —
so without the rewrite each block would exercise that linux-x64-only tarball
instead of the source it claims to document.
In a checkout of your own, write the path instead:
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const here = dirname(fileURLToPath(import.meta.url));
const curve = createRequire(import.meta.url)(join(here, 'index.cjs'));More in docs/quickstart.md.
The API
Six functions. Full detail, with the exact types and every error, in docs/api.md.
| Export | Kind | Signature |
|---|---|---|
| sign | Rust | (secretKey: Uint8Array(32), msg: Uint8Array, opt_random?: Uint8Array(64)) => Uint8Array(64) |
| verify | Rust | (publicKey: Uint8Array(32), msg: Uint8Array, signature: Uint8Array(64)) => boolean |
| generateKeyPair | node:crypto | (seed: Uint8Array(32)) => { public: Uint8Array(32), private: Uint8Array(32) } |
| sharedKey | node:crypto | (secretKey: Uint8Array(32), publicKey: Uint8Array(32)) => Uint8Array(32) |
| signMessage | JS wrapper | (secretKey, msg, opt_random?) => Uint8Array(64 + msg.length) |
| openMessage | JS wrapper | (publicKey, signedMsg) => Uint8Array \| null |
| default | — | {}, so an ESM default import resolves |
Two traps in that table, both covered in docs/encoding.md and both verified by the examples:
verify()wants 32 raw public-key bytes. The 33-byte0x05-prefixed form thatlibsignalcarries everywhere throwswrong public key length— it does not returnfalse. Strip it first.generateKeyPair(seed)ignoresseed. It is length-checked and then discarded; the keypair is random. The package's own docstring says so (index.cjs:29-31: "diabaikan — Node keygen random"), and0.0.6does exactly what the published0.0.4did — this is unchanged behaviour across both layouts. Use theprivatethe call returns. I could not verify what the upstreamcurve25519-jsdoes with that argument from this tree, so treat the parameter name as a shape, not a contract.
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const curve = require('oktz-curve25519');
const kp = curve.generateKeyPair(new Uint8Array(32).fill(1));
const msg = Buffer.from('prefix');
const sig = curve.sign(kp.private, msg);
const prefixed = Buffer.concat([Buffer.from([0x05]), Buffer.from(kp.public)]);
assert.throws(() => curve.verify(prefixed, msg, sig), /wrong public key length/);
assert.equal(curve.verify(prefixed.subarray(1), msg, sig), true);
console.log('the 0x05-prefixed 33-byte form throws; the 32-byte form verifies');Encoding, in brief
Full version with citations: docs/encoding.md.
- Secret key 32, public key 32, signature 64 (
R ‖ S), nonce 64. verify()throws on a wrong length (index.cjs:22-25, before the addon) and returnsfalseon a wrong key, message or signature. Afalsenever says which.- Byte 63 of the signature carries the public key's sign bit in bit 7; the
scalar
Sbelow it leaves bits 4-6 clear, becauseS < L < 2^252(src/lib.rs:106,src/lib.rs:139, and the reverse atsrc/lib.rs:186-194). - A 32-byte value that is not a real public key returns
false, not a throw (src/lib.rs:187-190).
Security note
This package is unaudited. There is no external security assessment of this code, no third-party cryptographer has reviewed it, and nothing in this repository constitutes one. The tests here are round-trip, rejection and known-answer tests written by the same person who wrote the implementation. Nothing below is a claim that it is safe; it is a list of what the code does, so you can decide.
What this primitive is for
XEdDSA signs a long-term identity key so a peer can check that a bundle belongs to the key it claims to. It is not:
- not Ed25519. Same curve, different scheme. An Ed25519 signature and an XEdDSA signature are not interchangeable, and an Ed25519 verifier will reject an XEdDSA signature.
- not a Diffie-Hellman.
sharedKeyis X25519 agreement and produces a secret nobody can sign with. Nothing in this package converts one into the other. - not a KDF, an AEAD, or a key-derivation function. 32 bytes of shared secret go in and 32 bytes come out. What you do with them is your problem.
What the code actually does
Verified by reading src/lib.rs and by running it:
- Every secret-equivalent buffer this crate materialises and keeps is wrapped
in
Zeroizing. That is the widest true claim, not the widest possible one: several buffers this crate keeps are public (a_bytes,r_bytes,s_bytes,sig) and are deliberately unwrapped, listed with reasons atsrc/lib.rs:267. The 32-byte secret enters this crate into azeroize::Zeroizingbuffer atsrc/lib.rs:164, and is clamped in place atsrc/lib.rs:99—clamp_scalartakes&mut Zeroizing<[u8; 32]>, so the unclamped bytes never exist inside this crate anywhere but that one buffer. EachScalaris wrapped too —a,r,handsinsign_internal(src/lib.rs:103,src/lib.rs:118,src/lib.rs:127,src/lib.rs:132) — together with three buffers that are secret-equivalent toa: theSHA512digest innonce_rnd(src/lib.rs:66), the CSPRNG noncegenerated(src/lib.rs:113), and the caller-suppliedopt_randomnoncernd(src/lib.rs:159). Each is a preimage ofr, and from the publicSandhthat givesa = (S − r)·h⁻¹. The wrap is the substance here, not the style:curve25519-dalek'sScalarhas a manualZeroizeimpl and noDrop, so thezeroizefeature makesscalar.zeroize()callable without making aScalarwipe itself — the arithmetic form of the key would otherwise sit in freed stack memory for the life of the process. Wrapping makes the wipe unconditional on every exit path, including the error return when the CSPRNG cannot be read. The digest is finalised directly into that guard —finalize_into_resetover aGenericArray::from_mut_slice(&mut digest[..])atsrc/lib.rs:67— rather than throughh.finalize().into(), which returned aGenericArrayby value and so put the secret digest in an unwiped slot in this crate's frame first. Two honest limits, recorded atsrc/lib.rs:360andsrc/lib.rs:279:&*r + &*h * &*amaterialises two unwipedScalartemporaries, the product and then the sum, because each is the return value of aMul/Addimpl — harmless here, sincehis public andais not recoverable fromh·aorr + h·awithout already holdinga; andZeroizingbounds this crate's own buffers, not the ones inside its dependencies —curve25519-dalek'sUnpackedScalarlimb temporaries and the[i8; 64]of radix-16 digits thatvariable_base_mulbuilds out ofaandrfor everyB * a, and in sha2 0.10.9 theSha512state thatnonce_rndfeeds the secret key into atsrc/lib.rs:63(sha2 has neitherDropnorZeroizeanywhere, andfinalize_fixed_resetdoes not help:digest_padonly zeroes bytes after the block position, andBlockBuffer::resetonly rewinds the position) plusfull_resinCtVariableCoreWrapper::finalize_fixed_core, which every finalisation path allocates unwiped. Separately, of the four scalars onlyaandrare secret —hisSHA512(R ‖ A ‖ m)over public values andSis published in the signature itself, so those two are wrapped for uniformity rather than necessity.curve25519-dalekanded25519-dalekare both pulled in with thezeroizefeature (Cargo.toml). Two questions decide the rule, and a buffer has to pass both: is it secret-equivalent — would whoever holds it be able to recoverafrom the publicS? "Not derived from the secret" does not clear it, which is why the digest and both nonces are wrapped — and does anything copy it by value, since every by-value argument and every by-value return on the signing path is a copy of material into memory this crate does not wipe, whatever its type. Secret-equivalence is the other gate, not a substitute: that is what keeps public by-value returns such asbase_mult_scalar'sAands.to_bytes()'sSout of the residue list. The by-value question is the one that a derivation test cannot see at all:clamp_scalarused to initialise an unwiped local from the guarded key and return it by value, which put an unclamped copy of the secret on the stack twice, and no amount of derivation reasoning would have flagged it. The caller'sUint8Arrayinputs are the caller's to zeroize, not ours, and they are not zeroized here — napi hands them over as borrowed&[u8]views onto JS memory (napi_get_typedarray_info), and this crate does not own that memory. It does copy out of those views:src/lib.rs:162copies the 64 caller's nonce bytes into a guard, andsrc/lib.rs:164copies the 32 caller's secret-key bytes into a guard. Those two copies are counted above, underSUDAH DI-GUARD; what is left outside any guard is on our side of the boundary, and it is not the caller's bytes. It is worth being precise about whose each piece is, so: one of them is ours to place, and the rest are not ours at all:Scalar::from_bytes_mod_ordertakes its 32 bytes by value, so the**skatsrc/lib.rs:103materialises an unwiped[u8; 32]for the duration of that call — ours to place, dalek's to accept, and unavoidable here only because dalek has no&[u8; 32]-taking constructor to call instead. The rest are not ours at all: dalek'sUnpackedScalarlimb temporaries fromScalar::unpack()(scalar.rs:1119, reached fromfrom_bytes_mod_order→reduce()and from theMul/Addimpls) and, separately, theUnpackedScalarthatfrom_bytes_mod_order_widegets fromUnpackedScalar::from_bytes_wide— that path does not go throughunpack()at all, it callsfrom_bytes_wide(...).pack()andpack()callsas_bytes()— plus the[i8; 64]of radix-16 digits fromScalar::as_radix_16()(scalar.rs:985) thatvariable_base_mulbuilds for everyB * a; then theSha512buffers above, which holdskor a preimage ofruntil they are dropped unwiped, andfull_resinCtVariableCoreWrapper::finalize_fixed_core(digest-0.10.7/src/core_api/ct_variable.rs:119), which every finalisation path allocates unwiped. TheGenericArraythat sha2'sfinalize_fixedused to return by value was not in that group — its value landed in this crate's frame, so it was ours to fix, and it is fixed. All of these are recorded atsrc/lib.rs:279as open, not as fixed: two numbered items, covering six allocation sites. That entry states plainly that the claim is a source-level one and makes no assertion about what any particular build's codegen does with it. "Six" is the result of the criterion applied to the code as it stands, not a proof that six is all of them. Two things cannot show up in a count made this way: allocations internal to a dependency that are not the ones the enumeration names, and anything reachable only through a dependency's internal call graph — that is, through no expression in this file. Five separate review rounds each turned up one more after the previous round said the list was finished, so the number is a claim to be re-run, not a fact to rely on.src/lib.rs:287-293carries the same hedge in the source. - No
unsafein the Rust.#![deny(unsafe_code)]is the first line ofsrc/lib.rs. Verification is delegated toed25519-dalekrather than hand-rolled (src/lib.rs:175-177says why). verify()uses the strict equation.src/lib.rs:206callsvk.verify_strict(...), not the cofactorlessvk.verify(...). That is not a stylistic choice: the cofactorless equation accepts a forgery under any small-order public key. Foru = 0, the Edwards order-2 pointA, the fixed pairR = A, S = 0satisfies it for about half of messages —khas to be odd, since thatAis its own inverse — not for every message. No key material is involved: the attacker picks the message and retries until one lands.tests/loworder-forgery.test.cjsasserts that this package returnsfalsefor exactly that forgery, andexamples/02-rejection.mjsprints it as part of the measured rejection surface.oktz-signalwas already strict (native/signal/src/curve.rs:175-178, in that crate's checkout, which this repository does not vendor).- Scalar arithmetic is constant-time, because it is
curve25519-dalek's, not hand-written. The non-scalar work issha2.
The verifier that actually runs is chosen at load time
verify() is only as strong as the binding that got loaded. Nothing inside
this package chooses that. In the enclosing Onigi repository,
lib/Modded/curve-native.js:126-134 delegates XEdDSA verification to
oktz-signal's native curveVerify when that binding loaded, and falls back to
this package's verify() when it did not. So the equation a caller actually gets
depends on whether an optional prebuild installed.
Both are strict, and that is checked rather than asserted:
tests/platform-loader.test.cjs loads oktz-signal/native/signal/index.cjs,
and asserts that both implementations reject the low-order forgery under three
messages and that each verifies the other's signatures — byte for byte on a
pinned nonce. Without that test, a disagreement would be invisible here:
tests/curve-xeddsa-delegation.test.mjs blocks oktz-curve25519 resolution
outright, so this crate's verify is never reached through that path at all.
The test skips, with the reason printed, when the optional prebuild is absent —
a missing prebuild does not fail the suite.
The fallback is silent. lib/Modded/curve-native.js emits a warning only
when neither binding loaded; when exactly one did, the substitution is
invisible at runtime. As things stand that is not a security hole, because the
two agree — but it is the shape the bug had: this package used to be the
cofactorless one, and the only reason anyone found out is that the two were
compared by hand. This should probably become a warning — an opt-in one,
since a caller who deliberately installed only this prebuild would otherwise
start seeing one on every process start. It is deliberately not done here:
this package cannot emit it, oktz-signal does not own the decision either, and
changing the fallback's behaviour belongs to the adaptor, not to a change that
has no source file to put it in.
One thing a caller should know before using it
sign() is randomised unless you pin the nonce. With no third argument the
nonce is 64 bytes from the platform CSPRNG (src/lib.rs:113-121), so two calls
with the same key over the same message return different signatures. Measured
on this tree: over 64 distinct keypairs, 0/64 pairs of no-nonce signatures came
back byte-identical. Bit 7 of byte 63 is the public key's, not the nonce's —
across 16 no-nonce signatures per key over those same 64 keys, 0/64 keys ever
changed it.
Earlier versions of this package defaulted to r = SHA512(sk ‖ m) mod L, a
function of the secret key alone, and were deterministic. That is a
key-recovery setup rather than a curiosity: with sk fixed, S = r + h·a is
affine in the nonce, so two signatures over chosen messages supply enough
equations to recover a — the hidden-number-problem lattice attack
oktz-signal documents at native/signal/src/curve.rs:123-126 (in that
crate's checkout, which this repository does not vendor), and the reason that
sibling implementation has always taken its nonce from OsRng when the caller
supplies none. This package no longer derives it that way. If the CSPRNG cannot
be read, sign throws rather than fall back to a predictable nonce.
Pass a 64-byte nonce only if you need a reproducible signature — to compare
against a value another implementation produced, or to pin a test vector. It is
the third argument, and that path hashes it under a distinct prefix,
SHA512(0xfe ‖ 0xff×31 ‖ sk ‖ m ‖ rnd) mod L (src/lib.rs:59-69), which is
the derivation [email protected], libsignal and WhatsApp use — so it is
also what keeps this package byte-compatible with them. A nonce you pass in
determines the output; a nonce left out does not. Two caller-supplied nonces
over one key and one message:
import assert from 'node:assert/strict';
import { randomBytes } from 'node:crypto';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const curve = require('oktz-curve25519');
const kp = curve.generateKeyPair(new Uint8Array(32));
const message = Buffer.from('randomised nonce');
const first = curve.sign(kp.private, message, randomBytes(64));
const second = curve.sign(kp.private, message, randomBytes(64));
assert.notDeepEqual(Buffer.from(first), Buffer.from(second),
'two CSPRNG nonces give two different signatures');
assert.equal(curve.verify(kp.public, message, first), true);
assert.equal(curve.verify(kp.public, message, second), true);
console.log('two random 64-byte nonces -> two different signatures, both valid');Rejection surface, measured
A wrong key, a wrong message, a flipped bit anywhere in the 64-byte
signature, a toggled sign bit, an all-zero signature: all false. A wrong
length or a plain Array: a throw. See
docs/quickstart.md
and examples/02-rejection.mjs, both executed by npm run docs:verify.
One of those rejections is about the key rather than the signature, and it
is measured in the same example rather than asserted in prose: an all-zero
public key with R = A, S = 0 returns false, under three different messages.
The cofactorless equation this package used to verify with returned true for
that forgery on about half of all messages, and for about three quarters of them
if R is allowed to range over all eight low-order points. The point is not that
the forgery always works: it is that nothing secret is needed to get a signature
accepted, so here "it returns false" is the security property rather than a
convenience.
What has and has not actually been run
Being precise, because "it builds" and "it works" are not the same claim.
| | Status |
|---|---|
| x86_64-unknown-linux-gnu | built and loaded. The test suite and the documentation gate both run against it. |
| the other four targets | built in CI. Never loaded. No runner executes them. |
| cross-implementation agreement with oktz-signal | executed in the test suite, by the last case in tests/platform-loader.test.cjs: both implementations reject the low-order forgery, and each verifies the other's signatures byte for byte on a pinned nonce. Skipped, with the reason printed, when oktz-signal's prebuild does not resolve. Also demonstrated in examples/01-sign-verify.mjs. |
| cargo test | not run. There are no #[test] functions in src/lib.rs; examples/verify_debug.rs is a cargo run example, not a test. |
| external security assessment | none |
cargo build --release --manifest-path native/curve25519/Cargo.toml
cp target/release/libcurve25519_rs.so \
native/curve25519/curve25519.linux-x64-gnu.node
# measured on this tree, Node 22.23.3, linux-x64-gnu:
npm test # 13 passed, 0 failed, 4 files
npm run docs:verify # 20 code blocks + 4 examples, 0 failuresTesting
npm test
npm run docs:verifynpm test is node --test tests/*.test.cjs — a shell glob. That is
deliberate and it is not the obvious spelling. node --test tests/ — the
directory form — fails on Node 22.23.3 with
Error: Cannot find module '…/native/curve25519/tests', because this Node
treats the positional argument as a file path. The shell glob works on both
Node 20 and Node 22; node's own glob syntax for positional arguments is Node
22+, so node --test 'tests/**/*.test.cjs' is not an option for a package
whose engines allow 20.
npm run docs:verify executes every js run block in this README,
CHANGELOG.md and docs/, plus every examples/*.mjs, and exits non-zero
if any of them does. Two shapes are hard failures rather than silent skips: a
JavaScript block that is neither run nor illustrative, and a fence with no
info string at all. A snippet nobody labelled is the one that goes stale
without anyone noticing, so the gate refuses to guess.
Each block writes the package specifier a consumer would write, and the
verifier rewrites that one specifier to this directory's index.cjs before
running it — otherwise every block would exercise the [email protected]
that the enclosing repository has in node_modules, which is the wrong
artifact.
Both need a loaded native binding, so in CI they run on the
x86_64-unknown-linux-gnu leg only, across Node 20, 22 and 24. On any other
host they will fail at require, which is the correct outcome and not a
documentation bug.
Known limitations
- Only
linux-x64-gnuis verified end to end.0.0.6publishes four platform packages, but the other three are compile results that no runner has executed. See the platform matrix above. - macOS and Windows are unsupported, by omission rather than by policy — there is no target to build.
- The Android binary is never published, gated on a workflow input that
nothing sets. It is also not in
optionalDependencies, sonpm installnever asks for it. generateKeyPairis not seeded. The parameter is namedseed, is validated as one, and is then thrown away.0.0.6and the published0.0.4behave identically, so this is not a0.0.6regression — it is the behaviour that has always shipped here, through both layouts. Ported code that expects the argument to determine the keypair will not get that.- No TypeScript definitions ship in the tarball.
index.cjsis CommonJS and untyped;napi.config.jsonhas notypesentry andpackage.jsonhas notypesfield. Editors will inferany. A.d.tsgenerated bynapi buildis not infiles. - No
LICENSEfile in this directory.package.jsonsays MIT, and the parent repository carries the licence text; the vendored crate does not have its own copy.
See also
- docs/quickstart.md — sign, verify, reject
- docs/api.md — every export, read from source
- docs/encoding.md — the
0x05prefix, the sign bit, the lengths - CHANGELOG.md — what
0.0.6changed, and what is still wrong examples/*.mjs— the above, as programs
Licence
MIT. See the parent repository's LICENSE.
