Skip to content

test(wallet-core): assert the typed-data BLS vector corpus - #4083

Open
ichbindas wants to merge 2 commits into
dusk-network:masterfrom
ichbindas:test/typed-data-bls-vectors
Open

ichbindas wants to merge 2 commits into
dusk-network:masterfrom
ichbindas:test/typed-data-bls-vectors

Conversation

@ichbindas

Copy link
Copy Markdown

Draft: opened to get a CI build.

The test has not been compiled locally. Its assertions were verified against bls12_381-bls 0.6.0 in a standalone crate with derivation transcribed from wallet-core, but the in-tree build against dusk_wallet_core::keys and dusk_core is unproven. Marking ready once CI is green.

Adds a conformance test for the typed-data signing scheme (dusk-network/wallet#22) and vendors its vector corpus.

Why this belongs here

The scheme is implemented in JavaScript twice — in the Connect SDK and in the wallet extension — and both check themselves against a shared corpus. Nothing checks that corpus against this crate.

That gap is not theoretical. Dusk signs under a custom hash-to-curve domain separation tag, BLS_SIG_BLS12381G1_XMD:SHA-256_DUSK_V2, while every BLS library defaults to the IETF ciphersuite. An implementation that leaves the default in place is self-consistent: it verifies its own signatures, all of its round-trip tests pass, and every signature it produces is rejected on chain. Only fixed expected bytes, checked against this implementation, catch it.

What the test does

Derives keys with derive_bls_sk, signs SIG_TAG || digest on the V2 path, and compares the secret key, public key, signed message and signature to the vendored bytes. It also asserts a corpus signature does not verify over the bare 32-byte digest, which is the property the domain tag exists to provide, and that derive_bls_sk is deterministic for a fixed seed and index — the assumption the rest of the file rests on.

What it adds

  • wallet-core/tests/bls_typed_data_vectors.rs
  • wallet-core/tests/vectors/bls-v1/ — five vectors, vendored verbatim
  • wallet-core/tests/vectors/SOURCE — the upstream commit they came from
  • serde_json in wallet-core's dev-dependencies; already a workspace dependency, so the lockfile change is one line

Vectors are generated in dusk-network/typed-data and are not edited here. Changing them means changing them there and re-vendoring.

Related: dusk-network/connect#35, dusk-network/wallet#101, dusk-network/typed-data.

The typed-data signing scheme (dusk-network/wallet#22) is implemented in
JavaScript twice: in the Connect SDK and in the wallet extension. Both check
themselves against a shared vector corpus, and until now nothing checked that
corpus against this crate.

That gap is not theoretical. Dusk signs under a custom hash-to-curve domain
separation tag, BLS_SIG_BLS12381G1_XMD:SHA-256_DUSK_V2, and every BLS library
defaults to the IETF ciphersuite instead. An implementation that leaves the
default in place is self-consistent: it verifies its own signatures, all of its
round-trip tests pass, and every signature it produces is rejected on chain.
Only fixed expected bytes, checked against this implementation, catch it.

The test derives keys with derive_bls_sk, signs the tagged message with the V2
path, and compares the secret key, public key, signed message and signature to
the vendored bytes. It also asserts that a corpus signature does not verify over
the bare 32-byte digest, which is the property the domain tag exists to provide.

Vectors are vendored verbatim from dusk-network/typed-data with the source
commit recorded in tests/vectors/SOURCE. They are generated there, not here.
serde_json is a dev-dependency used only by tests/bls_typed_data_vectors.rs.
unused_crate_dependencies is evaluated per target, so the lib test target
denied it and the package failed to build under cargo test.
@ichbindas
ichbindas marked this pull request as ready for review September 13, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant