This source candidate declares SDK peer ^2.4.1 || ^3.0.0 || ^4.0.1. SDK3 remains
a coordinated proposal; see the qualification and migration limits
before adopting it.
@bsv/ecpm-permission-module is the reference p ecpm semantic module for
BRC-100 wallet hosts. It applies or removes a wallet-derived scalar from an
arbitrary validated secp256k1 point while retaining the standard
getPublicKey request and response shapes.
Use this package when a protocol needs commutative point masking or another
point operation whose base is supplied by the application. Pure BRC-43 can
name a counterparty while deriving the scalar, but ordinary getPublicKey
still returns that scalar times the fixed generator; it cannot select the
caller's point as the multiplication base.
npm install @bsv/ecpm-permission-module @bsv/wallet-toolbox-client @bsv/sdkCall the existing getPublicKey method with this protocol name inside the
normal [securityLevel, protocolName] tuple:
p ecpm <apply|remove> <pointHex> <logicalProtocolID>The module reads keyID, counterparty, privileged, privilegedReason, and
seekPermission from their existing fields. It derives a BRC-42/43 child key
under p ecpm <logicalProtocolID> and maps it to the multiplication scalar by
HKDF-SHA256 as 1 + (OKM mod (n - 1)); the child key is never used as the scalar
or returned. The operation and point are deliberately omitted from the
derivation so remove uses the inverse of the exact scalar selected by apply.
Version 0.2.0 introduced this mapping (GHSA-m3c6-3mv8-j86f), so every scalar
differs from 0.1.x; do not mix versions within one protocol run.
const masked = await wallet.getPublicKey({
protocolID: [2, `p ecpm apply ${pointHex} mental poker deal`],
keyID: 'deck mask',
counterparty: 'self'
})
const restored = await wallet.getPublicKey({
protocolID: [2, `p ecpm remove ${masked.publicKey} mental poker deal`],
keyID: 'deck mask',
counterparty: 'self'
})import { createEcpmModule } from '@bsv/ecpm-permission-module'
import { WalletPermissionsManager } from '@bsv/wallet-toolbox-client'
const ecpm = createEcpmModule({
keyDeriver: setup.keyDeriver,
authorize: request => showTrustedWalletPrompt(request),
privilegedKeyDeriver: reason => acquirePrivilegedKeyDeriver(reason)
})
const wallet = new WalletPermissionsManager(setup.wallet, adminOriginator, {
permissionModules: { ecpm }
})The privileged provider is optional. If an application requests
privileged: true, the module authorizes the supplied reason before asking the
host for a privileged deriver and fails closed when no provider is available.
getPublicKey is accepted under p ecpm; signing, HMAC, and encryption
calls cannot reuse the ECPM-derived scalar.forSelf modes are rejected.privilegedReason, so a different reason
cannot reuse the approval. seekPermission: false fails unless an applicable
grant is already cached.{ publicKey }, never the derived scalar or
either key-derivation provider.Wallet Toolbox exposes the optional
PermissionsModule.handleRequest(request, next) semantic hook. A module can
return the standard BRC-100 result directly, as ECPM does, or call next at
most once. Existing onRequest/onResponse transformation modules remain
compatible.
The SDK4 peer alternative now requires @bsv/sdk ^4.0.1 for the numeric wallet
result and legacy wire hotfix. Existing SDK2/3 alternatives and lower bounds
remain unchanged. No wire or data migration is required.