@btc-vision/transaction 1.8.8 → 1.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -115,7 +115,7 @@ export class EpochValidator {
115
115
  public static verifySolution(
116
116
  challenge: IChallengeSolution,
117
117
  log: boolean = false,
118
- useHashedPreimage: boolean = false,
118
+ useConcatenatedPreimage: boolean = false,
119
119
  ): boolean {
120
120
  try {
121
121
  const verification = challenge.verification;
@@ -123,7 +123,7 @@ export class EpochValidator {
123
123
  verification.targetChecksum,
124
124
  challenge.publicKey.toBuffer(),
125
125
  challenge.salt,
126
- useHashedPreimage,
126
+ useConcatenatedPreimage,
127
127
  );
128
128
 
129
129
  const computedSolution = this.sha1(calculatedPreimage);
@@ -168,7 +168,7 @@ export class EpochValidator {
168
168
  */
169
169
  public static validateEpochWinner(
170
170
  epochData: RawChallenge,
171
- useHashedPreimage: boolean = false,
171
+ useConcatenatedPreimage: boolean = false,
172
172
  ): boolean {
173
173
  try {
174
174
  const epochNumber = BigInt(epochData.epochNumber);
@@ -194,7 +194,7 @@ export class EpochValidator {
194
194
  verification.targetChecksum,
195
195
  publicKey.toBuffer(),
196
196
  salt,
197
- useHashedPreimage,
197
+ useConcatenatedPreimage,
198
198
  );
199
199
 
200
200
  const computedSolution = this.sha1(calculatedPreimage);
@@ -226,9 +226,9 @@ export class EpochValidator {
226
226
  */
227
227
  public static validateChallengeSolution(
228
228
  challenge: IChallengeSolution,
229
- useHashedPreimage: boolean = false,
229
+ useConcatenatedPreimage: boolean = false,
230
230
  ): boolean {
231
- return this.verifySolution(challenge, false, useHashedPreimage);
231
+ return this.verifySolution(challenge, false, useConcatenatedPreimage);
232
232
  }
233
233
 
234
234
  /**
@@ -242,13 +242,13 @@ export class EpochValidator {
242
242
  targetChecksum: Uint8Array,
243
243
  publicKey: Uint8Array,
244
244
  salt: Uint8Array,
245
- useHashedPreimage: boolean = false,
245
+ useConcatenatedPreimage: boolean = false,
246
246
  ): Uint8Array {
247
247
  const preimage = this.calculatePreimage(
248
248
  targetChecksum,
249
249
  publicKey,
250
250
  salt,
251
- useHashedPreimage,
251
+ useConcatenatedPreimage,
252
252
  );
253
253
  return this.sha1(preimage);
254
254
  }
@@ -983,8 +983,25 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
983
983
  const mldsaSigner = this.mldsaSigner;
984
984
  const legacySignature = this.generateLegacySignature();
985
985
 
986
+ // Reveal by default. The legacy Schnorr signature only proves ownership of
987
+ // the Bitcoin key being linked; it says nothing about the claimed
988
+ // hashedPublicKey. Without the ML-DSA public key and a signature over it,
989
+ // a link request carries no proof that the sender knows a preimage for
990
+ // that hash, so a node cannot safely create a NEW identity from it.
991
+ //
992
+ // Defaulting to false made every caller responsible for remembering, and
993
+ // callers do forget: opwallet never set this anywhere, and its deployment
994
+ // screen calls signDeployment() directly, bypassing any controller-level
995
+ // fix. Revealing when it was not needed only costs bytes (ML-DSA-44:
996
+ // 1312-byte key + 2420-byte signature); not revealing when it was needed
997
+ // gets the transaction rejected.
998
+ //
999
+ // Callers that KNOW the key is already linked on-chain should pass false
1000
+ // explicitly to avoid paying for the reveal on every interaction.
1001
+ const shouldReveal = parameters.revealMLDSAPublicKey ?? true;
1002
+
986
1003
  let mldsaSignature: Uint8Array | null = null;
987
- if (parameters.revealMLDSAPublicKey) {
1004
+ if (shouldReveal) {
988
1005
  mldsaSignature = this.generateMLDSASignature();
989
1006
  }
990
1007
 
@@ -992,7 +1009,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
992
1009
  priority: FeaturePriority.MLDSA_LINK_PUBKEY,
993
1010
  opcode: Features.MLDSA_LINK_PUBKEY,
994
1011
  data: {
995
- verifyRequest: !!parameters.revealMLDSAPublicKey,
1012
+ verifyRequest: shouldReveal,
996
1013
  publicKey: mldsaSigner.publicKey,
997
1014
  hashedPublicKey: this.hashedPublicKey,
998
1015
  level: getLevelFromPublicKeyLength(mldsaSigner.publicKey.length),