Skip to content

Commit

Permalink
Fix incorrect signatures being produced for caps
Browse files Browse the repository at this point in the history
  • Loading branch information
sgwilym committed May 15, 2024
1 parent b174dbe commit 9c1d13c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/meadowcap/meadowcap.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { assert, assertEquals, assertRejects } from "$std/assert/mod.ts";
import {
ANY_SUBSPACE,
concat,
encodeEntry,
Entry,
KeypairScheme,
Expand Down Expand Up @@ -82,7 +83,7 @@ const ecdsaScheme: KeypairScheme<ArrayBuffer, CryptoKey, ArrayBuffer> = {
},
signatures: {
sign: (
_publicKey: ArrayBuffer,
publicKey: ArrayBuffer,
secretKey: CryptoKey,
bytestring: Uint8Array,
) => {
Expand All @@ -92,7 +93,7 @@ const ecdsaScheme: KeypairScheme<ArrayBuffer, CryptoKey, ArrayBuffer> = {
hash: { name: "SHA-256" },
},
secretKey,
bytestring,
concat(new Uint8Array(publicKey), bytestring),
);
},
verify: async (
Expand All @@ -118,7 +119,7 @@ const ecdsaScheme: KeypairScheme<ArrayBuffer, CryptoKey, ArrayBuffer> = {
},
publicKeyWeb,
signature,
bytestring,
concat(new Uint8Array(publicKey), bytestring),
);
},
},
Expand Down
8 changes: 6 additions & 2 deletions src/meadowcap/meadowcap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ export class Meadowcap<
user,
);

const receiver = this.getCapReceiver(cap);

const signature = await this.params.userScheme.signatures.sign(
user,
receiver,
secret,
handover,
);
Expand Down Expand Up @@ -280,8 +282,10 @@ export class Meadowcap<
user,
);

const receiver = this.getCapReceiver(cap);

const signature = await this.params.userScheme.signatures.sign(
user,
receiver,
secret,
handover,
);
Expand Down

0 comments on commit 9c1d13c

Please sign in to comment.