Skip to content

Commit

Permalink
Reject identity keys in Schnorr/Chaum proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFeickert committed Jan 2, 2024
1 parent ab389d8 commit 625e2af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libspark/chaum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ bool Chaum::verify(
if (!(T.size() == n && proof.A2.size() == n && proof.t1.size() == n)) {
throw std::invalid_argument("Bad Chaum semantics!");
}
for (std::size_t i = 0; i < n; i++) {
if (S[i].isInfinity()) {
throw std::invalid_argument("Bad Chaum input!");
}
}

Scalar c = challenge(mu, S, T, proof.A1, proof.A2);
if (c.isZero()) {
Expand Down
6 changes: 6 additions & 0 deletions src/libspark/schnorr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ bool Schnorr::verify(const GroupElement& Y, const SchnorrProof& proof) {
bool Schnorr::verify(const std::vector<GroupElement>& Y, const SchnorrProof& proof) {
const std::size_t n = Y.size();

for (std::size_t i = 0; i < n; i++) {
if (Y[i].isInfinity()) {
throw std::invalid_argument("Bad Schnorr input key!");
}
}

std::vector<GroupElement> points;
points.reserve(n + 2);
std::vector<Scalar> scalars;
Expand Down

0 comments on commit 625e2af

Please sign in to comment.