-
Notifications
You must be signed in to change notification settings - Fork 3
feat: validate prism proofs for all web requests #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jns-ps
wants to merge
13
commits into
main
Choose a base branch
from
include-prism
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7a53b7c
refactor: CT log types are exported and imported
jns-ps 8eab72e
refactor: Common HTTP client superclass
jns-ps f502eb2
refactor: pull out method for hashing with sha256
jns-ps 4f58987
refactor: pull out method for creating STHs from raw bytes
jns-ps 36c879f
feat: improved byte conversion capabilities
jns-ps fbfa96a
refactor: move util methods for byte arrays into separate file
jns-ps 1cb6a7e
feat: add prism types and http client
jns-ps c8ce4de
feat: add bincode-like serialization for prism accounts
jns-ps 7156592
feat: support validation of prism Merkle proofs
jns-ps fe24d03
feat: less verbose light node simulation
jns-ps 09f6c59
feat: validate prism proofs for all web requests
jns-ps 4e9db51
refactor: pull out and re-order methods in background.ts
jns-ps 62e2bde
docs: add documentation to many classes/methods
jns-ps File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /** | ||
| * Concatenates multiple Uint8Arrays into a single Uint8Array. | ||
| * | ||
| * @param arrays - Variable number of Uint8Array arguments to concatenate | ||
| * @returns A new Uint8Array containing all input arrays concatenated in order | ||
| * @example | ||
| * ```ts | ||
| * const arr1 = new Uint8Array([1, 2]); | ||
| * const arr2 = new Uint8Array([3, 4]); | ||
| * const result = concatenateArrays(arr1, arr2); | ||
| * // result is Uint8Array([1, 2, 3, 4]) | ||
| * ``` | ||
| */ | ||
| export function concatenateArrays(...arrays: Uint8Array[]): Uint8Array { | ||
| const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0); | ||
| const result = new Uint8Array(totalLength); | ||
| let offset = 0; | ||
|
|
||
| for (const arr of arrays) { | ||
| result.set(arr, offset); | ||
| offset += arr.length; | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Compares two Uint8Arrays for equality by checking length and values. | ||
| * | ||
| * @param arr1 - First Uint8Array to compare | ||
| * @param arr2 - Second Uint8Array to compare | ||
| * @returns true if arrays are equal in length and values, false otherwise | ||
| * @example | ||
| * ```ts | ||
| * const arr1 = new Uint8Array([1, 2]); | ||
| * const arr2 = new Uint8Array([1, 2]); | ||
| * const equal = areArraysEqual(arr1, arr2); // true | ||
| * ``` | ||
| */ | ||
| export function areArraysEqual(arr1: Uint8Array, arr2: Uint8Array): boolean { | ||
| if (arr1.length !== arr2.length) { | ||
| return false; | ||
| } | ||
| return arr1.every((value, index) => value === arr2[index]); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using constant-time comparison for cryptographic operations
The current array comparison using
everymight be vulnerable to timing attacks if used for comparing sensitive cryptographic data.export function areArraysEqual(arr1: Uint8Array, arr2: Uint8Array): boolean { if (arr1.length !== arr2.length) { return false; } - return arr1.every((value, index) => value === arr2[index]); + // Constant-time comparison + let result = 0; + for (let i = 0; i < arr1.length; i++) { + result |= arr1[i] ^ arr2[i]; + } + return result === 0; }📝 Committable suggestion