remove commitment from signature

This commit is contained in:
poma 2021-11-01 18:14:03 +03:00
parent 3fed6e5410
commit ecc3e6b0f5
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
4 changed files with 6 additions and 9 deletions

View File

@ -12,13 +12,11 @@ template Keypair() {
template Signature() {
signal input privateKey;
signal input commitment;
signal input merklePath;
signal output out;
component hasher = Poseidon(3);
component hasher = Poseidon(2);
hasher.inputs[0] <== privateKey;
hasher.inputs[1] <== commitment;
hasher.inputs[2] <== merklePath;
hasher.inputs[1] <== merklePath;
out <== hasher.out;
}

View File

@ -11,7 +11,7 @@ Utxo structure:
}
commitment = hash(amount, pubKey, blinding)
nullifier = hash(commitment, merklePath, sign(commitment + merklePath, privKey))
nullifier = hash(commitment, merklePath, sign(merklePath, privKey))
*/
// Universal JoinSplit transaction with nIns inputs and 2 outputs
@ -57,7 +57,6 @@ template Transaction(levels, nIns, nOuts, zeroLeaf) {
inSignature[tx] = Signature();
inSignature[tx].privateKey <== inPrivateKey[tx];
inSignature[tx].commitment <== inUtxoHasher[tx].out;
inSignature[tx].merklePath <== inPathIndices[tx];
nullifierHasher[tx] = Poseidon(3);

View File

@ -85,8 +85,8 @@ class Keypair {
* @param {string|number|BigNumber} merklePath a hex string with merkle path
* @returns {BigNumber} a hex string with signature
*/
sign(commitment, merklePath) {
return poseidonHash([this.privkey, commitment, merklePath])
sign(merklePath) {
return poseidonHash([this.privkey, merklePath])
}
/**

View File

@ -46,7 +46,7 @@ class Utxo {
) {
throw new Error('Can not compute nullifier without utxo index or private key')
}
const signature = this.keypair.privkey ? this.keypair.sign(this.getCommitment(), this.index || 0) : 0
const signature = this.keypair.privkey ? this.keypair.sign(this.index || 0) : 0
this._nullifier = poseidonHash([this.getCommitment(), this.index || 0, signature])
}
return this._nullifier