Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mitschabaude committed Nov 6, 2024
1 parent 13a895a commit 3af1a08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
11 changes: 3 additions & 8 deletions src/credentials/dynamic-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,12 @@ class DynamicArrayBase<T = any, V = any> {

// create blocks of 2 field elements each
// TODO abstract this into a `chunk()` method that returns a DynamicArray<StaticArray<T>>
let mustPack = packedFieldSize(type) > 1;
let elementSize = bitSize(type);
let elementsPerHalfBlock = Math.floor(254 / elementSize);
let fullField = elementsPerHalfBlock === 0;
if (elementsPerHalfBlock === 0) elementsPerHalfBlock = 1; // larger types are compressed

let elementsPerBlock = 2 * elementsPerHalfBlock;
assert(!mustPack, 'TODO'); // this should get a separate branch here

// we pack the length at the beginning of the first block
// for efficiency (to avoid unpacking the length), we first put zeros at the beginning
Expand All @@ -343,12 +341,9 @@ class DynamicArrayBase<T = any, V = any> {
let blocks = new Blocks(chunked, nBlocks).map(
StaticArray(Field, 2),
(block) => {
let firstHalf = block.array
.slice(0, elementsPerHalfBlock)
.map((el) => packToField(el, type));
let secondHalf = block.array
.slice(elementsPerHalfBlock)
.map((el) => packToField(el, type));
let fields = block.array.map((el) => packToField(el, type));
let firstHalf = fields.slice(0, elementsPerHalfBlock);
let secondHalf = fields.slice(elementsPerHalfBlock);
if (fullField) {
return [defined(firstHalf[0]), defined(secondHalf[0])];
}
Expand Down
10 changes: 5 additions & 5 deletions src/credentials/dynamic-hash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ async function main() {

let RecordArray = DynamicArray(Record, { maxLength: 5 });

// await test('hash arrays of records', () => {
Provable.witness(RecordArray, () => array)
.hash()
.assertEquals(arrayHash, 'array');
// });
await test('hash arrays of records', () => {
Provable.witness(RecordArray, () => array)
.hash()
.assertEquals(arrayHash, 'array');
});
}

await test('outside circuit', () => main());
Expand Down

0 comments on commit 3af1a08

Please sign in to comment.