deriveChildPublic static method

SVPublicKey deriveChildPublic(
  1. SVPublicKey recipientPub,
  2. SVPrivateKey senderPriv,
  3. String invoiceNumber
)

Child public key C = recipientPub + t·G.

The tweak t is derived from the ECDH secret of (senderPriv, recipientPub) and invoiceNumber, so the sender (payer) computes the destination for the recipient (creator) without the recipient's private key.

Implementation

static dartsv.SVPublicKey deriveChildPublic(
  dartsv.SVPublicKey recipientPub,
  dartsv.SVPrivateKey senderPriv,
  String invoiceNumber,
) {
  final t = _nonZero(tweak(sharedSecret(senderPriv, recipientPub), invoiceNumber));
  final c = recipientPub.point + _scalarBaseMult(t);
  if (c == null || c.isInfinity) {
    throw StateError('Derived child public key is the point at infinity');
  }
  // Round-trip through dartsv's own curve to avoid cross-instance mismatches.
  return dartsv.SVPublicKey.fromHex(_hex(c.getEncoded(true)));
}