Skip to content

Commit 73ef4bd

Browse files
authored
fix: canonicalize identity before encrypting (#134)
1 parent 226db70 commit 73ef4bd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/hypergraph/src/identity/identity-encryption.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { sha256 } from '@noble/hashes/sha256';
55
import type { Hex } from 'viem';
66
import { verifyMessage } from 'viem';
77

8-
import { bytesToHex, hexToBytes } from '../utils/index.js';
8+
import { bytesToHex, canonicalize, hexToBytes } from '../utils/index.js';
99
import type { IdentityKeys, Signer } from './types.js';
1010

1111
// Adapted from the XMTP approach to encrypt keys
@@ -36,7 +36,7 @@ const encrypt = (msg: Uint8Array, secret: Uint8Array): string => {
3636
const ciphertext = aes.encrypt(msg);
3737

3838
// TODO: Use Effect Schema and better serialization?
39-
const ciphertextJson = JSON.stringify({
39+
const ciphertextJson = canonicalize({
4040
aes256GcmHkdfSha256: {
4141
payload: bytesToHex(ciphertext),
4242
hkdfSalt: bytesToHex(hkdfSalt),

0 commit comments

Comments
 (0)