Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
0x471 committed Aug 29, 2024
1 parent 321ab8a commit 2878999
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/chacha20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ class ChaChaState {
counter, nonce[0], nonce[1], nonce[2],
];

// Filter out any undefined values and convert to UInt32 format
this.state = stateValues
.filter(value => value !== undefined) // Filter out undefined values
.filter(value => value !== undefined)
.map(value => UInt32.fromValue(BigInt(value)));
}

Expand Down Expand Up @@ -69,23 +68,23 @@ class ChaChaState {
this.state[i] = UInt32.fromFields([Field.from((this.state[i].toBigint() + other.state[i].toBigint()) & 0xFFFFFFFFn)]);
}
}
// toLe4Bytes(): Uint8Array {
// const length = this.state.length;
// const buffer = new Uint8Array(length * 4);

// for (let i = 0; i < length; i++) {
// // Explicitly specify the type of value as number
// const value: number = this.state[i] as number;

// // Convert each number value to 4 bytes in little-endian order
// buffer[i * 4] = value & 0xFF;
// buffer[i * 4 + 1] = (value >> 8) & 0xFF;
// buffer[i * 4 + 2] = (value >> 16) & 0xFF;
// buffer[i * 4 + 3] = (value >> 24) & 0xFF;
// }

// return buffer;
// }
// toLe4Bytes(): Uint8Array {
// const length = this.state.length;
// const buffer = new Uint8Array(length * 4);

// for (let i = 0; i < length; i++) {
// // Explicitly specify the type of value as number
// const value: number = this.state[i] as number;

// // Convert each number value to 4 bytes in little-endian order
// buffer[i * 4] = value & 0xFF;
// buffer[i * 4 + 1] = (value >> 8) & 0xFF;
// buffer[i * 4 + 2] = (value >> 16) & 0xFF;
// buffer[i * 4 + 3] = (value >> 24) & 0xFF;
// }

// return buffer;
// }



Expand Down

0 comments on commit 2878999

Please sign in to comment.