Skip to content

Commit

Permalink
Fix some problems in js-bindings. (dashpay#69)
Browse files Browse the repository at this point in the history
* Update Threshold.spec.js

Fix index of fragments.

* Update SignatureWrapper.cpp

Update function name.

* Update ThresholdWrapper.cpp

Did not asign results to pubKeyWrappersArray nor privateKeyWrappers.
  • Loading branch information
mogisawa authored and mariano54 committed Jul 22, 2019
1 parent c87e896 commit 1093179
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions js-bindings/tests/Threshold.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('Threshold', () => {

for (let target = 0; target < N; target++) {
for (let source = 0; source < N; source++) {
assert(Threshold.verifySecretFragment(target + 1, fragments[target][source], commitments[source], T));
assert(Threshold.verifySecretFragment(target + 1, fragments[source][target], commitments[source], T));
}
}

Expand All @@ -80,7 +80,7 @@ describe('Threshold', () => {
for (let i = 0; i < N; ++i) {
receivedSecretFragments.push([]);
for (let j = 0; j < N; ++j) {
receivedSecretFragments[i].push(fragments[i][j]);
receivedSecretFragments[i].push(fragments[j][i]);
}
}

Expand Down Expand Up @@ -128,4 +128,4 @@ describe('Threshold', () => {

assert(signature2.verify([hash], [masterPubkey]));
});
});
});
2 changes: 1 addition & 1 deletion js-bindings/wrappers/SignatureWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ SignatureWrapper::FromBytesAndAggregationInfo(val buffer, const AggregationInfoW
SignatureWrapper SignatureWrapper::AggregateSigs(val signatureWrappers) {
std::vector <Signature> signatures = SignatureWrapper::Unwrap(
helpers::toVectorFromJSArray<SignatureWrapper>(signatureWrappers));
Signature aggregatedSignature = Signature::AggregateSigs(signatures);
Signature aggregatedSignature = Signature::Aggregate(signatures);
return SignatureWrapper(aggregatedSignature);
}

Expand Down
8 changes: 8 additions & 0 deletions js-bindings/wrappers/ThresholdWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ PrivateKeyWrapper ThresholdWrapper::Create(val pubKeyWrappersArray, val privateK
std::vector <PrivateKey> secretFragment = PrivateKeyWrapper::Unwrap(
helpers::toVectorFromJSArray<PrivateKeyWrapper>(privateKeyWrappers));
PrivateKey result = Threshold::Create(commitment, secretFragment, threshold, playersCount);
auto cl = commitment.size();
for (unsigned i = 0; i < cl; ++i) {
pubKeyWrappersArray.set(i, PublicKeyWrapper(commitment.at(i)));
}
auto fl = secretFragment.size();
for (unsigned i = 0; i < fl; ++i) {
privateKeyWrappers.set(i, PrivateKeyWrapper(secretFragment.at(i)));
}
return PrivateKeyWrapper(result);
}

Expand Down

0 comments on commit 1093179

Please sign in to comment.