Skip to content

feat(snap): support typed uint crypto - #130

Merged
gmesika-coti merged 4 commits into
coti-io:mainfrom
vladi-coti:decrypt-fix
Jul 1, 2026
Merged

feat(snap): support typed uint crypto#130
gmesika-coti merged 4 commits into
coti-io:mainfrom
vladi-coti:decrypt-fix

Conversation

@vladi-coti

@vladi-coti vladi-coti commented Jun 18, 2026

Copy link
Copy Markdown
Member
  • Extended existing encrypt and decrypt RPCs to support typed uint64/uint256 payloads.
  • Added single-value and batch support for typed confidential uint encryption/decryption.
  • Kept AES key handling inside the Snap and returned raw decrypted integer strings.

@vladi-coti
vladi-coti requested a review from a team June 18, 2026 14:05
@vladi-coti vladi-coti changed the title feat: implement decrypt-balance functionality and normalize balance payloads feat(snap): support typed uint crypto Jun 18, 2026
Comment thread packages/snap/src/index.tsx Outdated
return decodeUint(new Uint8Array([...ciphertext, ...r])).toString();
};

const encryptUint256Value = (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont you think that this code should have being in the coti-sdk-typescript?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, do you want me to create a PR for it in the sdk then change this PR?

Comment thread packages/snap/src/index.tsx Outdated
* Normalizes a JSON-RPC-safe confidential uint payload into the bigint shapes expected by
* SDK decrypt helpers. Exported so the parser can be tested without the Snap sandbox.
*/
export const normalizeCtPayload = (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont you think that this code should have being in the coti-sdk-typescript?

Comment thread packages/snap/src/index.tsx
…ayloads

- Added a new RPC method 'decrypt-balance' to handle decryption of balance payloads.
- Introduced utility functions for normalizing 64-bit and 256-bit balance formats.
- Enhanced error handling for malformed balance entries and invalid variants.
- Updated tests to cover new functionality and ensure robustness of the decryption process.
Route typed uint64/uint256 encryption and ctUint64/ctUint256
decryption through the existing RPCs so the AES key stays in Snap
state. Remove the temporary decrypt-balance RPC.
@vladi-coti
vladi-coti requested a review from gmesika-coti July 1, 2026 14:44
@gmesika-coti
gmesika-coti merged commit f9bc369 into coti-io:main Jul 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants