Skip to content

Commit

Permalink
Merge pull request #58 from o1-labs/feature/split-ocaml-bindings
Browse files Browse the repository at this point in the history
Post refactor clean up: Split OCaml libs
  • Loading branch information
mitschabaude authored Jun 28, 2023
2 parents f1bba7d + 102172f commit f52126e
Show file tree
Hide file tree
Showing 13 changed files with 92,960 additions and 92,971 deletions.
182,365 changes: 91,085 additions & 91,280 deletions compiled/node_bindings/snarky_js_node.bc.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiled/node_bindings/snarky_js_node.bc.map

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions compiled/web_bindings/snarky_js_web.bc.js

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions crypto/poseidon.unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { testPoseidonLegacyFp } from './test_vectors/poseidonLegacy.js';
import { expect } from 'expect';
import { bigIntToBytes } from './bigint-helpers.js';
import { test, Random } from '../../lib/testing/property.js';
import { Poseidon as SnarkyPoseidon } from '../../lib/hash.js';
import { Field } from '../../lib/core.js';
import { Test } from '../../snarky.js';
import { FieldConst } from '../../lib/field.js';
import { MlArray } from '../../lib/ml/base.js';

let testVectors = testPoseidonKimchiFp.test_vectors;

Expand All @@ -30,14 +31,17 @@ for (let i = 0; i < testVectors.length; i++) {
console.log('poseidon implementation matches the test vectors! 🎉');

test(Random.array(Random.field, Random.nat(20)), (xs) => {
let g1 = Poseidon.hashToGroup(xs);
let g2 = SnarkyPoseidon.hashToGroup(xs.map(Field));
let g1 = Poseidon.hashToGroup(xs)!;
let [, g2x, g2y] = Test.poseidon.hashToGroup(
MlArray.to(xs.map(FieldConst.fromBigint))
);

expect(g1).toBeDefined();

expect(g1?.x).toEqual(g2.x.toBigInt());
expect(g1?.y.x0).toEqual(g2.y.x0.toBigInt());
expect(g1?.y.x1).toEqual(g2.y.x1.toBigInt());
expect(g1.x).toEqual(FieldConst.toBigint(g2x));

let g2y_ = FieldConst.toBigint(g2y);
expect(g1.y.x0 === g2y_ || g1.y.x1 === g2y_).toEqual(true);
});

console.log('poseidon hashToGroup implementations match! 🎉');
Expand Down
4 changes: 4 additions & 0 deletions js/snarky-class-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export default [
name: 'tokenId',
type: 'object',
},
{
name: 'poseidon',
type: 'object',
},
{
name: 'signature',
type: 'object',
Expand Down
Loading

0 comments on commit f52126e

Please sign in to comment.