Skip to content

Commit

Permalink
chore: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Mar 21, 2024
1 parent 6df471b commit 078df07
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 22 deletions.
4 changes: 2 additions & 2 deletions yarn-project/accounts/src/defaults/account_interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export class DefaultAccountInterface implements AccountInterface {
return this.entrypoint.createTxExecutionRequest(executions, fee);
}

createAuthWit(message: Fr): Promise<AuthWitness> {
return this.authWitnessProvider.createAuthWit(message);
createAuthWit(messageHash: Fr): Promise<AuthWitness> {
return this.authWitnessProvider.createAuthWit(messageHash);
}

getCompleteAddress(): CompleteAddress {
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/accounts/src/ecdsa/account_contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export class EcdsaAccountContract extends DefaultAccountContract {
class EcdsaAuthWitnessProvider implements AuthWitnessProvider {
constructor(private signingPrivateKey: Buffer) {}

createAuthWit(message: Fr): Promise<AuthWitness> {
createAuthWit(messageHash: Fr): Promise<AuthWitness> {
const ecdsa = new Ecdsa();
const signature = ecdsa.constructSignature(message.toBuffer(), this.signingPrivateKey);
return Promise.resolve(new AuthWitness(message, [...signature.r, ...signature.s]));
const signature = ecdsa.constructSignature(messageHash.toBuffer(), this.signingPrivateKey);
return Promise.resolve(new AuthWitness(messageHash, [...signature.r, ...signature.s]));
}
}
6 changes: 3 additions & 3 deletions yarn-project/accounts/src/schnorr/account_contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export class SchnorrAccountContract extends DefaultAccountContract {
class SchnorrAuthWitnessProvider implements AuthWitnessProvider {
constructor(private signingPrivateKey: GrumpkinPrivateKey) {}

createAuthWit(message: Fr): Promise<AuthWitness> {
createAuthWit(messageHash: Fr): Promise<AuthWitness> {
const schnorr = new Schnorr();
const signature = schnorr.constructSignature(message.toBuffer(), this.signingPrivateKey).toBuffer();
return Promise.resolve(new AuthWitness(message, [...signature]));
const signature = schnorr.constructSignature(messageHash.toBuffer(), this.signingPrivateKey).toBuffer();
return Promise.resolve(new AuthWitness(messageHash, [...signature]));
}
}
9 changes: 0 additions & 9 deletions yarn-project/accounts/src/single_key/account_contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ export class SingleKeyAccountContract extends DefaultAccountContract {
class SingleKeyAuthWitnessProvider implements AuthWitnessProvider {
constructor(private privateKey: GrumpkinPrivateKey, private partialAddress: PartialAddress) {}

/**
* Signs a message hash using the private key and includes the public key and partial address
* in the witness.
*
* Beware that this ONLY signs and rely on the wrapping `wallet_account` to construct the message hash.
*
* @param messageHash - The message hash to sign.
* @returns The authentication witness
*/
createAuthWit(messageHash: Fr): Promise<AuthWitness> {
const schnorr = new Schnorr();
const signature = schnorr.constructSignature(messageHash.toBuffer(), this.privateKey);
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/wallet/signerless_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class SignerlessWallet extends BaseWallet {
throw new Error('Method not implemented.');
}

createAuthWit(_message: Fr): Promise<AuthWitness> {
createAuthWit(_messageHash: Fr): Promise<AuthWitness> {
throw new Error('Method not implemented.');
}
}
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/e2e_authwit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('e2e_authwit_tests', () => {
await expect(txCancelledAuthwit.wait()).rejects.toThrow('Transaction ');
});

it('invalid chain id', async () => {
it('invalid version', async () => {
const invalidVersion = Fr.random();

const innerHash = computeInnerAuthWitHash([Fr.fromString('0xdead'), Fr.fromString('0xbeef')]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class SchnorrHardcodedKeyAccountContract extends DefaultAccountContract {
getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider {
const privateKey = this.privateKey;
return {
createAuthWit(message: Fr): Promise<AuthWitness> {
createAuthWit(messageHash: Fr): Promise<AuthWitness> {
const signer = new Schnorr();
const signature = signer.constructSignature(message.toBuffer(), privateKey);
return Promise.resolve(new AuthWitness(message, [...signature.toBuffer()]));
const signature = signer.constructSignature(messageHash.toBuffer(), privateKey);
return Promise.resolve(new AuthWitness(messageHash, [...signature.toBuffer()]));
},
};
}
Expand Down

0 comments on commit 078df07

Please sign in to comment.