Skip to content

Commit

Permalink
Merge pull request #3 from distributed-lab/feature/sigma-zkp
Browse files Browse the repository at this point in the history
Sigma ZKP for veiled operations
  • Loading branch information
KlausKidman authored Sep 23, 2024
2 parents 9b054d0 + 3ea4b29 commit 7ac9c75
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/core/crypto/twistedElGamal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ export class TwistedElGamal {
return new TwistedElGamalCiphertext(C.toRawBytes(), D.toRawBytes());
}

/**
* Encrypts the amount with Twisted ElGamal with no randomness
*
* @param amount amount for encryption
*/
static encryptWithNoRandomness(amount: bigint) {
if (amount < 0n && amount >= ed25519.CURVE.n)
throw new Error(`The amount must be in the range 0 to ${ed25519.CURVE.n}`);

const C = amount === BigInt(0) ? RistrettoPoint.ZERO : RistrettoPoint.BASE.multiply(amount);

return new TwistedElGamalCiphertext(C.toRawBytes(), RistrettoPoint.ZERO.toRawBytes());
}

/**
* Decrypts the amount with Twisted ElGamal
* @param ciphertext сiphertext points encrypted by Twisted ElGamal
Expand Down

0 comments on commit 7ac9c75

Please sign in to comment.