Skip to content

Commit

Permalink
chore(sdk-lib-mpc): fix range for mu, nu, x, y in no small factors
Browse files Browse the repository at this point in the history
TICKET: WP-132

TICKET: WP-132
  • Loading branch information
johnoliverdriscoll authored and alebusse committed Oct 16, 2023
1 parent 2b525de commit 4480b5b
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 102 deletions.
1 change: 1 addition & 0 deletions modules/sdk-lib-mpc/src/tss/ecdsa/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * as EcdsaTypes from './types';
export * as EcdsaRangeProof from './rangeProof';
export * as EcdsaPaillierProof from './paillierProof';
export * as EcdsaPaillierBlumProof from './paillierBlumProof';
export * as EcdsaZkVProof from './zkVProof';
export * as EcdsaNoSmallFactorsProof from './noSmallFactorsProof';
export * from './generatePaillierKey';
Expand Down
8 changes: 4 additions & 4 deletions modules/sdk-lib-mpc/src/tss/ecdsa/noSmallFactorsProof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ export function prove(
const beta = randBetween(sqrtN0 << (ELL + EPSILON), -sqrtN0 << (ELL + EPSILON));
const rho = randBetween((nHat * n0) << ELL, -(nHat * n0) << ELL);
// Commit to p.
const mu = randBetween(BigInt(1) << ELL, BigInt(-1) << ELL);
const mu = randBetween(nHat << ELL, -nHat << ELL);
const P = (modPow(s, p, nHat) * modPow(t, mu, nHat)) % nHat;
// Commit to q.
const nu = randBetween(BigInt(1) << ELL, BigInt(-1) << ELL);
const nu = randBetween(nHat << ELL, -nHat << ELL);
const Q = (modPow(s, q, nHat) * modPow(t, nu, nHat)) % nHat;
// Commit to alpha.
const x = randBetween(BigInt(1) << (ELL + EPSILON), BigInt(-1) << (ELL + EPSILON));
const x = randBetween(nHat << (ELL + EPSILON), -nHat << (ELL + EPSILON));
const A = (modPow(s, alpha, nHat) * modPow(t, x, nHat)) % nHat;
// Commit to beta.
const y = randBetween(BigInt(1) << (ELL + EPSILON), BigInt(-1) << (ELL + EPSILON));
const y = randBetween(nHat << (ELL + EPSILON), -nHat << (ELL + EPSILON));
const B = (modPow(s, beta, nHat) * modPow(t, y, nHat)) % nHat;
// Commit to Q and alpha.
const r = randBetween((nHat * n0) << (ELL + EPSILON), -(nHat * n0) << (ELL + EPSILON));
Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-lib-mpc/src/tss/ecdsa/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ export function serializeNoSmallFactorsProof(
rho: signedBigIntToHex(noSmallFactorsProof.rho, 2 * (2 * 384 + 256 / 8)),
z1: signedBigIntToHex(noSmallFactorsProof.z1, 2 * (1 + 384 / 2 + (256 + 2 * 256) / 8)),
z2: signedBigIntToHex(noSmallFactorsProof.z2, 2 * (1 + 384 / 2 + (256 + 2 * 256) / 8)),
w1: signedBigIntToHex(noSmallFactorsProof.w1, 2 * (1 + (256 + 2 * 256) / 8)),
w2: signedBigIntToHex(noSmallFactorsProof.w2, 2 * (1 + (256 + 2 * 256) / 8)),
w1: signedBigIntToHex(noSmallFactorsProof.w1, 2 * 384 + 2 * (1 + (256 + 2 * 256) / 8)),
w2: signedBigIntToHex(noSmallFactorsProof.w2, 2 * 384 + 2 * (1 + (256 + 2 * 256) / 8)),
v: signedBigIntToHex(noSmallFactorsProof.v, 2 * (1 + 384 * 2 + (256 + 2 * 256) / 8)),
nonce: bigIntToHex(noSmallFactorsProof.nonce, 2 * 33),
};
Expand Down
Loading

0 comments on commit 4480b5b

Please sign in to comment.