Skip to content

Commit dc7841b

Browse files
committed
Remove 32 byte epochId restriction in WASM
Note: this fixes two tests, that previously could not encode the `epochId` in a format compatible with shutter optimism (which is where the data in these tests came from).
1 parent aec033d commit dc7841b

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

js/shutter-crypto/test/test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ describe("Test shutter crypto", () => {
2020
const hexString =
2121
"0b4e86e0ed51ef774210d1c0fe0be6f1b4f0695d5d396b3b003547f752ac82e316375aa37b1739c9c8472b1b5ae09477565bf9d2c0d7db0c39576f4615d32703262d5854bfbac8a60eb6d227f397289e6e51f979b56476b7f7f32a45ede7a61f21d893a54ab6e65b283342adc41d53df5432569c6a8c2304921bce3ea148efb4";
2222
const eonkey = Uint8Array.from(Buffer.from(hexString, "hex"));
23-
const epochId = ethers.getBytes(
24-
ethers.zeroPadValue(Buffer.from("46", "hex"), 32)
25-
);
23+
const epochId = new Uint8Array([70]);
2624

2725
const sigma = new Uint8Array(32);
2826
crypto.getRandomValues(sigma);
@@ -34,6 +32,7 @@ describe("Test shutter crypto", () => {
3432
expect(encrypted).toBeDefined();
3533
});
3634
test("decrypt a message", async () => {
35+
expect(encrypted).toBeDefined();
3736
const decryptionKey = Uint8Array.from(
3837
Buffer.from(
3938
"009bb51574d6a6790faa4724dfad416ca059a286ccfee20be732cac9a81e05dc2f47905cbaa0fb043ff849b0c41e99208d98d27cba3fffb43d63ba50c35259d3",
@@ -52,9 +51,7 @@ describe("Test shutter crypto", () => {
5251

5352
describe("Test known values (values obtained from 'rolling-shutter crypto encrypt/decrypt')", () => {
5453
test("encrypt a message with zero sigma", async () => {
55-
const epochId = ethers.getBytes(
56-
ethers.zeroPadValue(Buffer.from("46", "hex"), 32)
57-
);
54+
const epochId = new Uint8Array([70]);
5855
const eonKey = ethers.getBytes(
5956
Buffer.from(
6057
"0b4e86e0ed51ef774210d1c0fe0be6f1b4f0695d5d396b3b003547f752ac82e316375aa37b1739c9c8472b1b5ae09477565bf9d2c0d7db0c39576f4615d32703262d5854bfbac8a60eb6d227f397289e6e51f979b56476b7f7f32a45ede7a61f21d893a54ab6e65b283342adc41d53df5432569c6a8c2304921bce3ea148efb4",

rolling-shutter/shcryptowasm/shutter_crypto_wasm.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,6 @@ func decodeEpochIDArgBytes(arg js.Value) ([]byte, error) {
147147
if err != nil {
148148
return nil, err
149149
}
150-
if len(b) != 32 {
151-
return nil, fmt.Errorf("sigma must be 32 bytes, got %d", len(b))
152-
}
153150
return b, nil
154151
}
155152

0 commit comments

Comments
 (0)