From bbeda07b4b2bd1d31592b8758c74f404dc58f34d Mon Sep 17 00:00:00 2001 From: Gregor Date: Thu, 2 May 2024 10:54:30 +0200 Subject: [PATCH 1/2] remove `provable` reexport --- mina-transaction/transaction-leaves.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mina-transaction/transaction-leaves.ts b/mina-transaction/transaction-leaves.ts index 0b3238f8..004cd9c9 100644 --- a/mina-transaction/transaction-leaves.ts +++ b/mina-transaction/transaction-leaves.ts @@ -9,7 +9,7 @@ import { packToFields, emptyHashWithPrefix, } from '../../lib/provable/crypto/poseidon.js'; -import { provable } from '../../lib/provable/types/struct.js'; +import { provable } from '../../lib/provable/types/provable-derivers.js'; import { mocks, protocolVersions } from '../crypto/constants.js'; export { PublicKey, Field, Bool, AuthRequired, UInt64, UInt32, Sign, TokenId }; From 03241cd44f895249fc28dda7bd133479f2ef0de2 Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 3 May 2024 11:04:23 +0200 Subject: [PATCH 2/2] poseidon test --- crypto/poseidon.unit-test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crypto/poseidon.unit-test.ts b/crypto/poseidon.unit-test.ts index 8242c862..c82de1f4 100644 --- a/crypto/poseidon.unit-test.ts +++ b/crypto/poseidon.unit-test.ts @@ -28,6 +28,19 @@ checkTestVectors(testPoseidonKimchiFp.test_vectors, Poseidon.hash); checkTestVectors(testPoseidonLegacyFp.test_vectors, PoseidonLegacy.hash); +// calling update() subsequently on size-2 chunks is the same as calling hash() on the full input + +test(Random.array(Random.field, 5), (xs) => { + let h1 = Poseidon.hash(xs); + + let state = Poseidon.initialState(); + state = Poseidon.update(state, [xs[0], xs[1]]); + state = Poseidon.update(state, [xs[2], xs[3]]); + state = Poseidon.update(state, [xs[4]]); + let h2 = state[0]; + expect(h1).toEqual(h2); +}); + console.log('poseidon implementation matches the test vectors! 🎉'); test(Random.array(Random.field, Random.nat(20)), (xs) => {